andrewvc / dripdrop

Experimental Swiss Army Knife of Network Concurrency, ZeroMQ, EventMachine, WebSockets, HTTP, and More
MIT License
144 stars 10 forks source link

Answer rq from nodelet #18

Open elcuervo opened 13 years ago

elcuervo commented 13 years ago

Hello, i was wondering if there is a way of answer a rq from a separate nodelet. I'm trying to replicate the mongrel2 zmq behaviour using multiple "workers"

andrewvc commented 13 years ago

I'm not sure if I understand your question fully, but I think you're asking about communicating between nodelets. The best way would be with ZMQ sockets. For instance, you could communicate between nodelets with ZMQ pub/sub or xreq/xrep. See this file for an example: https://github.com/andrewvc/dripdrop/blob/master/example/complex/server.rb

If you want multiple workers however, you're most likely best off spawning multiple ruby processes. You'd want to create one 'master' process that delegates work, and have a bunch of other processes that process jobs. The reason being that this way you can use multiple cores on your machine.

DripDrop is built on eventmachine which is intended for single-threaded use, so multiple workers don't really make sense in the context of a single process.