fd-limits.html.en revision 84ef01e0cc5691422370a55f218f43f425d99a9c
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive This file is generated from xml source: DO NOT EDIT
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
b686b6a420bde7f78c416b90be11db94cb789979nd --><title>File Descriptor Limits - Apache HTTP Server</title><link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /><link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /><link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link href="/images/favicon.ico" rel="shortcut icon" /></head><body id="manual-page"><div id="page-header"><p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p><p class="apache">Apache HTTP Server Version 2.0</p><img alt="" src="/images/feather.gif" /></div><div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div><div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.0</a> > <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>File Descriptor Limits</h1>
b686b6a420bde7f78c416b90be11db94cb789979nd <p>When using a large number of Virtual Hosts, Apache may run
b686b6a420bde7f78c416b90be11db94cb789979nd out of available file descriptors (sometimes called <cite>file
b686b6a420bde7f78c416b90be11db94cb789979nd handles</cite>) if each Virtual Host specifies different log
b686b6a420bde7f78c416b90be11db94cb789979nd files. The total number of file descriptors used by Apache is
b686b6a420bde7f78c416b90be11db94cb789979nd one for each distinct error log file, one for every other log
b686b6a420bde7f78c416b90be11db94cb789979nd file directive, plus 10-20 for internal use. Unix operating
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz systems limit the number of file descriptors that may be used
b686b6a420bde7f78c416b90be11db94cb789979nd by a process; the limit is typically 64, and may usually be
b686b6a420bde7f78c416b90be11db94cb789979nd increased up to a large hard-limit.</p>
4b5981e276e93df97c34e4da05ca5cf8bbd937dand <p>Although Apache attempts to increase the limit as required,
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd this may not work if:</p>
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd <li>Your system does not provide the <code>setrlimit()</code>
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd system call.</li>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd <li>The <code>setrlimit(RLIMIT_NOFILE)</code> call does not
b686b6a420bde7f78c416b90be11db94cb789979nd function on your system (such as Solaris 2.3)</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>The number of file descriptors required exceeds the hard
06ba4a61654b3763ad65f52283832ebf058fdf1cslive limit.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>Your system imposes other limits on file descriptors,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive such as a limit on stdio streams only using file descriptors
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd below 256. (Solaris 2)</li>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <li>Reduce the number of log files; don't specify log files
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd in the <code class="directive"><a href="/mod/core.html#virtualhost"><VirtualHost></a></code>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd sections, but only log to the main log files. (See <a href="#splitlogs">Splitting up your log files</a>, below, for more
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd information on doing this.)</li>
5b10fd3977e6dfff19afe770e612e276962f7950nd If you system falls into 1 or 2 (above), then increase the
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd file descriptor limit before starting Apache, using a
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd script like
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd ulimit -S -n 100<br />
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna exec httpd</code>
2aff288113d772cedca6add888eb643afffe9fb1nd <p>Please see the <a href="/misc/descriptors.html">Descriptors and Apache</a>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd document containing further details about file descriptor
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd problems and how they can be solved on your operating
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd system.</p>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div><div class="section"><h2><a name="splitlogs" id="splitlogs">Splitting up your log files</a></h2>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd<p>If you want to log multiple virtual hosts to the same log file, you
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2ndmay want to split up the log files afterwards in order to run
2aff288113d772cedca6add888eb643afffe9fb1ndstatistical analysis of the various virtual hosts. This can be
2aff288113d772cedca6add888eb643afffe9fb1ndaccomplished in the following manner.</p>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<p>First, you will need to add the virtual host information to the log
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndentries. This can be done using the <code class="directive"><a href="/mod/mod_log_config.html# logformat">
7ec4d5cc4aa574e3191bc5a612e68fd8f25ab7earpluemdirective, and the <code>%v</code> variable. Add this to the beginning
7ec4d5cc4aa574e3191bc5a612e68fd8f25ab7earpluemof your log format string:</p>
2aff288113d772cedca6add888eb643afffe9fb1ndLogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost<br />
2aff288113d772cedca6add888eb643afffe9fb1nd<p>This will create a log file in the common log format, but with the
2aff288113d772cedca6add888eb643afffe9fb1ndcanonical virtual host (whatever appears in the
635e08c1d8332adc365b1c20bbe3577d59ebcd78kess<code class="directive"><a href="/mod/core.html#servername">ServerName</a></code> directive) prepended to
2aff288113d772cedca6add888eb643afffe9fb1ndeach line. (See <code class="directive"><a href="/mod/mod_log_config.html#custom log formats">Custom Log Formats</a></code> for
2aff288113d772cedca6add888eb643afffe9fb1ndmore about customizing your log files.)</p>
909ce17e2bd0faef7b1c294f2307f009793fd493nd<p>When you wish to split your log file into its component parts (one
2aff288113d772cedca6add888eb643afffe9fb1ndfile per virtual host) you can use the program <code><a href="/programs/other.html">split-logfile</a></code> to accomplish
aa0b2780958e9b1467c9d0153a05738e399811a5ndthis. You'll find this program in the <code>support</code> directory
2aff288113d772cedca6add888eb643afffe9fb1ndof the Apache disribution.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd<p>This program, when run with the name of your vhost log file, will
2aff288113d772cedca6add888eb643afffe9fb1ndgenerate one file for each virtual host that appears in your log file.
2aff288113d772cedca6add888eb643afffe9fb1nd</div></div><div id="footer"><p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p><p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div></body></html>