I'm currently running apache2.2 with mod_event, php-fpm and apc on Debian Wheezy. I've hosting 3 normal websites and 1 really shitty website, which has really bad code and needs sometimes 2 minutes for a single page load. The database already runs on RDS, and shouldn't be the problem, but rather that the code does inefficient db lookups. However, we don't have a PHP developer anymore, so can't fix the code.
At some point when accessing this site, apache reaches MaxClients and FPM too.
apache2ctl -M output
Loaded Modules: core_module (static) log_config_module (static) logio_module (static) version_module (static) mpm_event_module (static) http_module (static) so_module (static) actions_module (shared) alias_module (shared) authz_host_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) expires_module (shared) fastcgi_module (shared) mime_module (shared) negotiation_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) ssl_module (shared) status_module (shared) Syntax OK
<IfModule mpm_event_module> StartServers 2 MinSpareThreads 25 MaxSpareThreads 75 ThreadLimit 64 ThreadsPerChild 25 MaxClients 150 MaxRequestsPerChild 0 </IfModule>
Keepalive On MaxKeepAliveRequests 100 KeepAliveTimeout 5
pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3
extension=apc.so apc.enabled=1 apc.shm_size=128M apc.ttl=3600 apc.user_ttl=7200 apc.gc_ttl=3600 apc.max_file_size=1M
Fastcgi apache config:
<IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcgi AddHandler php5-fcgi .php #FastCgiWrapper /usr/lib/apache2/suexec FastCgiIpcDir /var/lib/apache2/fastcgi Action php5-fcgi /php5-fcgi Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass- header Authorization -idle-timeout 250 </IfModule>
Can you give me some tips how to optimise this setup? Thanks for your help.
Server load is very low(0.00 0.01 0.05 1/169 4823)
Memory looks ok:
total used free shared buffers cached Mem: 2011 431 1580 0 74 229 -/+ buffers/cache: 126 1885