Re: Apache 2.x configuration for high load servers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 On May 25, 2011 10:27 , Rob Morin <rob@xxxxxxxxxxxx> wrote:
We have recently had a 30% increase in traffic and will be expecting more. I would like to know the correct way to calculate the proper settings for prefork.c my settings, here is what I have now...

I am going to add more RAM today to make a total of 24 gigs on each server, and i am going to add an additional web server in the next week or so...

Each day we get about 5 million visits...


The settings you use for the prefork MPM are not determined by how many visits you get per day, but by how many concurrent requests the server in question needs to handle during your busiest periods. Number of concurrent requests is in turn determined by how quickly requests come in together with how long it takes to serve (process, respond to, handle) each request.

For example, let's say that 90% of the requests you serve require 1 second to serve, but 10% of the requests take 5 seconds to serve. Let's also assume that during your busiest period you are getting 100 requests per second. In each second, then, 100 children will be needed to server these requests -- 90 of these children will finish (and become available to serve another request) after 1 second and the remainder will become available again after 5 seconds. This means that after 5 seconds of your busiest anticipated load, 140 children will be tied up serving requests, and hence you'd want to set ServerLimit comfortably above this value (to allow margin for error and future growth), assuming that you have the necessary hardware resources (RAM, processor cores) to effectively do so. In addition, you may want to set MinSpareServers high enough to handle a spike in load equivalent to one second's worth of requests, and set MaxSpareServers to free up resources if more than the number of children required to server two seconds worth of requests are sitting idle.

Access logs with a custom log format containing %D (time required to serve the request in microseconds) are your best tool for figuring out the request patterns that your web server needs to be able to handle. Also, mod_status is a useful tool for seeing what each child process is doing at single point in time (which children are serving requests, which children are idle, and so on).


Apache is currently using 6207 Megs of memory...

There are 245 Apache processes running at this time.

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

So the load is high, but i have free RAM left and only running 245 Apache processes, out of a possible 600? I only show the first few lines of top ….


This is anticipated. Apache HTTP Server's prefork MPM will try to keep the number spare processes (children that are idle and waiting for new requests) between MinSpareServers and MaxSpareServers at all times.

The rule of thumb I recommend is that you want your system load to be less than twice the number of processor cores. Other people's advice may differ from this, so I recommend that you ask around.

If your system load is more than twice the number of processor cores, I recommend:

- Determine if there is any storage (disk, etc.) I/O bottleneck; if so, eliminate it. - Determine if there is any network I/O bottleneck (network link, load balancer, firewall, etc.); if so, eliminate it.
- Reduce the time required to serve each requests:
-- Reduce time required by any web applications run by the web server (active content) -- Reduce time required by the web server itself (web server configuration, operating system configuration)

The above recommendations may result in you adding more I/O capacity, more RAM, more processor cores, and/or more machines to your web server cluster. However, I believe it is generally better to only add more resources once you have determined that all existing resources are being used as optimally as possible: improve any web applictions or other active content on your web site so that they require less resources; change your infrastructure architecture (what each web server does and how it does it including caching and proxying); and improve the configuration or your web server (and other servers, including any database servers) and your operating system.


Or do I get this wrong, does each connection have an httpd process that is run, or are child/subsequent connections, not listed on under a ps ax??


If you are using the prefork MPM, a number of child processes get created to handle web server requests (connections). The number of these will vary dynamically based on how you configure the prefork MPM and also on how many requests come in how quickly. All of the processes will show up under ps.


I removed access logging, I disable access logging by commenting out the CustomLog directive in each virtualhost and then in httpd.com I set CustomLog value to /dev/null, this way I can keep error working too… is this ok? Here aer some of the httpd.con entries…


Are you sure that you want to not log web server accesses? This removes an incredibly important diagnostic tool. Also note that if you use CustomLog with a file of /dev/null, then you are having Apache HTTP Server actually create each log entry and send it to the kernel, which will then discard it instead of writing it to disk; if you really want to turn off access logging, then it would be better to completely remove any CustomLog or TransferLog directives from your web server configuration.

If you want to improve performance, see the recommendations at http://httpd.apache.org/docs/2.2/misc/perf-tuning.html


Here are loaded modules, I am not sure if I need them all, can I safely turn any off?

You can and should turn off any modules you are not using; this will save some memory and may make your web server a little more secure. You will need to look at what functionality your web site currently relies upon, together with your web server configuration, in order to determine which modules you can avoid loading.

--
  Mark Montague
  mark@xxxxxxxxxxx


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux