httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Httpd Wiki] Update of "PerformanceScalingUp" by jmcg
Date Thu, 18 Nov 2010 02:56:13 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.

The "PerformanceScalingUp" page has been changed by jmcg.
The comment on this change is: Fixing more typos. Correcting some more Solaris and FreeBSD
un-facts. Reference to the yet non-existent. scaling out document. Disable ETags..
http://wiki.apache.org/httpd/PerformanceScalingUp?action=diff&rev1=5&rev2=6

--------------------------------------------------

  running, its own process is usually in the top ten CPU gluttons). It is indispensable
  in determining the size of a running process, which comes in handy
  when determining how many server processes you can run on your machine.
- How to do this is described in Section 3.1.3. Top is, however, an interactive tool
+ How to do this is described in '[[#Sizing_MaxClients|sizing MaxClients]]'. Top is, however,
an interactive tool
  and running it continuously has few if any advantages.
  
  === free ===
@@ -115, +115 @@

  space is in use. Linux allocates unused memory as file system cache. The free
  command shows usage both with and without this cache. The free command
  can be used to find out how much memory the operating system is using, as
- described in the paragraph ‘Sizing MaxClients’. The output of free
+ described in the paragraph '[[#Sizing_MaxClients|Sizing MaxClients]]'. The output of free
  looks like this:
  
  {{{
@@ -130, +130 @@

  This command is available on many unix platforms. It displays a large number
  of operating system metrics. Run without argument, it displays a status line for
  that moment. When a numeric argument is added, the status is redisplayed at
- designated intervals. For example, vmstat 5 causes the information to reappear
+ designated intervals. For example, `vmstat 5` causes the information to reappear
  every five seconds. Vmstat displays the amount of virtual memory in use, how
  much memory is swapped in and out each second, the number of processes
  currently running and sleeping, the number of interrupts and context switches
  per second and the usage percentages of the CPU.
  
- The following is vmstat output of an idle server:
+ The following is `vmstat` output of an idle server:
  
  {{{
  [sctemme@GayDeceiver sctemme]$ vmstat 5 3
@@ -192, +192 @@

  processes running and how many bytes each has served, and the CPU load
  caused by httpd and the rest of the system. The Apache Software Foundation
  uses mod status on its own [[http://apache.org/server-status|web site]].
- If you put the ExtendedStatus On directive
+ If you put the `ExtendedStatus On` directive
- in your httpd.conf, the mod status page will give you more information at
+ in your `httpd.conf`, the `mod_status` page will give you more information at
  the cost of a little extra work per request.
  
  == Web Server Log Files ==
@@ -219, +219 @@

  stream. If you start httpd manually, this error information will appear on your
  terminal and you can use it directly to troubleshoot your server. If your httpd
  is started by a startup script, the destination of early error messages depends
- on their design. The /var/log/messages file is usually a good bet. On Windows,
+ on their design. The `/var/log/messages` file is usually a good bet. On Windows,
  early error messages are written to the Applications Event Log, which can be
  viewed through the Event Viewer in Administrative Tools.
  
@@ -254, +254 @@

  
  The default log level is warn. A production server should not be run on
  debug, but increasing the level of detail in the error log can be useful
- during troubleshooting. Startint 2.3.8 LogLevel can be specified on a
+ during troubleshooting. Starting with 2.3.8 `LogLevel` can be specified on a
  per module basis:
  {{{
  LogLevel debug mod_ssl:warn
  }}}
- This puts all of the server in debug mode, except for `mod_ssl`, which we
+ This puts all of the server in debug mode, except for `mod_ssl`, which
  tends to be very noisy.
  
  === Access Log ===
@@ -331, +331 @@

  A second approach is to use piped logs. From the `CustomLog`, `TransferLog`
  or `ErrorLog` directives you can send the log data into any program using a pipe
  character (`|`). For instance:
- 
  {{{
  CustomLog "|/usr/local/apache2/bin/rotatelogs /var/log/access_log 86400" common
  }}}
- 
  The program on the other end of the pipe will receive the Apache log data on
  its stdin stream, and can do with this data whatever it wants. The rotatelogs
  program that comes with Apache seamlessly turns over the log file based on
@@ -352, +350 @@

  a read operation in a fairly random pattern, and log files are written to disk
  sequentially.
  
- Do not run a production server with your error LogLevel set to debug. This
+ Do not run a production server with your error `LogLevel` set to debug. This
  log level causes a vast amount of information to be written to the error log,
  including, in the case of SSL access, complete dumps of BIO read and write
  operations. The performance implications are significant: use the default warn
@@ -369, +367 @@

  
  You can use the `BufferedLogs` directive to have Apache collect several log
  lines in memory before writing them to disk. This might yield better performance,
- but could affect the order in which the server’s log is written.
+ but could affect the order in which the server's log is written.
  
  == Generating A Test Load ==
  It is useful to generate a test load to monitor system performance under realistic
@@ -411, +409 @@

  the same pre-forking process model that Apache 1.3 uses. The Worker MPM
  runs a smaller number of child processes, and spawns multiple request handling
  threads within each child process. In 2.3+ MPMs are no longer hard-wired.
- They too can be exchanged via LoadModule. The default MPM in 2.3 is the event mpm.
+ They too can be exchanged via LoadModule. The default MPM in 2.3 is the event MPM.
  
  The maximum number of workers, be they pre-forked child processes or
  threads within a process, is an indication of how many requests your server
@@ -422, +420 @@

  backing up, system performance is likely to degrade.
  
  === MaxClients ===
- The MaxClients directive in your Apache httpd configuration file specifies the
+ The `MaxClients` directive in your Apache httpd configuration file specifies the
  maximum number of workers your server can create. It has two related directives,
  `MinSpareServers` and `MaxSpareServers`, which specify the number of
  workers Apache keeps waiting in the wings ready to serve requests. The absolute
@@ -443, +441 @@

  memory on your system is used, but no more. If your system gets so overloaded
  that it needs to heavily swap core memory out to disk, performance will degrade
  quickly. The formula for determining `MaxClients` is fairly simple:
- 
  {{{
                total RAM − RAM f or OS − RAM f or external programs
- MaxClients = ---------------------------------------------------------
+ MaxClients = -------------------------------------------------------
                              RAM per httpd process
  }}}
- 
  The various amounts of memory allocated for the OS, external programs
  and the httpd processes is best determined by observation: use the top and
  free commands described above to determine the memory footprint of the OS
@@ -493, +489 @@

  that process disappear, which means all the clients currently being served by
  that process will see their connection aborted. Additionally, there may be so-called
  "thread-safety" issues, especially with third-party libraries. In threaded
- applications, threads may access the same variables indiscriminantly, not knowing
+ applications, threads may access the same variables indiscriminately, not knowing
  whether a variable may have been changed by another thread.
  
  This has been a sore point within the PHP community. The PHP processor
@@ -503, +499 @@

  relative to the threaded option.
  
  === Spinning Locks ===
- Apache maintains an inter-process lock around its network listener. For all
+ Apache httpd maintains an inter-process lock around its network listener. For all
  practical purposes, this means that only one httpd child process can receive
  a request at any given time. The other processes are either servicing requests
  already received or are 'camping out' on the lock, waiting for the network listener
@@ -568, +564 @@

  While the various platforms treat their virtual memory in different ways, it
  is never a good idea to run with less disk-based swap space than RAM. The
  virtual memory system is designed to provide a fallback for RAM, but when you
- don’t have disk space available and run out of swappable memory, your machine
+ don't have disk space available and run out of swappable memory, your machine
  grinds to a halt. This can crash your box, requiring a physical reboot for which
  your hosting facility may charge you.
  
@@ -581, +577 @@

  
  Most unix-like operating systems use designated disk partitions for swap
  space. When a system starts up it finds all swap partitions on the disk(s), by
- partition type or because they are listed in the file /etc/fstab, and automatically
+ partition type or because they are listed in the file `/etc/fstab`, and automatically
  enables them. When adding a disk or installing the operating system, be sure
- to allocate enough swap space to accomodate eventual RAM upgrades. Reassigning
+ to allocate enough swap space to accommodate eventual RAM upgrades. Reassigning
  disk space on a running system is a cumbersome process.
  
  Plan for available hard drive swap space of at least twice your amount of
  RAM, perhaps up to four times in situations with frequent peaking loads. Remember
  to adjust this configuration whenever you upgrade RAM on your system.
  In a pinch, you can use a regular file as swap space. For instructions
- on how to do this, see the manual pages for the mkswap and swapon or swap
+ on how to do this, see the manual pages for the `mkswap` and `swapon` or `swap`
  programs.
  
  === ulimit: Files and Processes ===
  Given a machine with plenty of RAM and processor capacity, you can run
- hundreds of Apache processes if necessary. . . and if your kernel allows it. The
+ hundreds of Apache processes if necessary. . . and if your kernel allows it.
- Linux 2.2 kernel series by default limited the number of processes a user can
- run to 256, which is a fairly small number in computational circles.
  
  Consider a situation in which several hundred web servers are running; if
  some of these need to spawn CGI processes, the maximum number of processes
@@ -605, +599 @@

  
  However, you can change this limit with the command
  {{{
- ulimit -u [newvalue]
+ ulimit [-H|-S] -u [newvalue]
  }}}
  This must be changed before starting the server, since the new value will
  only be available to the current shell and programs started from it. In newer
- Linux kernels the default has been raised to 2048. There does not seem to be
+ Linux kernels the default has been raised to 2048. On FreeBSD, the number seems
- a process limit on Solaris. On FreeBSD, the number seems to be the rather
- unusual 513. Since the default user shell on this system is csh and ulimit is a
- built-in command in Bourne-like shells, you need to start a Bourne shell or bash
- to see and set this value, and then start the web server from this shell.
- 
+ to be the rather unusual 513. In the default user shell on this system, `csh` the
+ equivalent is `limit` and works analogous the the Bourne-like `ulimit`:
+ {{{
+ limit [-h] maxproc [newvalue]
+ }}}
  Similarly, the kernel may limit the number of open files per process. This is
  generally not a problem for pre-forked servers, which just handle one request at
  a time per process. Threaded servers, however, serve many requests per process
@@ -634, +628 @@

  {{{
  session required /lib/security/pam_limits.so
  }}}
- All items can have a ‘soft’ and a ‘hard’ limit: the first is the default setting
+ All items can have a 'soft' and a 'hard' limit: the first is the default setting
  and the second the maximum value for that item.
+ 
+ In FreeBSD's `/etc/login.conf` these resources can be limited or extended system wide,
+ analogously to `limits.conf`. 'Soft' limits can be specified with `-cur` and 'hard'
+ limits with `-max`.
  
  Solaris has a similar mechanism for manipulating limit values at boot time:
  In `/etc/system` you can set kernel tunables valid for the entire system at
@@ -724, +722 @@

  distributions of Apache come with mod rewrite included. The following is an
  example of an Apache virtual host that takes advantage of pre-rendered blog
  pages:
- 
- The `RewriteCond` and `RewriteRule` directives say that, if the requested
- resource does not exist as a file or a directory, its path is passed to the Blosxom
- CGI for rendering. Blosxom uses Path Info to specify blog entries and index
- pages, so this means that if a particular path under Blosxom exists as a static
- file in the file system, the file is served instead. Any request that isn’t pre-
- rendered is served by the CGI. This means that individual entries, which show
- the comments, are always served by the CGI which in turn means that your
- comment spam is always visible. This configuration also hides the Blosxom CGI
- from the user-visible URL in their Location bar. Mod rewrite is a fantastically
- powerful and versatile module: investigate it to arrive at a configuration that is
- best for your situation.
- 
  {{{
  Listen *:8001
  <VirtualHost *:8001>
@@ -765, +750 @@

    </Directory>
  </VirtualHost>
  }}}
+ The `RewriteCond` and `RewriteRule` directives say that, if the requested
+ resource does not exist as a file or a directory, its path is passed to the Blosxom
+ CGI for rendering. Blosxom uses Path Info to specify blog entries and index
+ pages, so this means that if a particular path under Blosxom exists as a static
+ file in the file system, the file is served instead. Any request that isn't pre-
+ rendered is served by the CGI. This means that individual entries, which show
+ the comments, are always served by the CGI which in turn means that your
+ comment spam is always visible. This configuration also hides the Blosxom CGI
+ from the user-visible URL in their Location bar. Mod rewrite is a fantastically
+ powerful and versatile module: investigate it to arrive at a configuration that is
+ best for your situation.
  
  == Caching Content With mod cache ==
  The mod cache module provides
@@ -805, +801 @@

  were patched to send the proper HTTP response headers. After this modification,
  the cache in front of the Wiki was enabled with the following configuration
  snippet in `httpd.conf`:
- 
  {{{
  CacheRoot /raid1/cacheroot
  CacheEnable disk /
@@ -814, +809 @@

  # Always check again after 6 hours
  CacheMaxExpire 21600
  }}}
- 
- 
  This configuration will try to cache any and all content within its virtual
  host. It will never cache content for more than six hours (the `CacheMaxExpire`
  directive). If no `Expires:` header is present in the response, mod_cache will
  compute an expiration period from the `Last-Modified:` header. The computation
  using `CacheLastModifiedFactor` is based on the assumption that if a
  page was recently modified, it is likely to change again in the near future and
+ will have to be re-cached.
- will have to be re-cached. Please see the mod_cache documentation for more
- information on using this module.
  
+ Do note that it can pay off to ''disable'' the `ETag:` header: For files smaller
+ than 1k the server has to calculate the checksum (usually MD5) and then send out
+ a `304 Not Modified` response, which will take waste some CPU and still saturate
+ the same amount of network resources for the transfer (one TCP packet).
+ For resources larger than 1k it might prove CPU expensive to calculate the header
+ for each request. Unfortunately there does currently not exist a way to cache these
+ headers.
+ {{{
+ <FilesMatch \.(jpe?g|png|gif|js|css|x?html|xml)>
+   FilesETag None
+ </FilesMatch>
+ }}}
+ This will disable the generation of the `ETag:` header for most static resources.
+ The server does not calculate these headers for dynamic resources.
+ 
+ = Further Considerations =
+ Armed with the knowledge of how to tune a sytem to deliver the desired the
+ performance, we will soon discover that ''one'' system might prove a bottleneck.
+ How to make a system fit for growth, or how to put a number of systems into
+ tune will be discussed in PerformanceScalingOut.
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Mime
View raw message