<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="en-us" /> <meta name="ROBOTS" content="ALL" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="Keywords" content="cherokee web server httpd http" /> <meta name="Description" content="Cherokee is a flexible, very fast, lightweight Web server. It is implemented entirely in C, and has no dependencies beyond a standard C library. It is embeddable and extensible with plug-ins. It supports on-the-fly configuration by reading files or strings, TLS/SSL (via GNUTLS or OpenSSL), virtual hosts, authentication, cache friendly features, PHP, custom error management, and much more." /> <link href="media/css/cherokee_doc.css" rel="stylesheet" type="text/css" media="all" /> </head> <body> <h2 id="_a_href_index_html_index_a_8594_a_href_cookbook_html_cookbook_a"><a href="index.html">Index</a> → <a href="cookbook.html">Cookbook</a></h2> <div class="sectionbody"> </div> <h2 id="_cookbook_optimizing_cherokee">Cookbook: Optimizing Cherokee</h2> <div class="sectionbody"> <div class="paragraph"><p>Cherokee’s default parameters are suitable for most cases. However, there are a number of things that can be tweaked in order to improve the behavior of Cherokee under special circumstances.</p></div> <h3 id="compiled">Compiled capabilities</h3><div style="clear:left"></div> <div class="paragraph"><p>First of all you should check the capabilities that have been built into your specific Cherokee build. This can be done by:</p></div> <div class="listingblock"> <div class="content"> <pre><tt>$ cherokee -i Compilation Version: 1.0.0 [...] Support IPv6: yes Pthreads: yes Tracing: yes sendfile(): yes syslog(): yes Polling methods: select poll epoll</tt></pre> </div></div> <div class="paragraph"><p>The last section is interesting. If you see that any significant capability supported by your platform is missing, you should really build another binary or check if something is wrong with your system. Note that not every single capability is present in every platform. For instance, <tt>epoll</tt> is a polling method specific to Linux platforms, and its absence from any non-Linux system is perfectly normal. It is inherently more efficient than the other methods available on Linux. For BSD based platforms <tt>kqueue</tt> is also a great improvement over the most standard <tt>poll</tt>. This is the standard POSIX conformant system call, and will only be available on systems that follow the POSIX standard. From the list above, the capabilities that have a dramatic impact in the speed of Cherokee are the polling methods, the existence of sendfile() and the Pthreads support.</p></div> <h3 id="tweaks">Tweaks</h3><div style="clear:left"></div> <div class="paragraph"><p>There is no general recommendation that is the best for everybody. In general Cherokee’s default values try to offer a good compromise between resources and performance, but for specific cases you will be able to tweak somethings that may (or may not) improve the overall performance. Some of the things to keep in mind are mentioned here.</p></div> <div class="dlist"><dl> <dt class="hdlist1"> Encoding </dt> <dd> <p> As it is explained in the <a href="modules_encoders.html">Encoders'</a> documentation, compressing the information to be sent makes a lot of sense for specific file types. It’s Not that much processing power is used to compress a text file, for instance, and hardware is cheaper than bandwidth, so you should encode files whenever it makes sense. </p> </dd> <dt class="hdlist1"> Handler specific </dt> <dd> <div class="ulist"><ul> <li> <p> <strong>CGI, SCGI, FastCGI</strong>: <a href="other_goodies.html#x-sendfile">X-Sendfile</a> support can be enabled or disabled. If you know what this is, you will know how X-Sendfile improves performance by assigning the task of serving files to the web server while leaving the backend application to run free without waiting for the task to end. This gives you extra performance at no cost, but of course your application must specifically make use of this feature. </p> </li> <li> <p> <strong>Static Content</strong>: IO cache is a caching mechanism that dramatically improves performance serving files. The caching algorithm is very efficient and assures that a file will be immediately served while it remains cached. The usage of IO cache is absolutely recommended in all cases except when the contents of the files are changed frequently. Note that the global <em>IO Cache</em> setting from the <em>Advanced</em> section (see bellow) must be enabled for each individual handler’s setting to be taken into account. </p> </li> </ul></div> </dd> <dt class="hdlist1"> General </dt> <dd> <div class="ulist"><ul> <li> <p> <strong>Timeout</strong>: The lower your timeout interval is, the faster you will free up resources at the cost of cancelling viable but slow connections. </p> </li> <li> <p> <strong>Keep alive</strong>: This setting dramatically affects the speed at which repeated connections are served to the same client. This is especially noticeable when an asynchronous application is used. The trade off is that, since connections are kept open more time, less connections remain available for other clients in any given moment. Cherokee does a pretty good job at reclaiming unused open connections, especially when the number of connections approaches the limit imposed to the system, but any way you should keep in mind this. </p> </li> </ul></div> </dd> <dt class="hdlist1"> Advanced </dt> <dd> <div class="ulist"><ul> <li> <p> <strong>Threads</strong>: The default value is chosen so that it is more than enough to saturate the processors. You will probably not get much out of this setting, since a higher value will not produce better results and a lower one will simply increase the amount of unused processor power. </p> </li> <li> <p> <strong>File descriptors</strong>: By definition, the higher this limit is, the less efficient will your system be in relative terms. However, it is understood that if you are tweaking this value is because you need to, that is, you have a very high load site. In these cases increasing the file descriptors' limit makes sense because the higher this limit is, the more connections Cherokee will be able to handle. By default Cherokee does not touch this value and it uses the one specified by your system. </p> </li> <li> <p> <strong>IO Cache</strong>: This setting allows to enable or disable server-wide the content caching. If disabled, the <em>IO Cache</em> settings of the static content handlers will also be disabled, no matter what behavior is desired in their specific configuration. This global setting is essential if you are trying to debug a cache-related bug in your server’s configuration. </p> </li> </ul></div> </dd> </dl></div> <h3 id="trace">Debug: Disable TRACE</h3><div style="clear:left"></div> <div class="paragraph"><p>When compiled with debugging support, Cherokee’s performance is heavily penalized. Being able to trace the state of the web server at a very low level is quite useful when you have to fine tune your infrastructure, but once it is done you should disable this feature. A production environment deserves only the finest tuned binaries.</p></div> </div> <div id="footer"> <div id="footer-text"> </div> </div> </body> </html>