~ubuntu-branches/ubuntu/maverick/gunicorn/maverick

« back to all changes in this revision

Viewing changes to doc/site/tuning.rst

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-07-16 10:44:12 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100716104412-iddgoj0lss2hxg7q
Tags: 0.10.0-1
* New upstream release.
* Add python-setproctitle to Suggests. Thanks to Örjan Persson
  <orange@fobie.net>.
* Bump Standards-Version to 3.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
template: doc.html
2
 
title: Tuning
3
 
 
4
 
Tuning
5
 
======
6
 
 
7
 
Unicorn Configuration
8
 
---------------------
9
 
 
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_.
14
 
 
15
 
See Configuration_ for a more thorough description of the available parameters.
16
 
 
17
 
.. _Nginx: http://www.nginx.org
18
 
.. _Configuration: configuration.html
19
 
 
20
 
Kernel Parameters
21
 
-----------------
22
 
 
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
27
 
running.
28
 
 
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
31
 
uncertain.
32
 
 
33
 
File Descriptor Limits
34
 
++++++++++++++++++++++
35
 
 
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.
39
 
 
40
 
::
41
 
    
42
 
    $ sudo ulimit -n 2048
43
 
 
44
 
Listen Queue Size
45
 
+++++++++++++++++
46
 
 
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.
50
 
 
51
 
::
52
 
 
53
 
    $ sudo sysctl -w kern.ipc.somaxconn="2048"
54
 
 
55
 
Ephemeral Port Range
56
 
++++++++++++++++++++
57
 
 
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
61
 
valid port.
62
 
 
63
 
This setting is generally only required on machines that are being used to test
64
 
a network server.
65
 
 
66
 
::
67
 
 
68
 
    $ sudo sysctl -w net.inet.ip.portrange.first="8048"