2

Sorry to ask a question like this if its too superficial for you. Considering the information below, how would you configure httpd.conf?

The load time of pages reaches to 30 seconds when the server busy.

Server:

Quad-Xeon 3220 / 8GB memory / 2x250GB SATAII / 10TB BW / 1GiGE / 8 IPS (SoftLayer), CentOS 5 (64-bit) Plesk 9.5

Linux server.x.com 2.6.18-274.17.1.el5 #1 SMP Tue Jan 10 17:25:58 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

Sites on the server receive around 500,000 pageviews and 200GB a day on average. There are around 1500 visitors online when the server busy according to http://whos.amung.us/stats/.

top - 11:15:08 up 23 days, 12:21,  1 user,  load average: 0.30, 1.09, 1.84
Tasks: 453 total,   1 running, 452 sleeping,   0 stopped,   0 zombie
Cpu(s):  2.9%us,  2.8%sy,  0.0%ni, 90.3%id,  3.7%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:   8165772k total,  8065268k used,   100504k free,   348884k buffers
Swap:  1052248k total,      208k used,  1052040k free,  6466136k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                              
15573 mysql     15   0  601m  80m 4520 S 35.1  1.0   2026:37 mysqld                                                                                                               
19381 apache    15   0  307m  15m 3312 S  1.0  0.2   0:02.73 httpd                                                                                                                
13230 apache    15   0  307m  15m 3296 S  0.7  0.2   0:03.74 httpd                                                                                                                
14152 apache    15   0  307m  15m 3284 S  0.7  0.2   0:03.91 httpd                                                                                                                
16147 apache    15   0  307m  15m 3296 S  0.7  0.2   0:03.14 httpd                                                                                                                
16957 apache    15   0  307m  15m 3292 S  0.7  0.2   0:03.03 httpd               

httpd.conf file:

Timeout 60
KeepAlive On
MaxKeepAliveRequests 300
KeepAliveTimeout 5
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>
<IfModule worker.c>
StartServers         2
MaxClients         150
MinSpareThreads     25
MaxSpareThreads     75 
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>
6
  • 1
    What sort of content are you serving? e.g. static HTML, Perl, PHP, etc. Which MPM are you currently using in Apache? Feb 18, 2012 at 17:51
  • sites are similar to y8.com.I don't know actually, how can I learn?
    – nahha
    Feb 18, 2012 at 17:53
  • If you don't know what sort of sites you're running it's going to be very hard to help... Feb 18, 2012 at 17:56
  • What !? No! Sites are similar to y8.com. I was saying I don't know which MPM I am using. I just learned. It is prefork
    – nahha
    Feb 18, 2012 at 18:06
  • "Similar to y8.com" doesn't help in determining what kind of code is being served. Prefork isn't very efficient but if you're running PHP then it's all you can use. If you're not using PHP then you can switch to the worker MPM and use threaded mode. Feb 18, 2012 at 18:08

2 Answers 2

2

Things to consider:

  1. Your maximum number of online clients is ~1500
  2. The amount of memory each httpd process uses (about 300MB from your output) and the amount of memory your machine has.

It would be a good idea to thoroughly examine your httpd.conf and remove any unnecessary modules to cut down your memory footprint. Once you've done that, you can start to raise MaxClients and ServerLimit gradually.

You'll want to raise StartServers, MinSpareServers and MaxSpareServers too, but again do this gradually and monitor memory usage and site performance for a while after each change.

Other things to consider would be to place something like Varnish in front of Apache or (as Fernando suggests) APC.

2

If possible, try to switch to another webserver like Nginx or Lighttpd. Apache is great but usually it doesn't handle busy websites well.

If you can't, no problem. Here are some tips that can help you:

1. Disable logs

If your application doesn't depend on log files and you use Analytics or other service for stats you can disable logs. You will see I/O dropping because apache doesn't have to write every request on disk.

2. Are you using PHP? Opcode cache is mandatory!

I prefer APC because it's simple to install, stable and is going to be part of PHP soon. To install it simply run:

pecl install apc

Them add the following line to your php.ini:

extension="apc.so"

Restart your webserver and watch load going down.

3. Change to another MPM

Changing to worker or event MPM can help in some causes. It really depends on the type of files that you're serving. I saw cases where the load dropped after this and others were running as prefork or worker didn't made any considerable difference.

Note: you can break PHP if you change for worker and you're running it as a DSO module. Check this first.

2
  • Thanks so much!! However, I can't disable logs though I tried so hard as you can see: 1 2 3 4. Maybe you know how to disable logs?
    – nahha
    Feb 18, 2012 at 18:43
  • I'm not sure about how to do with Plesk ( in a way that updates won't break ). But you can try to replace all CustomLog with #CustomLog ( note # at the beginning ) and them restart Apache.
    – Fernando
    Feb 18, 2012 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .