Search code examples
apacheubuntulamp

Slow apache on ubuntu


We have a pretty standard LAMP stack (Ubuntu 12.04 - Apache2 - MySQL - PHP), on a dedicated server with a large hosting provider.

Since a couple of days we are experiencing slow web performance from time to time (requests would succeed but would sometimes take up to 10-15 seconds).

I have tried to check the server usage with the top command, but nothing seems to indicate anything unusual or excessive usage (cpu usage would lie between 10-30%).

Tasks: 268 total,   2 running, 266 sleeping,   0 stopped,   0 zombie
Cpu(s):  4.2%us,  2.8%sy,  0.0%ni, 80.3%id, 11.3%wa,  0.0%hi,  1.4%si,  0.0%st
Mem:   8070300k total,  7779400k used,   290900k free,    66648k buffers
Swap:        0k total,        0k used,        0k free,  2799188k cached

Does anybody have an idea what other stats I could check and in which direction I should continue searching?


Solution

  • The issue was with the number of simultaneous connections allowed on Apache, which by default was set to 150 (in the /etc/apache2/apache2.conf file). I updated the directives:

    <IfModule mpm_prefork_module>
        ServerLimit        1500
        StartServers          5
        MinSpareServers       5
        MaxSpareServers      10
        MaxClients         1500
        MaxRequestsPerChild   0
    </IfModule>
    

    Further readings:

    http://oxpedia.org/wiki/index.php?title=Tune_apache2_for_more_concurrent_connections How do you increase the max number of concurrent connections in Apache?