Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

nodejs cluster - keep client session on one worker

nodejs cluster - keep client session on one worker


Is it possible to change strategy of assigning Worker to request on nodejs cluster? I mean on first client access select worker and later keep client on this worker by session id.

I'm using memory cache as a storage for large structure of objects. Every client (session) has own data in this storage. All stored objects are configured and referenced (with cycles). This was solution to complicated serialization to redis/memcached.

Now on cluster, every request could be processed by different worker, so data for same session will be created, in worst case, under every worker.

Is it about some setting of cluster, or is it possible to write method? which helps select worker for client session. When worker dies, it will select new one and session data will be recreated from permanent storage (mysql).

Problem courtesy of: opio


Try amino cluster, it has support for sticky sessions through amino gateway.

Solution courtesy of: Dmitry


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

nodejs cluster - keep client session on one worker


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription