Forking New Consumers for RabbitMQ in NodeJS

175 views
Skip to first unread message

Tri Wibowo

unread,
Jul 25, 2016, 12:22:14 PM7/25/16
to rabbitmq-users

So I'm implementing work queue with RabbitMQ in NodeJS. The consumer is a child process and I plan to fork new ones as need arises, but I read in the official documentation that :

Because of the additional resource allocations required, spawning a large number of child Node.js processes is not recommended.

So should I stick with only a few of child processes as consumers or is there any flaw in my approach?


Btw, one guy told me to check this out. Haven't tried it out, but it seems using threads is more resource-efficient than forking new child process *shrugs*


Thanks~

Michael Klishin

unread,
Jul 25, 2016, 8:19:14 PM7/25/16
to rabbitm...@googlegroups.com
There are Node modules that manage pools ("clusters") of processes.

Note that every child OS process must open its own connection
to RabbitMQ (or anything that uses sockets, actually) because fork(2) creates
unintentional file descriptor sharing, often is less-than-obvious ways (e.g. [1]).

Concurrency + shared mutable state = problems.



--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Tri R.A. Wibowo

unread,
Jul 25, 2016, 9:46:58 PM7/25/16
to rabbitm...@googlegroups.com
Each of my child processes does open its own connection.

So you're saying I should use such module instead?

--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/pcynjX5BUEo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.

Michael Klishin

unread,
Jul 26, 2016, 7:36:08 AM7/26/16
to rabbitm...@googlegroups.com
Yes. Process pooling is not a trivial problem even if it sounds like one. Consider
using an existing library such as [1] first.

Tri Wibowo

unread,
Jul 26, 2016, 7:50:18 AM7/26/16
to rabbitmq-users
Noted. Gonna try that one.
Reply all
Reply to author
Forward
0 new messages