Solved

Apache Optimization

Posted on 2006-06-21
4
885 Views
Last Modified: 2008-02-01
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
</IfModule>

# 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
</IfModule>
0
Comment
Question by:techie411
4 Comments
 

Author Comment

by:techie411
ID: 17004532
Bump.....
0
 
LVL 27

Accepted Solution

by:
Nopius earned 500 total points
ID: 17006869
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:

   PID USERNAME LWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
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.


0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question