Apache2 tweaking tips?

Discussion in 'Server Operation' started by edge, Dec 23, 2006.

  1. edge

    edge Active Member Moderator

    Yesterday (and today also) one of my Apache2 servers was/is having a real hard time.
    Problem is that the site(s) on port 80 get really slow!

    Yesterday it had arround 15572 visitors, and today it's allready at 10182 (8 more hours to go for today)
    This is only a count for the problem site. The other sites are all low profile.

    Only the Apache2 server (on port 80) is slow. SMTP, FTP, SSH and even the Apache on https, port 81 (ISPconfig) and Webmin on https, port 10000 are still fast, so it's not a hardware problem.
    Top does also not show a high CPU use on any process!

    The "problem" site does NOT make use of any fancy PHP stuff, and does not make use of a MySQL, or .htaccess

    So.. I'm 99% sure that it's the Apache2 server!
    Is there an easy way to see what parts need tweaking in the Apache2 config file?
    Last edited: Dec 23, 2006
  2. edge

    edge Active Member Moderator

    Okay.. update..

    The page did make some use of "fancy" stuff..
    It's using a small loging script that is calling "power phlogger" (from phpee.com)

    phlogger is also running on that server, so I guess (1) PHP could not handle phlogger, or (2) MySQL could not handle the amount of data.
    (MySQL is also on that server)

    Anyway.. After removing the "call to phlogger" from the trouble site, the problem is gone. (To make sure that this was the problem, I added the "call to phlogger" again some time later, and the problem was back again.)

    Now I need to see if the problem is the PHP or the MySQL..
  3. edge

    edge Active Member Moderator

    Update 2

    Guess what.. The problem came back again.. Even with the "phlogger" off :(

    I've now set the MaxClients** in the "/etc/apache2/apache2.conf" a bit higher

    **There is two times a MaxClients.
    The 1st one was set to 20, and is now set to 40
    The 2nd one was set to 150 and is now set to 256

    So far so good..
  4. falko

    falko Super Moderator ISPConfig Developer

    Do you use eAccelerator or some other PHP cache? That should lower the load of your server a lot.
    Also, did you take a look here? http://www.howtoforge.com/configuring_apache_for_maximum_performance

    For HowtoForge, we use the following settings for Apache:

    MaxKeepAliveRequests 100000
    KeepAliveTimeout 4
    <IfModule prefork.c>
    ServerLimit            500
    StartServers             5
    MinSpareServers          5
    MaxSpareServers         15
    MaxClients             500
    MaxRequestsPerChild  100000
  5. edge

    edge Active Member Moderator

    The page is not using PHP, but it is using Coldfusion (however this it not the problem)

    Apache2 is having problems with the (at the moment) 40 connections per second!


    I've had a look at the howto, and did all the changesm but it's still having a hard time..
  6. edge

    edge Active Member Moderator

    So how do you calculate the MaxClients?

    I found the following on the web, but have no clue how to get the "MSRPC".

    My TotalRam in the server is 2GB
    The CPU (2x) in that server are PIII 1.13GHz (I guess that this is the MaxProcessSize)

    Is there a way to see the MSRPC (Minimal Shared RAM per Child)?
  7. Hans

    Hans Moderator ISPConfig Developer

  8. edge

    edge Active Member Moderator

    Thanks Hans,

    Traffic has gone down a bit (now doing +/- 20 connections per second).
    The server is handling this fine for now...
    Totall till now (from 09:00 till now 22:25) is 319,905 page views :/

    Data used:

    1st and 2nd row hour from/to
    3rd row data in
    4th row data out :/
    5th row data totall

    Last edited: Dec 24, 2006
  9. falko

    falko Super Moderator ISPConfig Developer

    You can run
    to get a feeling how much RAM your Apache children use.
  10. edge

    edge Active Member Moderator


    top is alsway confusing me..

    This is what I get when I ask top to show me only www-data.

    top - 13:13:57 up 9 days, 17:44,  1 user,  load average: 0.10, 0.17, 0.12
    Tasks: 292 total,   1 running, 291 sleeping,   0 stopped,   0 zombie
     Cpu0 :  1.2% us,  0.7% sy,  0.0% ni, 97.2% id,  0.0% wa,  0.2% hi,  0.7% si
     Cpu1 :  1.4% us,  0.7% sy,  0.0% ni, 97.0% id,  0.0% wa,  0.2% hi,  0.7% si
    Mem:   3636872k total,  2694140k used,   942732k free,    83472k buffers
    Swap:  2650684k total,        0k used,  2650684k free,  2206836k cached
     6547 www-data  16   0 24300  11m  19m S  0.2  0.3   0:00.08 apache2
    many more, but all with 0.3 for %MEM
    Is it the %MEM I should look at (0.3)?

    Also.. It's now nice and quite again on the server..

    Here are the stats from yesterday.
    Small note.. This server has got only ONE site with ONE page on it.
    (I have moved every other site that was running on that server temporarily to an other server the day before)
    The page views might look low, but the server was really having a hard time from 10:00 to 12:00. After this I "tweaked" the Apache2 server, and it did work a bit better..


    Total page views from 09:00 to 09:00 (24 hrs) 371,715
    Busiest time of the day was from 15:00 to 16:00 hrs with 74536 pages (that is about 1242 pages per minute)

    After "tweaking" Apache at 12:00 it worked nice the rest of the day

    The bandwidth used for that day was in 4.28 GB, and out 100.48 GB (again, this is only one site with one page and some flash on it)

    I think I'm okay now as the Christmas rush is over, but I would still like to get Apache2 setup correct (for the next time)
    Last edited: Dec 25, 2006
  11. falko

    falko Super Moderator ISPConfig Developer


    That's a lot. Maybe your site was hit by one or more bots? You could check the Apache logs to find out if the requests came always from the same IP address.
  12. edge

    edge Active Member Moderator

    No bot.. They are real users.. That site was featured on a big USA TV station *it's a "create your own flash Christmas greating card page"

    I was also running AdSense on it, and did good with the $$$$ :)
  13. falko

    falko Super Moderator ISPConfig Developer

    That's good! :) Congratulations.

Share This Page