fd-limits.xml revision 84ef01e0cc5691422370a55f218f43f425d99a9c
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<?xml version='1.0' encoding='UTF-8' ?>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<manualpage>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<relativepath href=".."/>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<parentdocument href="./">Virtual Hosts</parentdocument>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick <title>File Descriptor Limits</title>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<summary>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick <p>When using a large number of Virtual Hosts, Apache may run
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick out of available file descriptors (sometimes called <cite>file
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick handles</cite>) if each Virtual Host specifies different log
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick files. The total number of file descriptors used by Apache is
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick one for each distinct error log file, one for every other log
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick file directive, plus 10-20 for internal use. Unix operating
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick systems limit the number of file descriptors that may be used
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick by a process; the limit is typically 64, and may usually be
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick increased up to a large hard-limit.</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick <p>Although Apache attempts to increase the limit as required,
61a4b32b1032d530e84e1131cb803f803acf7461trawick this may not work if:</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick <ol>
61a4b32b1032d530e84e1131cb803f803acf7461trawick <li>Your system does not provide the <code>setrlimit()</code>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick system call.</li>
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>The <code>setrlimit(RLIMIT_NOFILE)</code> call does not
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick function on your system (such as Solaris 2.3)</li>
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick <li>The number of file descriptors required exceeds the hard
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick limit.</li>
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>Your system imposes other limits on file descriptors,
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick such as a limit on stdio streams only using file descriptors
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick below 256. (Solaris 2)</li>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick </ol>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p>In the event of problems you can:</p>
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick <ul>
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick <li>Reduce the number of log files; don't specify log files
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick in the <directive type="section" module="core">VirtualHost</directive>
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick sections, but only log to the main log files. (See <a
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick href="#splitlogs">Splitting up your log files</a>, below, for more
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick information on doing this.)</li>
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <li>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick If you system falls into 1 or 2 (above), then increase the
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick file descriptor limit before starting Apache, using a
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick script like
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <example>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <code>#!/bin/sh<br />
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick ulimit -S -n 100<br />
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick exec httpd</code>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick </example>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick </li>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick </ul>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p>Please see the <a
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick href="/misc/descriptors.html">Descriptors and Apache</a>
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick document containing further details about file descriptor
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick problems and how they can be solved on your operating
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick system.</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick
798cfee8074b529042079c77eee6962a723350detrawick</summary>
798cfee8074b529042079c77eee6962a723350detrawick
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick<section id="splitlogs"><title>Splitting up your log files</title>
798cfee8074b529042079c77eee6962a723350detrawick
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<p>If you want to log multiple virtual hosts to the same log file, you
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawickmay want to split up the log files afterwards in order to run
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawickstatistical analysis of the various virtual hosts. This can be
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawickaccomplished in the following manner.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<p>First, you will need to add the virtual host information to the log
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawickentries. This can be done using the <directive module="mod_log_config">
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawickLogFormat</directive>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawickdirective, and the <code>%v</code> variable. Add this to the beginning
61a4b32b1032d530e84e1131cb803f803acf7461trawickof your log format string:</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick<example>
61a4b32b1032d530e84e1131cb803f803acf7461trawickLogFormat "%v %h %l %u %t \"%r\" %&gt;s %b" vhost<br />
61a4b32b1032d530e84e1131cb803f803acf7461trawickCustomLog logs/multiple_vhost_log vhost
61a4b32b1032d530e84e1131cb803f803acf7461trawick</example>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick<p>This will create a log file in the common log format, but with the
61a4b32b1032d530e84e1131cb803f803acf7461trawickcanonical virtual host (whatever appears in the
61a4b32b1032d530e84e1131cb803f803acf7461trawick<directive module="core">ServerName</directive> directive) prepended to
61a4b32b1032d530e84e1131cb803f803acf7461trawickeach line. (See <directive
61a4b32b1032d530e84e1131cb803f803acf7461trawickmodule="mod_log_config">Custom Log Formats</directive> for
61a4b32b1032d530e84e1131cb803f803acf7461trawickmore about customizing your log files.)</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick<p>When you wish to split your log file into its component parts (one
61a4b32b1032d530e84e1131cb803f803acf7461trawickfile per virtual host) you can use the program <code><a
61a4b32b1032d530e84e1131cb803f803acf7461trawickhref="/programs/other.html">split-logfile</a></code> to accomplish
61a4b32b1032d530e84e1131cb803f803acf7461trawickthis. You'll find this program in the <code>support</code> directory
61a4b32b1032d530e84e1131cb803f803acf7461trawickof the Apache disribution.</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick<p>Run this program with the command:</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick<example>
61a4b32b1032d530e84e1131cb803f803acf7461trawicksplit-logfile &lt; /logs/multiple_vhost_log
61a4b32b1032d530e84e1131cb803f803acf7461trawick</example>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick<p>This program, when run with the name of your vhost log file, will
61a4b32b1032d530e84e1131cb803f803acf7461trawickgenerate one file for each virtual host that appears in your log file.
61a4b32b1032d530e84e1131cb803f803acf7461trawickEach file will be called <code>hostname.log</code>.</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick</section>
61a4b32b1032d530e84e1131cb803f803acf7461trawick</manualpage>
61a4b32b1032d530e84e1131cb803f803acf7461trawick
61a4b32b1032d530e84e1131cb803f803acf7461trawick