mercredi 25 février 2015

Node.JS Job / Background Process and high availability

I’m working on the design of a new Node.JS application. I see a lot of options and possibilities on getting a high availability production environment: load balanced apps and reverse proxies, Redis clusters, MongoDB replicas and sharding deployments, etc.


The solution I’m planning have the need of a background process, doing some processing on specific MongoDB tables, and in-memory Redis data. The job needs to run every minute, and I can’t be run in parallel with another instance of the same job.


I know how to build that kind of job in Node using timers. In the other hand, i know I can have some monitoring process probing the job process, but I can see a clear solution on how to replace a failing app in another host.


I found some blog posts about “HA Singleton” (a sort of pattern in the Java world), and database based locks for resolving this situation. May be I can implement a locking mechanism using a lock stored on a Redis replicated data store, with several jobs pooling the lock state, but I guess it will be hard to implement some “extreme” situations (a job pooling the lock state a few milliseconds after a previous job).


There is any pattern of best practice about how to resolve this king of situation?.


Aucun commentaire:

Enregistrer un commentaire