On May 21, 02014, at 5:06, Mouli Kumar <[email protected]> wrote:

> I am working on a NodeJs based application primarily a Web app written using 
> AngularJs/HTML/CSS.
> I have a need for running a worker process in my server which will process 
> background jobs. Like, sending emails to 100s of staff at the end of the day, 
> or processing billing related records etc. Sometimes I also want this process 
> to listen to the main NodeJS process that is serving the webui, so that the 
> main process can handover the work to the worker for immediate processing.
> 
> Things I have considered
> 1) Worker process will run as another NodeJs app (entirely different app, no 
> forking, no clustering from the main process).
> 2) Worker process will open a server socket for listening to the main nodejs 
> process for any immediate job delegation.
> 3) Worker process will poll the database (mongodb) periodically to pick up 
> unprocessed records (say, every 5 sec)
> 
> Your expert suggestions needed
> 1) Is the approach explained above viable? 

Yes.

> 2) Communicating between the 2 nodejs processes using sockets, is it a 
> recommended approach. I may have to move this worker process to a different 
> server and may even scale out if required.

Sounds decent. Consider Gearman instead though.

> 3) Is mongodb a good option for implementing a workload queue. My web 
> application uses MongoDB as database, so I did not consider moving to a 
> different database for the queue. Any suggestions for in-memory queue.

I love Gearman for queueing. It gives limited guarantees (design for actions to 
be repeatable in the case of failures detected). It’s the right mix for a 
robust, simple app, I think.

Aria

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to