10
DO NOT scale the number of workers to the number of clients you expect to have.
11
Gunicorn should only need 4-12 worker processes to handle hundreds or thousands
12
of simultaneous clients. Remember, Gunicorn is **NOT** designed for serving slow
13
clients, that's the job of Nginx_.
15
See Configuration_ for a more thorough description of the available parameters.
17
.. _Nginx: http://www.nginx.org
18
.. _Configuration: configuration.html
23
When dealing with large numbers of concurrent connections there are a handful of
24
kernel parameters that you might need to adjust. Generally these should only
25
affect sites with a very large concurrent load. These parameters are not
26
specific to Gunicorn, they would apply to any sort of network server you may be
29
The commands listed are tested under Mac OS X 10.6. Your flavor of Unix may use
30
slightly different flags. Always reference the appropriate man pages if
33
File Descriptor Limits
34
++++++++++++++++++++++
36
One of the first settings that usually needs to be bumped is the maximum number
37
of open file descriptors for a given process. For the confused out there,
38
remember that Unices treat sockets as files.
47
Listening sockets have an associated queue of incoming connections that are
48
waiting to be accepted. If you happen to have a stampede of clients that fill up
49
this queue new connections will eventually start getting dropped.
53
$ sudo sysctl -w kern.ipc.somaxconn="2048"
58
After a socket is closed it enters the TIME_WAIT state. This can become an issue
59
after a prolonged burst of client activity. Eventually the ephemeral port range
60
is exhausted which can cause new connections to stall while they wait for a
63
This setting is generally only required on machines that are being used to test
68
$ sudo sysctl -w net.inet.ip.portrange.first="8048"