gunicorn/doc/htdocs/faq.html
2011-04-23 11:04:32 +02:00

168 lines
9.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Green Unicorn - FAQ</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="container" class="twocolumn">
<div id="menu">
<div class="logo">
<a href="./">
<img src="images/gunicorn.png" alt="Gunicorn - Green Unicorn" />
</a>
</div>
<ul id="actions">
<li><a href="install.html">Install</a></li>
<li><a href="run.html">Run</a></li>
<li><a href="configure.html">Configure</a></li>
<li><a href="deploy.html">Deploy</a></li>
<li><a href="design.html">Design</a></li>
<li><a href="faq.html">FAQ</a></li>
<li><a href="community.html">Community</a></li>
<li><a href="news.html">News</a></li>
<li><a href="http://github.com/benoitc/gunicorn/">Code</a></li>
<li><a href="http://github.com/benoitc/gunicorn/issues">Issues</a></li>
</ul>
</div>
<div id="content">
<div class="document">
<div class="section" id="wsgi-bits">
<h2><a class="toc-backref" href="#contents">WSGI Bits</a></h2>
<div class="section" id="how-do-i-set-script-name">
<h3><a class="toc-backref" href="#contents">How do I set SCRIPT_NAME?</a></h3>
<p>By default <tt class="docutils literal">SCRIPT_NAME</tt> is an empy string. The value could be set by
setting <tt class="docutils literal">SCRIPT_NAME</tt> in the environment or as an HTTP header.</p>
</div>
</div>
<div class="section" id="server-stuff">
<h2><a class="toc-backref" href="#contents">Server Stuff</a></h2>
<div class="section" id="how-do-i-reload-my-application-in-gunicorn">
<h3><a class="toc-backref" href="#contents">How do I reload my application in Gunicorn?</a></h3>
<p>You can gracefully reload by sending HUP signal to gunicorn:</p>
<pre class="literal-block">
$ kill -HUP masterpid
</pre>
</div>
<div class="section" id="how-might-i-test-a-proxy-configuration">
<h3><a class="toc-backref" href="#contents">How might I test a proxy configuration?</a></h3>
<p>The <a class="reference external" href="http://ha.ckers.org/slowloris/">Slowloris</a> script is a great way to test that your proxy is correctly
buffering responses for the synchronous workers.</p>
</div>
<div class="section" id="how-can-i-name-processes">
<h3><a class="toc-backref" href="#contents">How can I name processes?</a></h3>
<p>If you install the Python package <a class="reference external" href="http://pypi.python.org/pypi/setproctitle">setproctitle</a> Gunicorn will set the process
names to something a bit more meaningful. This will affect the output you see
in tools like <tt class="docutils literal">ps</tt> and <tt class="docutils literal">top</tt>. This helps for distinguishing the master
process as well as between masters when running more than one app on a single
machine. See the <a class="reference external" href="/configure.html#proc-name">proc_name</a> setting for more information.</p>
</div>
<div class="section" id="gunicorn-fails-to-start-with-upstart">
<h3><a class="toc-backref" href="#contents">Gunicorn fails to start with upstart</a></h3>
<p>Make sure you run gunicorn with <tt class="docutils literal"><span class="pre">--daemon</span></tt> option.</p>
</div>
<div class="section" id="why-is-there-no-http-keep-alive">
<h3><a class="toc-backref" href="#contents">Why is there no HTTP Keep-Alive?</a></h3>
<p>The default Sync workers are designed to run behind Nginx which only uses
HTTP/1.0 with its upstream servers. If you want to deploy Gunicorn to
handle unbuffered requests (ie, serving requests directly from the internet)
you should use one of the async workers.</p>
</div>
</div>
<div class="section" id="worker-processes">
<h2><a class="toc-backref" href="#contents">Worker Processes</a></h2>
<div class="section" id="how-do-i-know-which-type-of-worker-to-use">
<h3><a class="toc-backref" href="#contents">How do I know which type of worker to use?</a></h3>
<p>Read the <a class="reference external" href="/design.html">design</a> page for help on the various worker types.</p>
</div>
<div class="section" id="what-types-of-workers-are-there">
<h3><a class="toc-backref" href="#contents">What types of workers are there?</a></h3>
<p>Check out the configuration docs for <a class="reference external" href="/configure.html#worker-class">worker_class</a></p>
</div>
<div class="section" id="how-can-i-figure-out-the-best-number-of-worker-processes">
<h3><a class="toc-backref" href="#contents">How can I figure out the best number of worker processes?</a></h3>
<p>Here is our recommendation for tuning the <a class="reference external" href="/design.html#how-many-workers">number of workers</a>.</p>
</div>
<div class="section" id="how-can-i-change-the-number-of-workers-dynamically">
<h3><a class="toc-backref" href="#contents">How can I change the number of workers dynamically?</a></h3>
<blockquote>
<p>To increase the worker count by one:</p>
<pre class="literal-block">
$ kill -TTIN $masterpid
</pre>
<p>To decrease the worker count by one:</p>
<pre class="literal-block">
$ kill -TTOU $masterpid
</pre>
</blockquote>
</div>
</div>
<div class="section" id="kernel-parameters">
<h2><a class="toc-backref" href="#contents">Kernel Parameters</a></h2>
<p>When dealing with large numbers of concurrent connections there are a handful of
kernel parameters that you might need to adjust. Generally these should only
affect sites with a very large concurrent load. These parameters are not
specific to Gunicorn, they would apply to any sort of network server you may be
running.</p>
<p>These commands are for Linux. Your particular OS may have slightly different
parameters.</p>
<div class="section" id="how-can-i-increase-the-maximum-number-of-file-descriptors">
<h3><a class="toc-backref" href="#contents">How can I increase the maximum number of file descriptors?</a></h3>
<p>One of the first settings that usually needs to be bumped is the maximum number
of open file descriptors for a given process. For the confused out there,
remember that Unices treat sockets as files.</p>
<pre class="literal-block">
$ sudo ulimit -n 2048
</pre>
</div>
<div class="section" id="how-can-i-increase-the-maximum-socket-backlog">
<h3><a class="toc-backref" href="#contents">How can I increase the maximum socket backlog?</a></h3>
<p>Listening sockets have an associated queue of incoming connections that are
waiting to be accepted. If you happen to have a stampede of clients that fill up
this queue new connections will eventually start getting dropped.</p>
<pre class="literal-block">
$ sudo sysctl -w net.core.somaxconn=&quot;2048&quot;
</pre>
</div>
</div>
</div>
</div>
<div id="toc">
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#wsgi-bits" id="id1">WSGI Bits</a><ul>
<li><a class="reference internal" href="#how-do-i-set-script-name" id="id2">How do I set SCRIPT_NAME?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#server-stuff" id="id3">Server Stuff</a><ul>
<li><a class="reference internal" href="#how-do-i-reload-my-application-in-gunicorn" id="id4">How do I reload my application in Gunicorn?</a></li>
<li><a class="reference internal" href="#how-might-i-test-a-proxy-configuration" id="id5">How might I test a proxy configuration?</a></li>
<li><a class="reference internal" href="#how-can-i-name-processes" id="id6">How can I name processes?</a></li>
<li><a class="reference internal" href="#gunicorn-fails-to-start-with-upstart" id="id7">Gunicorn fails to start with upstart</a></li>
<li><a class="reference internal" href="#why-is-there-no-http-keep-alive" id="id8">Why is there no HTTP Keep-Alive?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#worker-processes" id="id9">Worker Processes</a><ul>
<li><a class="reference internal" href="#how-do-i-know-which-type-of-worker-to-use" id="id10">How do I know which type of worker to use?</a></li>
<li><a class="reference internal" href="#what-types-of-workers-are-there" id="id11">What types of workers are there?</a></li>
<li><a class="reference internal" href="#how-can-i-figure-out-the-best-number-of-worker-processes" id="id12">How can I figure out the best number of worker processes?</a></li>
<li><a class="reference internal" href="#how-can-i-change-the-number-of-workers-dynamically" id="id13">How can I change the number of workers dynamically?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#kernel-parameters" id="id14">Kernel Parameters</a><ul>
<li><a class="reference internal" href="#how-can-i-increase-the-maximum-number-of-file-descriptors" id="id15">How can I increase the maximum number of file descriptors?</a></li>
<li><a class="reference internal" href="#how-can-i-increase-the-maximum-socket-backlog" id="id16">How can I increase the maximum socket backlog?</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="footer">
<p>Site Content License <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.</p>
<p>Hosted on <a href="http://github.com/">GitHub</a></p>
</div>
</div>
</body>
</html>