Open Dragomir-Ivanov opened 6 years ago
You can do it by keeping server distribution state in a pool of available slots by server using a simple counter, all of this within a middleware component that receives an outgoing request. Then, you should manage the request completion in order to free the taken slot. If you want traffic control on the client side in order to limit the amount of requests (not sure if this makes sense anyway), you would possibly need to use a waiting queue mechanism in case of all the slots are taken and await any new request.
If you want more sophisticated logic, you could use a content hashing algorithm for a truly uniform distribution in the pool. For node.js, you could use: https://www.npmjs.com/package/consistent-hashing https://www.npmjs.com/package/consistent-hash
@h2non Thanks for the fast response. I am thinking if I go the route you have suggested with the simpler counter, didn't I loose the server balancing functionality. Perfectly the system should pick a server with a better score if not fully utilized at the moment.
Hi again, Was wondering how to implement maximum connection count to a server ( within a server pool )? So for example, if I have 3 servers defined, each will handle up to 5 connections, then It will result in 15 simultaneous connections at most. Maybe something among the lines on Middleware?
Thanks again