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

« back to all changes in this revision

Viewing changes to doc/site/faq.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
1
template: doc.html
2
2
title: FAQ
3
3
 
4
 
FAQ
5
 
===
 
4
_TOC_TOP_
 
5
 
 
6
.. contents::
 
7
    :backlinks: top
 
8
 
 
9
_TOC_BOT_
 
10
 
 
11
 
 
12
WSGI Bits
 
13
=========
 
14
 
 
15
How do I set SCRIPT_NAME?
 
16
-------------------------
 
17
 
 
18
By default ``SCRIPT_NAME`` is an empy string. The value could be set by
 
19
setting ``SCRIPT_NAME`` in the environment or as an HTTP header.
 
20
 
 
21
 
 
22
Server Stuff
 
23
============
 
24
 
 
25
How do I reload my application in Gunicorn?
 
26
-------------------------------------------
 
27
 
 
28
You can gracefully reload by sending HUP signal to gunicorn::
 
29
 
 
30
    $ kill -HUP masterpid
 
31
 
 
32
How might I test a proxy configuration?
 
33
---------------------------------------
 
34
 
 
35
The Slowloris_ script is a great way to test that your proxy is correctly
 
36
buffering responses for the synchronous workers.
 
37
 
 
38
How can I name processes?
 
39
-------------------------
 
40
 
 
41
If you install the Python package setproctitle_ Gunicorn will set the process
 
42
names to something a bit more meaningful. This will affect the output you see
 
43
in tools like ``ps`` and ``top``. This helps for distinguishing the master
 
44
process as well as between masters when running more than one app on a single
 
45
machine. See the proc_name_ setting for more information.
 
46
 
 
47
.. _slowloris: http://ha.ckers.org/slowloris/
 
48
.. _setproctitle: http://pypi.python.org/pypi/setproctitle
 
49
.. _proc_name: /configure.html#proc-name
 
50
 
 
51
 
 
52
Worker Processes
 
53
================
6
54
 
7
55
How do I know which type of worker to use?
8
 
  Test. Read the "Synchronous vs Asynchronous workers" section on the 
9
 
  deployment_ page. Test some more.
 
56
------------------------------------------
 
57
 
 
58
Read the design_ page for help on the various worker types.
10
59
 
11
60
What types of workers are there?
12
 
  These can all be used with the ``-k`` option and specifying them
13
 
  as ``egg:gunicorn#$(NAME)`` where ``$(NAME)`` is chosen from this list.
14
 
  
15
 
  * ``sync`` - The default synchronous worker
16
 
  * ``eventlet`` - Asynchronous workers based on Greenlets
17
 
  * ``gevent`` - Asynchronous workers based on Greenlets
18
 
  * ``tornado`` - Asynchronous workers based on FriendFeed's Tornado server.
19
 
 
20
 
How might I test a proxy configuration?
21
 
  Check out slowloris_ for a script that will generate significant slow
22
 
  traffic. If your application remains responsive through out that test you
23
 
  should be comfortable that all is well with your configuration.
24
 
 
25
 
How do I reload my application in Gunicorn?
26
 
  You can gracefully reload by sending HUP signal to gunicorn::
27
 
 
28
 
    $ kill -HUP masterpid
29
 
 
30
 
How do I increase or decrease the number of running workers dynamically?
 
61
--------------------------------
 
62
 
 
63
Check out the configuration docs for worker_class_
 
64
 
 
65
How can I figure out the best number of worker processes?
 
66
---------------------------------------------------------
 
67
 
 
68
Here is our recommendation for tuning the `number of workers`_.
 
69
 
 
70
How can I change the number of workers dynamically?
 
71
---------------------------------------------------
 
72
 
31
73
    To increase the worker count by one::
32
74
 
33
75
        $ kill -TTIN $masterpid
36
78
 
37
79
        $ kill -TTOU $masterpid
38
80
 
39
 
How can I figure out the best number of worker processes?
40
 
  Start gunicorn with an approximate number of worker processes. Then use the
41
 
  TTIN and/or TTOU signals to adjust the number of workers under load.
42
 
 
43
 
How do I set SCRIPT_NAME?
44
 
    By default ``SCRIPT_NAME`` is an empy string. The value could be set by
45
 
    setting ``SCRIPT_NAME`` in the environment or as an HTTP header.
46
 
 
47
 
How can I name processes?
48
 
    You need to install the Python package setproctitle_. Then you can specify
49
 
    a base process name on the command line (``-n``) or in the configuration
50
 
    file.
51
 
 
52
 
.. _deployment: http://gunicorn.org/deployment.html
53
 
.. _slowloris: http://ha.ckers.org/slowloris/
54
 
.. _setproctitle: http://pypi.python.org/pypi/setproctitle
55
 
.. _Eventlet: http://eventlet.net
56
 
.. _Gevent: http://gevent.org
 
 
b'\\ No newline at end of file'
 
81
.. _design: /design.html
 
82
.. _worker_class: /configure.html#worker-class
 
83
.. _`number of workers`: /design.html#how-many-workers
 
84
 
 
85
Kernel Parameters
 
86
=================
 
87
 
 
88
When dealing with large numbers of concurrent connections there are a handful of
 
89
kernel parameters that you might need to adjust. Generally these should only
 
90
affect sites with a very large concurrent load. These parameters are not
 
91
specific to Gunicorn, they would apply to any sort of network server you may be
 
92
running.
 
93
 
 
94
These commands are for Linux. Your particular OS may have slightly different
 
95
parameters.
 
96
 
 
97
How can I increase the maximum number of file descriptors?
 
98
----------------------------------------------------------
 
99
 
 
100
One of the first settings that usually needs to be bumped is the maximum number
 
101
of open file descriptors for a given process. For the confused out there,
 
102
remember that Unices treat sockets as files.
 
103
 
 
104
::
 
105
    
 
106
    $ sudo ulimit -n 2048
 
107
 
 
108
How can I increase the maximum socket backlog?
 
109
----------------------------------------------
 
110
 
 
111
Listening sockets have an associated queue of incoming connections that are
 
112
waiting to be accepted. If you happen to have a stampede of clients that fill up
 
113
this queue new connections will eventually start getting dropped.
 
114
 
 
115
::
 
116
 
 
117
    $ sudo sysctl -w net.core.somaxconn="2048"