Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

im new to server administration and i've got a site with many users and dynamic content and a virtual server with 2gb ram and a good multicore cpu. but only 8 users are served by the server simultaneously, if there are more users requesting a page then they have to wait, which is really annoying. i know the apache2.conf settings are not right but i dont know how to sent them correctly.

im guessing these are the relevant lines from the apache2.conf:

KeepAlive On

MaxKeepAliveRequests    5

KeepAliveTimeout    5

<IfModule mpm_prefork_module>
    StartServers       1
    MinSpareServers    1
    MaxSpareServers    5
    MaxClients        60
    MaxRequestsPerChild   0 </IfModule>

<IfModule mpm_itk_module>
    StartServers       1
    MinSpareServers    1
    MaxSpareServers    5
    MaxClients        60
    MaxRequestsPerChild   0 </IfModule>

<IfModule mpm_worker_module>
    StartServers       1
    MinSpareThreads    1
    MaxSpareThreads    4
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients        60
    MaxRequestsPerChild   0 </IfModule>

<IfModule mpm_event_module>
    StartServers       1
    MaxClients        60
    MinSpareThreads    1
    MaxSpareThreads    4
    ThreadLimit          64
    ThreadsPerChild      25
    MaxRequestsPerChild   0 </IfModule>

when some users are online it looks something like this:

 5945 web0      16   0  207m  44m 8200 S    8  2.2   0:00.24 php-cgi
 5947 web0      21   0  207m  44m 8200 S    6  2.2   0:00.19 php-cgi
 5946 web0      15   0  207m  44m 8200 S    8  2.2   0:00.23 php-cgi
 5950 web0      16   0  207m  44m 8200 S    7  2.2   0:00.22 php-cgi
 5956 web0      18   0  184m  25m 8132 R    4  1.3   0:00.11 php-cgi
 5958 web0      18   0  172m  12m 7200 R    1  0.6   0:00.03 php-cgi
 1344 root      15   0 89176 4516 2136 S    0  0.2   0:02.68 apache2
 5611 www-data  15   0 89836 4452 1424 S    0  0.2   0:00.47 apache2
 5454 www-data  15   0 89704 4420 1424 S    1  0.2   0:00.49 apache2
 5927 www-data  15   0 89840 4416 1412 S    0  0.2   0:00.03 apache2
 5892 www-data  15   0 89840 4400 1424 S    1  0.2   0:00.04 apache2
 5916 www-data  15   0 89704 4304 1428 S    0  0.2   0:00.01 apache2
 5546 www-data  15   0 89516 4260 1424 S    0  0.2   0:00.47 apache2
 5893 www-data  15   0 89516 4248 1412 S    1  0.2   0:00.10 apache2
 5570 www-data  15   0 89484 4228 1424 S    0  0.2   0:00.43 apache2
 5689 www-data  15   0 89484 4224 1424 S    1  0.2   0:00.32 apache2
 5538 www-data  15   0 89484 4220 1424 S    1  0.2   0:00.63 apache2
 5879 www-data  16   0 89484 4220 1424 S    0  0.2   0:00.04 apache2
 5910 www-data  15   0 89484 4212 1412 S    1  0.2   0:00.06 apache2
 5796 www-data  15   0 89476 4208 1412 S    1  0.2   0:00.25 apache2
 5769 www-data  16   0 89484 4204 1412 S    0  0.2   0:00.21 apache2
 5926 www-data  15   0 89484 4200 1412 S    0  0.2   0:00.02 apache2

can anyone give me some advice on how to correct the settings? thanks in advance.

share|improve this question
1  
Which MPM are you using? What method did you use to determine that 8 was the maximum number of simultaneous requests? –  Shane Madden Jul 3 '12 at 5:20
    
that was just a guess, sorry i should have stated that. i confused it beacuse my site was running on a different server before and there 8 was the limit. it could be different now, but my own tests showed that only 5-10 users get the page instantly, the rest needs to wait until the other requestes finished. –  peter smergle Jul 3 '12 at 5:34
    
Compiled in modules: core.c mod_log_config.c mod_logio.c prefork.c http_core.c mod_so.c Server version: Apache/2.2.16 (Debian) Server built: Feb 5 2012 21:35:42 sorry i am new to this. was this what u were asking for? –  peter smergle Jul 3 '12 at 5:37
    
Yup, you're on prefork. MaxClients 60 seems to be the lowest limit you have in place.. are the users just requesting a single resource, or does the page they're loading have extra resources (images, css, javascript)? And what kind of content are you serving - is there any dynamic content generation through something like PHP involved? –  Shane Madden Jul 3 '12 at 5:57
    
its all in php and there is a lot of mysql queries going on. there is a forum and news pages, with images css a lot of javascript jquery etc. –  peter smergle Jul 3 '12 at 6:01
add comment

1 Answer

up vote 1 down vote accepted

the problem is not with Apache and seems you're running out of memory - per your server description. Try to optimize your PHP scripts and use an opcode cache, like APC/Xcache. Just to confirm, run "sar -r" and look to the output.

share|improve this answer
    
"sar -r" isnt working says command not found? -bash: sar: command not found –  peter smergle Jul 3 '12 at 6:04
    
Great! Let me show you: - you have 16 apache2 processes each with ~ 90MB - you have 6 php-cgi processes, each with ~ 200MB That's a total of "2.6GB". Remember the memory needed for MySQL and OS and you'll need at least the double memory you have right now. Give sar a try and install it (perhaps some apt-get install sar may help you) or install other monitoring system only to confirm my assumption. It may help you also if your forum have any built in caching method. –  ruyrocha Jul 3 '12 at 6:16
    
thanks i will try using sar and have a look at its output. im rewriting the whole page right now using zend and i will use zend cache for the forum queries which take up a lot of time and memory etc. –  peter smergle Jul 3 '12 at 6:18
    
apt-get install sar Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package sar cant install sar btw... –  peter smergle Jul 3 '12 at 6:19
    
Sorry about the typo: apt-get install sysstat (will include sar) also change state to enabled on /etc/default/sysstat –  ruyrocha Jul 3 '12 at 6:22
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.