• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1043
  • Last Modified:

Apache Optimization

I need help optimizing a server w/ 15Gigs of RAM.  The load is currently stable now, however it's slow.  It's for a very popular & busy forum server.  Below are the current values.  Any Apache experts here that can help me possibly fix the following values or explain them?  At certain times, I see the following error below.  Thank you.

[Wed Jun 21 11:43:08 2006] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 16 children, there are 23 idle, and 370 total children

[Wed Jun 21 11:43:09 2006] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 32 children, there are 24 idle, and 386 total children

<IfModule prefork.c>
StartServers      500
MinSpareServers   40
MaxSpareServers   90
ServerLimit      2048
MaxClients       2048
MaxRequestsPerChild  0

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers       1000
MaxClients         2500
MinSpareThreads     450
MaxSpareThreads    2500
ThreadsPerChild     350
MaxRequestsPerChild 0
1 Solution
techie411Author Commented:
Did you read: http://httpd.apache.org/docs/2.2/mod/prefork.html and http://httpd.apache.org/docs/2.2/misc/perf-tuning.html ?

> At certain times, I see the following error below.
that's are not errors, just 'info' messages ...

MaxClients - this variable is very importent.
1) Determine memory size, consumed by a single apache process (top command), suppose we have:

71264 www         1  96    0 20024K 11572K select   0:00  0.51% httpd

I see 20M RAM size and about 12M resident memory size.

Now you have 12G RAM, suppose 10G is ok to use for Apache processes (other 2G for system and whatever.
Then, your limit is about 833 apache processes (that can fit to memory without swapping). You should never exceed this value of childrens.

Now (of even first of all) check what MPM are you using:
httpd -V
it's either prefork (-D APACHE_MPM_DIR="server/mpm/prefork") or worker, but NOT both

Don't use so much value of StartServers:
StartServers      500
most of them will be killed in a second after apache start (it's an extra work to spawn then to kill) because most of them will be idle at start time and every idle child above MaxSpareServers will be killed.

# These lines will manage how often apache will spawn and kill new idle servers.
MinSpareServers   40
MaxSpareServers   90

These error logs "spawning 16 children, there are 23 idle" shows that your have high enough connection rate (about 80 connections per second).
Why 64? Because you have 370 spare apache servers with 2048 maximum clients, suppose the load is distributed equally, it's about 5 connections per 1 server process (yes, it's very low). Spare servers are checked for spawn once a second, so 16 servers need to be spawn to handle these new connections, we have 16*5=80 connections per second.

What is wrong in your configuration?  High value of StartServers. Probably it's a low value of MaxClients. May be someone is doing DoS against your server, you may limit connection rate then.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now