javascript - How to load balance publish/subscribe websocket requests to node server using nginx as a load balancer? -


i have following scenario. want implement pub/sub model using socket.io library on node.js rabbitmq queueing service. particular websocket can act publisher or subscriber depending upon query string following requst

var socket = io.connect("http://localhost:8000?type=publisher&id=1"); 

similarly subscriber

var socket = io.connect("http://localhost:8000?type=subscriber&id=1"); 

now have maintained rabbitmq @ backend provide funcitonality, node.js server. publisher publishers central exchange of rabbitmq different topics being formed each subscriber depending upon "id" (specified in url) listen. works fine no load balancer in front of node.js servers. problem arises when want use nginx load balancer in front of node servers. architecture m following each node sever has own rabbitmq server keep track of publishers , subscribers. in order implement pub/sub model should made mandatory subscriber request particular id should go same server request publisher of particular id went. how keep track of node server nginx sent publisher requst, request subscriber of same id can directed same server pub/sub model implemented.

tl;dr:- there way keep track or requests sent node server specified in "upstream " cluster of nginx. ??? there module in nginx? if no , how resolve problem m facing?

thanks


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -