Reply
Apache using lots of memory
Old 09-30-2008, 02:32 PM Apache using lots of memory
Junior Talker

Posts: 1
Hi, I'm not really sure this is the right place to post this but what the hell. I've recenly been having problems with apache's memory usage, the type of problem that forces me into restarting apache. The server is running php, apache and mysql on centos. To show you how bad this problem is here is the output of top;

Code:
top - 18:26:35 up 11:33,  3 users,  load average: 4.23, 1.97, 0.88
Tasks: 132 total,   1 running, 131 sleeping,   0 stopped,   0 zombie
Cpu(s): 15.8% us,  3.0% sy,  0.0% ni, 78.1% id,  2.5% wa,  0.2% hi,  0.3% si
Mem:    897304k total,   697232k used,   200072k free,    53100k buffers
Swap:  2048276k total,      160k used,  2048116k free,   442076k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                          
22786 apache    15   0  108m  11m 3608 S   11  1.3   0:00.46 httpd                                                                             
22677 apache    15   0  107m  11m 3720 S    5  1.3   0:00.29 httpd                                                                             
22630 apache    15   0  107m  11m 3624 S    5  1.3   0:00.25 httpd                                                                             
22813 apache    15   0  107m  11m 3604 S    4  1.3   0:00.13 httpd                                                                             
22665 apache    15   0  107m  11m 3784 S    4  1.3   0:00.33 httpd                                                                             
22794 apache    16   0  107m  11m 3608 S    3  1.3   0:00.20 httpd                                                                             
 3447 mysql     15   0  147m  35m 4736 S    1  4.1  11:55.80 mysqld                                                                            
21008 apache    16   0  107m  11m 3664 S    1  1.3   0:00.99 httpd                                                                             
22229 apache    15   0  108m  11m 3732 S    1  1.3   0:01.64 httpd                                                                             
22604 apache    15   0  107m  11m 3616 S    1  1.3   0:00.29 httpd                                                                             
22795 apache    15   0  107m  10m 3104 S    1  1.2   0:00.02 httpd                                                                             
22265 apache    16   0  108m  12m 3872 S    0  1.4   0:00.87 httpd                                                                             
22368 apache    16   0  107m  11m 3756 S    0  1.3   0:01.06 httpd                                                                             
22610 apache    15   0  107m  11m 3648 S    0  1.3   0:00.56 httpd                                                                             
22793 apache    15   0  108m  11m 3640 S    0  1.3   0:00.14 httpd                                                                             
    1 root      16   0  4756  552  456 S    0  0.1   0:00.56 init
As you can see this is less than Ideal, now too attempt to solve this problem I recompiled apache (or httpd) with support for prefork mpm and added the following settings to /etc/httpd/conf/httpd.conf ;


Code:
Timeout 15
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
ServerLimit 256
StartServers 15
MinSpareServers 15
MaxSpareServers 20
MaxClients 200
MaxRequestsPerChild 500
but after restarting httpd I have noticed no differences, this server only handels about 300 simultaneos connections / users, so I'm quite sure that the volume of users isn't the problem. the most visited part of the server is some forums on one of the sites, which uses mod_rewrite and has an rss feed (phpbb), could that be a problem? anyway I would be very greatful of some suggestions on how I might go about investigaing the cause of this problem otherwise.

Last edited by leef : 09-30-2008 at 02:35 PM. Reason: there is no such thing as stupid spelling only stupid people
leef is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 10-01-2008, 02:33 AM Re: Apache using lots of memory
mtishetsky's Avatar
King Spam Talker

Posts: 1,134
Name: Mike
Location: Mataro, Spain
It is not the apache itself, it is most likely php, that runs under apache, and mysql, that is used by php script. Check your scripts, it's very probable that you do select * on some 300K rows table just to get the number of records in result. Learn to use mysqldumpslow, it shows you the number of records returned for each query. Learn to use pagination and the "limit" statement along with select count(*).
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Apache using lots of memory
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11400 seconds with 12 queries