セルロイドプールに対する私の理解は、ちょっと壊れていると思います. 以下で説明しようと思いますが、その前に簡単なメモを。
注: 私たちのシステムはfast client
、ZeroMQ を介して非常に通過するメッセージに対して実行されています。
以下のバニラセルロイドアプリで
class VanillaClient include Celluloid::ZMQ def read loop { async.evaluate_response(socket.read_multipart) end def evaluate_response(data) ## the reason for using defer can be found over here. Celluloid.defer do ExternalService.execute(data) end end end
私たちのシステムは、しばらくして、理由 'Can't spawn more thread'
(またはそのようなもの)の後に失敗します
そのため、(上記の問題を回避するために) Celluloid Pool を使用して、生成されるスレッドの数を制限できるようにするつもりでした。
Celluloid Pool に対する私の理解は、Celluloid Pool は、タスクを並行して分散できるように、アクターのプールを維持するということです。
したがって、私はそれをテストすることにしましたが、私のテストケースによると、シリアルに動作するようです (つまり、物事が分散したり、並列に発生したりすることはありません)。
これを複製する例。
## Send message `1` to the the_client.rb
## Send message `2` to the the_client.rb
## take message from sender-1 and sender-2 and return it back to receiver.rb
## heads on, the `sleep` is introduced to test/replicate the IO block that happens in the actual code.
## print the message obtained from the_client.rb
によって送信されたデータを消費する前に、プールが 1 秒間ブロックされたように見えるsender-2.rb
前に が実行された場合(スリープ時間は、ここで確認できます)。sender-1.rb
20
the_client.rb
sender-1.rb
ruby-2.2.2 でも jRuby-9.0.5.0 でも同じように動作します。プールがそのような行動をとる原因として考えられるものは何ですか?