Elixir/Phoenixで並行処理を使って大量のメッセージに対応するBOTサーバーを構築する方法を調査してみました。ElixirbotPhoenix Facebook Messenger PlatformやLINE BOTが話題になっていますが、下記の記事でも言及されているように、BOTサーバーとして大量メッセージに対応するには「並行処理」がキモになってきます。 大量メッセージが来ても安心なLINE BOTサーバのアーキテクチャ そしてElixirといえばやっぱり「並行処理」なわけです。ということで「BOTサーバーを効率よく開発するにはElixir/Phoenixってとても良い選択なのでは?」という仮定のもと、色々と検証してみました。 並行処理のコード Elixirでプロセスを起動・管理する方法はいくつも用意されていますが、BOTサーバーの要件的に「状態」を管理する必要はありませんし、
スーパバイザは、他のプロセスを監視するという一つの目的に特化したプロセスです。 子プロセスが失敗した際に自動的に再起動させることによって、耐障害性の高いアプリケーションを作ることを可能にします。 設定 スーパバイザの魔術は Supervisor.start_link/2 関数の中にあります。 スーパーバイザプロセスと子プロセスを開始するのに加えて、子を管理するためにスーパーバイザが使用する戦略を定義することができます。 OTPの並行性レッスンで実装したSimpleQueueを用いて、始めていきましょう。 新しいプロジェクトを mix new simple_queue --sup を使って作成することで、スーパバイザツリーも一緒に作成することができます。 SimpleQueue モジュール用のコードは lib/simple_queue.ex へ、スーパバイザを起動するコードは lib/sim
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く