0

Gunicorn design says:

Gunicorn relies on the operating system to provide all of the load balancing
when handling requests. 

With WebSocket requests, this is resulting in uneven load balancing of requests to the workers. that is, some workers handle lot more WebSocket connections than others. How do you deal with this and get a uniform distribution?

I am using geventwebsocket for the WebSocket server application.

vrtx54234
  • 2,196
  • 3
  • 30
  • 53
  • 1
    I know this is a bit late but I don't see what Nginx has to do with that. Gunicorn docs are only talking about load balancing across the worker processes not the backends to Nginx. You could make multiple Gunicorn instances on one machine and have Nginx LB to them. – Joe Doherty Oct 12 '15 at 10:40
  • @JoeDoherty - yeah, I wanted to know if running multiple gunicorn instances is the only solution. The problem with that though, is, I will have to use different port for each instance and so I cannot autoscale them. Thoughts? – vrtx54234 Oct 12 '15 at 15:23
  • You can auto scale with a bit of scripting and a port range covering the number of available CPU cores on each box. This is the only way though. The KFS will do a good job for you though so it may be overkill to get equal balance. Depends on cores and utilized workers. – Joe Doherty Oct 12 '15 at 15:27
  • Thanks. quick question - what is KFS? – vrtx54234 Oct 12 '15 at 17:48
  • Knife, fork, spoon :P I actually meant CFS: Completely Fair Scheduler. It is how Linux splits CPU time across processes by default. – Joe Doherty Oct 12 '15 at 18:01
  • @JoeDoherty - I'd say CFS is not applicable for websocket apps, unlike short lived HTTP request handlers, as the websocket handler may not busy or overly busy when new requests come in. It would have been great if gunicorn has an option to do other types of scheduling too. – vrtx54234 Oct 13 '15 at 17:33
  • Your right it isn't but green threads in general aren't applicable for the CFS. Web sockets in general will never generally be used with native threads – Joe Doherty Oct 13 '15 at 19:46

0 Answers0