Webmaster tips » Apache

Jan 24, 2007
Nick Krotov

Are You Ready for High Volume Traffic?

Average rating:
  • 3.4 out of 5 Stars
Rate this article

Many webmasters wish they got a lot of traffic to their site. A day may come and their website may be very popular in just one day. This could be a reason that unique article is published on their site, or just a simple change in search position results in major search engines. So you get a lot of traffic, but is your server ready for this? Pages may take seconds to load and many visitors may think that the site is not available right now and go somewhere else.

Today we will talk about Linux and apache tips and tricks that will help webmaster to tune their dedicated server to handle high traffic.

How to see that you get a lot of traffic? Check log files, or check traffic rating at alexa.

How to see that your server is not capable of handling it? Use uptime command or top command. load average: 0.31, 0.46, 0.33 line is to search for. The first number shows current load (1 min average), second and third number show 5 and 15 min load average. If your 5-15 server load average is higher than 10 you have to worry about items discussed below.

Apache configuration

httpd.conf is a file file, usually located at /usr/local/apache/conf/httpd.conf path containing configuration settings for apache server. Cannot find the location of the file? Use locate command: >cd / then >locate httpd.conf

Main parameters to tune are:

  • MaxClients - sets the limit on the number of simultaneous requests that can be supported. Never set this number to high. Setting MaxClients parameter to a big number will lead to consumption of all available memory on your server and a hard disk swapping may occur. In other words the server will try to use hard disk space as additional memory, which is a very-very slow process. How to detect this? Use top command. Typical output of a swap command is shown below. Swap “41852k used” and Mem “624148k used” are two lines to look at. It memory size is approaching to total and swap used is growing then you are in trouble. Check MaxClients parameter. How to find what is the maximum that I can set? Calculate the average of your httpd process, divide total available memory by the average leaving some for the system. E.g. in case of 1 Gig RAM and average httpd process size 7MB on this server it is safe to set it to 100. What to set it to a larger value? Add more physical RAM.
    top - 01:04:08 up 4 days, 2:19, 1 user, load average: 0.31, 0.46, 0.33

    Tasks: 129 total, 1 running, 128 sleeping, 0 stopped, 0 zombie

    Cpu(s): 5.0% us, 1.3% sy, 0.3% ni, 87.4% id, 5.6% wa, 0.3% hi, 0.0% si

    Mem: 1027668k total, 624148k used, 403520k free, 10300k buffers

    Swap: 2048276k total, 41852k used, 2006424k free, 446804k cached

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

    15856 nobody 15 0 47532 7180 3532 S 3.3 0.7 0:00.17 httpd

    16097 nobody 15 0 46736 6036 3212 S 1.3 0.6 0:00.06 httpd

  • KeepAlive - allows multiple requests to be sent over the same TCP/IP connection. Turning it on can greatly improve the speed of your server, particularly when you have static pages and are serving quite a bit of images from your server. An example would be a catalogue site with screenshots. From my experience it is best to keep it On
  • KeepAliveTimeout – sets the number of seconds that the child httpd process sits and takes memory. From my experience it is best to set it to minimum, 1-3 seconds.
  • MaxRequestsPerChild – sets how many requests to serve per new httpd child process. You may set it very low, thus constantly freeing the memory, however on a particular case values like 15 or 20 may work well. As an example our site Filesland.com showing 10 images per page has this parameter set to 15.

After you change settings in httpd.conf do not forget to restart apache. You may do this from control panel or from command line > service httpd restart

Print! Print this article   Bookmark:

About The Author
Nick is a webmaster for Filesland.com
Rate This Article
How would you rate the quality of this content? Currently rated: 3.4 out of 5 stars. 7 people have rated this article.
Use your mouse pointer to select as many stars as you want, and press the left mouse button to vote.
  • 3.4 out of 5 Stars
  • 1
  • 2
  • 3
  • 4
  • 5
Other Apache Articles
Rating: 5 stars
Mod_Rewrite For Newbies by Bobby Handzhiev (Jan 24, 2007)
This article is not a complete guide to Apache's mod_rewrite neither to .htaccess. Its purpose is to help you - the webmaster - to create "mod_rewritten" versions of your dynamic webpages even if you have limited technical knowledge...
Rating: 4 stars
Apache htaccess for PHP web application deployment by Nathan C. Dickerson (Jul 28, 2006)
The following is a brief introduction to Apache's htaccess file for web application deployment, distribution, or implementation on shared hosting environments. The Apache htaccess file is not new; however it seems to only be used by more advanced Apache users and web application developers...
Rating: 4.2 stars
6 Tips To Secure Your Website by David Risley (Jul 2, 2006)
Most people on the internet are good, honest people. However, there are some people browsing the internet who derive fun from poking around websites and finding security holes. A few simple tips can help you secure your website in the basic ways...
Rating: 4.5 stars
301 Redirect - The SEO way to rename or move files or folders by Andrei Smith (Jan 18, 2006)
In this article I will discuss page redirection techniques, what works and what to avoid. What is page redirection and why would you want to use it? Let's say you rename a page on your website, for whatever reason...
Rating: 5 stars
Creating Custom Error Pages with .htaccess by Eric Reif (Jan 13, 2006)
Have you ever noticed that some people have really nice error pages when a page doesn't exist on their site? Wouldn't it be nice if you could make your error page match the rest of your site? Don't fret; you can do it! All you'll need to do is use a handly little file called ...