Results 1 to 18 of 18
  1. #1

    Apache performance tuning

    Here is my httpd.conf setting for Linux Dual CPU 1000 MHz RAM 512 MHz

    MinSpareServers 100
    MaxSpareServers 200
    StartServers 100
    MaxClients 512
    MaxRequestsPerChild 15

    === top result ===

    9:50am up 11 days, 21:51, 1 user, load average: 0.19, 0.24, 0.26
    256 processes: 252 sleeping, 1 running, 3 zombie, 0 stopped
    CPU0 states: 0.0% user, 7.0% system, 0.0% nice, 92.0% idle
    CPU1 states: 2.0% user, 0.0% system, 0.0% nice, 97.0% idle
    Mem: 512372K av, 487948K used, 24424K free, 712K shrd, 7480K buff
    Swap: 787144K av, 211512K used, 575632K free 93640K cached

    === server-status ===
    Server uptime: 4 hours 51 minutes 28 seconds
    Total accesses: 96905 - Total Traffic: 419.2 MB
    CPU Usage: u14.83 s5.75 cu11.96 cs4.16 - .21% CPU load
    5.54 requests/sec - 24.5 kB/second - 4535 B/request
    52 requests currently being processed, 101 idle servers

    Everything is looking good but I don't know what is the best value of MaxRequestsPerChild since before I changed from 150 to 15. The value of requests/sec is ~20 requests/sec and kB/second is ~140 kB/second but CPU load decrease from ~30% to ~0.5%

    I want to know if small value of requests/sec and requests/sec will effect performance of server or not.

    How much of MaxRequestsPerChild on your Apache?

    I would like to read your opinion


    Jimmy

  2. #2
    Join Date
    Dec 2001
    Location
    New Jersey
    Posts
    1,152
    any chance you could offer up what application you are running because you are already running into your swap memory.

    Mike

    p.s. I'm no briliant unix guy, but there should be good reason why in 5 hours your already into swap memory. In windows I spend hours tuning the servers to avoid the swap file. Your problem might sit on a bad application set up

    Mike
    I am Mike From ADEHOST.Com, Multidomain Windows hosting with Cold Fusion and ASP and Dot.NET Also offering multi-domain Unix hosting. silently, each one should ask, Have I done my daily task. Have I kept my honor bright, can I sleep without guilt tonight. Have I done and have I did, everything, to be prepared. - our motto to maintain services.

  3. #3
    Join Date
    Jul 2002
    Location
    Kolding, Denmark
    Posts
    292
    I just checked one of our servers - running one fresh, new, totally unused httpd-server takes up 6 MB RAM as far as I can tell.

    Unless you have a very good reason to do so, I'd say that starting up 100 servers are somewhat dramatic and it will obviously consume all of your available, physical memory.

    The lower CPU-load is most likely to be caused by heavy swapping once the server starts receiving incoming requests - especially since you've told it to kill newly created threads almost instantly (MaxRequestsPerChild 15).

    The swapping is causing the general performance to decrease a lot - that is why the CPU-load is so much lower: You're not serving nearly as many pages per second as before.

    I'm sure that there are tuning-experts that can explain this better but in short I'd make the following cahnges to your configuration:

    MinSpareServers 20
    - unless you need a huge overhead.

    MaxSpareServers 50
    - we don't want old threads using physical memory.

    StartServers 50
    - depending on your needs.

    MaxClients 512

    MaxRequestsPerChild 1000
    - the higher the better but be aware of memory leaking. Starting and shutting down threads takes up valuable resources so we don't do it unless really necessary.

    These numbers are just suggestions! Your needs may be very much different from what I'm facing locally, so be sure to benchmark your settings.
    Best regards,

    Anders C. Madsen
    Golden Planet Support - http://www.goldenplanet.com

  4. #4
    Here is more information about my server

    === error_log ===

    [Tue Sep 3 14:55:14 2002] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 92 idle, and 194 total children
    [Tue Sep 3 14:55:19 2002] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 92 idle, and 205 total children
    [Tue Sep 3 14:56:32 2002] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 98 idle, and 189 total children

    It show in log every 5 min.

  5. #5
    Join Date
    Jul 2002
    Location
    Kolding, Denmark
    Posts
    292
    Well, you're telling the poor thing that you want at least 100 spare servers but you don't have the physical RAM to accomodate it - what is it supposed to do?

    The log entry is just an information telling you that the server needs to spawn more children in order to stay within configuration values - nothing else. It is somewhat misleading that it tells you to increase MinSpareServers though - it's too high already and that is what's causing the entry to be logged in the first place.

    Try reducing MinSpareServers to some more reasonable values (a StartServers of 100 is OK since you actually seems to use them).
    Best regards,

    Anders C. Madsen
    Golden Planet Support - http://www.goldenplanet.com

  6. #6
    Thank you for your suggestion.

    However, I would like to know how to benchmark Apache?

    More details is really appreciated

    Jimmy

  7. #7
    Join Date
    Jul 2002
    Location
    Kolding, Denmark
    Posts
    292
    Uh-oh - now you're asking for real voodoo! Sorry but this is somewhat out of my league...

    One way to do it may be using ab.exe (ApacheBenchmark) from Remote Communications - while it is targeted at benchmarking mod_gzip on-the-fly compression it is also giving away informations about requests per second and connect/processing time.

    You may download ab.exe from here (it's free):

    http://www.remotecommunications.com/apache/ab/

    Be sure to read the documentation!
    Best regards,

    Anders C. Madsen
    Golden Planet Support - http://www.goldenplanet.com

  8. #8
    Thank you for your reply

    The program has print out a lot of information but I don't know which one is important and don't know which one should be lower and which one should be higher for good performance

    Concurrency Level
    Time taken for tests
    Complete requests
    Failed requests
    Total transferred
    HTML transferred
    Requests per second
    Transfer rate
    Connnection Times (ms)


    Jimmy

  9. #9
    Join Date
    Jul 2002
    Location
    Kolding, Denmark
    Posts
    292
    Originally posted by ThaiZone
    Thank you for your reply

    Concurrency Level
    Time taken for tests
    Complete requests
    Failed requests
    Total transferred
    HTML transferred
    Requests per second
    Transfer rate
    Connnection Times (ms)
    Well - there should be no failed requests, requests per sescond should be as high as possible and connection times as low as possible. Make sure that you fetch the page more than once by setting the "n"-parameter to e.g. 5 or 10, otherwise results may be unpredictable.

    Please note that this is just a rough benckhmark - I'm sure that there are many other (better suited) ways to do this but I don't know enough to help you there.
    Best regards,

    Anders C. Madsen
    Golden Planet Support - http://www.goldenplanet.com

  10. #10
    your system swaps a lot.. you will need to add another 512MB or 1GB of memory... will help you for some time..

    ps. what HDD system (IDE, SCSI-2, SCSI U160, RAID-1,RAID-5) are you using?

  11. #11
    ps. what HDD system (IDE, SCSI-2, SCSI U160, RAID-1,RAID-5) are you using?
    Adaptec AHA274x/284x/294x (EISA/VLB/PCI-Fast SCSI) with
    SEAGATE (ST336705LC) 36704 MB

  12. #12
    Join Date
    Nov 2001
    Location
    Ann Arbor, MI
    Posts
    2,978
    I agree that you might get some more memory. I saw someone post specs the other day for a dual 1GHz proc machine with only 512MB RAM, and I was thinking, "why?"

    You probably don't want a MaxRequestsPerChild set for 1000. Fifty is actually a good number for returning apache back to "rest" after a spike. I wouldn't set it higher than twice your min spare servers value.

    The apache docs actually list two good reasons for keeping this value low.

    1. It limits the amount of memory that process can consume by (accidental) memory leakage;
    2. By giving processes a finite lifetime, it helps reduce the number of processes when the server load reduces.

    Until you get more memory or your webserver gets busier, you'd be more than happy with starting 50-75 min servers and keeping them spare. And lower your MaxClients back down to 256.

    You might also look at your keepalive values.
    -Mark Adams
    www.bitserve.com - Secure Michigan web hosting for your business.
    Only host still offering a full money back uptime guarantee and prorated refunds.
    Offering advanced server management and security incident response!

  13. #13
    Join Date
    Jul 2002
    Location
    Kolding, Denmark
    Posts
    292
    Thanks Mark - your advice actually goes against a tuning-HOWTO I originally got my knowledge from but it does make sense.

    BTW - I thought that unneeded threads would be killed off once they weren't needed anymore, regardless of whether they had actually reached MaxRequestsPerChild or not?
    Best regards,

    Anders C. Madsen
    Golden Planet Support - http://www.goldenplanet.com

  14. #14
    Join Date
    Nov 2001
    Location
    Ann Arbor, MI
    Posts
    2,978
    As far as I know, apache only kills processes when idle after they've done their time (MaxRequestsPerChild), except for using the MaxSpareServers setting.

    I think that MaxSpareServers was originally designed to kill off spare processes, but people use it to prevent apache from spawning too many.

    In theory, you could have:

    MinSpareServers 25
    MaxSpareServers 25

    That would always keep 25 spare processes.

    But you typically don't want to immediately kill off your spare servers. You want to wait a little while to see if that heavy traffic is going to continue. The MaxRequestsPerChild setting lets us gradually go back down.

    You really only need to keep as many spare servers lying around as you might get requests per second to prevent any delay or resources spent in spawing new servers. You don't even need the 50-75, but it would be better than the 100 you have, and you'd still be pretty over optimized.

    I haven't found a "tuning apache" document that hasn't had at least one instance of bad advice (IMHO), except for the one on apache's site, which of course doesn't mention these directives.
    -Mark Adams
    www.bitserve.com - Secure Michigan web hosting for your business.
    Only host still offering a full money back uptime guarantee and prorated refunds.
    Offering advanced server management and security incident response!

  15. #15
    Join Date
    Jul 2002
    Location
    Kolding, Denmark
    Posts
    292
    I just did a bit of digging - now I know where I found the info about keeping MaxRequestsPerChild pretty high:

    #
    # MaxRequestsPerChild: the number of requests each child process is
    # allowed to process before the child dies. The child will exit so
    # as to avoid problems after prolonged use when Apache (and maybe the
    # libraries it uses) leak memory or other resources. On most systems, this
    # isn't really needed, but a few (such as Solaris) do have notable leaks
    # in the libraries. For these platforms, set to something like 10000
    # or so; a setting of 0 means unlimited.

    The way I read this the developers are recommending using the spare servers directives for controlling the amount of resources allocated, not MaxRequestsPerChild?
    Best regards,

    Anders C. Madsen
    Golden Planet Support - http://www.goldenplanet.com

  16. #16
    Join Date
    Nov 2001
    Location
    Ann Arbor, MI
    Posts
    2,978
    It's definitely odd that the default httpd.conf file and the docs go in totally different directions. Hopefully one day they'll decide which way to go.

    People's reasoning for a high number there is usually that you're saving resources spent on respawning children. Well if you're killing them off with MaxSpareServers, they'll never get to serve that many requests anyway. Also, you'll have to respawn them after killing them. So where's the benefit?

    So my recommendation is not using MaxSpareServers, but rather a "low" MaxRequestsPerChild setting to kill off your children.

    You probably wouldn't notice much difference between the two methods for killing off spare children though, unless you're getting:

    HEAVY BURST OF TRAFFIC!
    wait a few seconds...
    HEAVY BURST OF TRAFFIC!
    wait a few seconds...
    HEAVY BURST OF TRAFFIC!
    -Mark Adams
    www.bitserve.com - Secure Michigan web hosting for your business.
    Only host still offering a full money back uptime guarantee and prorated refunds.
    Offering advanced server management and security incident response!

  17. #17
    Join Date
    Jul 2002
    Location
    Kolding, Denmark
    Posts
    292
    Originally posted by bitserve

    People's reasoning for a high number there is usually that you're saving resources spent on respawning children. Well if you're killing them off with MaxSpareServers, they'll never get to serve that many requests anyway. Also, you'll have to respawn them after killing them. So where's the benefit?

    You probably wouldn't notice much difference between the two methods for killing off spare children though, unless you're getting:

    HEAVY BURST OF TRAFFIC!
    wait a few seconds...
    HEAVY BURST OF TRAFFIC!
    wait a few seconds...
    HEAVY BURST OF TRAFFIC!
    Ah - all of a sudden I think I understand the reasoning behind the recommendation in httpd.conf: If you're having a pretty stable number of requests coming in over a period of time and isn't experiencing memory leaks you actually could benefit from a high MaxRequestsPerChild.

    You would of course need to tune MinSpareServers and MaxSpareServers a bit to prevent the server from killing off and respawning servers all the time but unless RAM is a problem (there would be unused servers taking up memory) it should be possible to keep the same threads servicing a lot of requests without problems - especially with KeepAlive on.

    Setting a low MaxRequestsPerChild would just cause the server to kill children and respawn them even though they were working fine.

    Things are falling into place in my head now.

    On a server with short bursts of high traffic one should use your recommendation:

    * A reasonable but high number of MinSpareServers to keep the server ready for the next peak without hogging up too much memory.

    * A high number of MaxSpareServers - the number isn't that important as we use MaxRequestsPerChild to limit the number of threads.

    * A low MaxRequestsPerChild to kill off the remains of a burst pretty quickly in order to reduce memory allocation - otherwise the server will take far to long time recovering from a serious burst that used up all mermory and will be swapping unnecessarily, thus creating load on the CPU and the harddisk system.

    On a server with a rather stable (high) number of incoming requests one should go with the recommendation in httpd.conf:

    * A low number of MinSpareServers - just enough too keep up with minor bursts and natural fluctation.

    * A reasonable but high number of MaxSpareServers - as long as memory usage isn't a problem a high number will prevent killing and respawning.

    * A very high MaxRequestsPerChild in order to prevent killing and respawning - on a server with a high, stable load all resources should go into serving pages, not unnecessary housecleaning. Memory leaks and general apache stability will be the determining factor here.

    That makes sense to me - but perhaps I just finally lost my marbles for good....?
    Best regards,

    Anders C. Madsen
    Golden Planet Support - http://www.goldenplanet.com

  18. #18
    Join Date
    Nov 2001
    Location
    Ann Arbor, MI
    Posts
    2,978
    I totally agree. If you have a machine with a lot of memory and resources and want to use it all the time on having your web server always prepared, and you have no corruption problems with apache, there's no point in EVER moving back toward a "more idle" state. Just set everything high.

    Might as well set the MinSpareServers high too, though.
    -Mark Adams
    www.bitserve.com - Secure Michigan web hosting for your business.
    Only host still offering a full money back uptime guarantee and prorated refunds.
    Offering advanced server management and security incident response!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •