For an article in a news paper, I'm benchmarking 5 different web servers (Apache2, Cherokee, Lighttpd, Monkey and Nginx).
The tests made consist of measuring the execution times as well as different parameters such as the number of request served per second, the amount of RAM, the CPU used, during a growing load of simultaneous clients (from 1 to 1.000 with a step of 10) each client sending 1.000.000 requets of a small fixed file, then of a medium fixed file, then a small dynamic content (hello.php) and finally a complex dynamic content (the computation of the reimbursment of a loan).
All the web servers are able to sustain such a load (up to 1.000 clients) but Apache2 which always stops to respond when the test reach 450 to 500 simultaneous clients.
My configuration is :
- CPU: AMD FX 8150 8 cores @ 4.2 GHz
- RAM: 32 Gb.
- SSD: 2 x Crucial 240 Gb SATA6
- OS: Ubuntu 12.04.3 64 bit
- WS: Apache 2.2.22
My Apache2 configuration is as follows:
/etc/apache2/apache2.conf
LockFile ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 30
KeepAlive On
MaxKeepAliveRequests 1000000
KeepAliveTimeout 2
ServerName "fnux.net"
<IfModule mpm_prefork_module>
StartServers 16
MinSpareServers 16
MaxSpareServers 16
ServerLimit 2048
MaxClients 1024
MaxRequestsPerChild 0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</Files>
DefaultType None
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel emerg
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include httpd.conf
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Include conf.d/
Include sites-enabled/
/etc/apache2/ports.conf
NameVirtualHost *:8180
Listen 8180
<IfModule mod_ssl.c>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
/etc/apache2/mods-available
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /cgi-bin/php5.external
<Location "/cgi-bin/php5.external">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
</Location>
</IfModule>
/etc/apache2/sites-available/default
<VirtualHost *:8180>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/apache2
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel emerg
##### CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>
</VirtualHost>
/etc/security/limits.conf
* soft nofile 1000000
* hard nofile 1000000
So, I would trully appreciate your advice to setup Apache2 to make it able to sustain 1.000 simultaneous clients, if this is even possible.
TIA for your help. Cheers.
@Laszlo Valco: I do 100 per 100 aggree with your point and that's why I came here to ask for advice and help to configure Apache2 in order to make it able to sustain such a load.
Now, I'm confortable to do so for all the other web servers but I admit that I'm dumb and completely ignorant of the Apache2 settings.
BTW, the current Apache2 configuration above isn't the default one, but once again I agree it doesn't meet the need to sustain my tests.
So, could you be kind enough to explain how to set the numbers affecting the worker processes in a way that the 1.000 child process are available?
I guess it's in the section "IfModule mpm_prefork_module" of the file "/etc/apache2/apache2.conf" but I've no idea how to set the right values accordingly to both my hardware capabilities (especially the amount of RAM that is 32 Gb) and my need to reach 1.000 simultaneous connected clients.
Your expertise would be truly appreciated to help me to use the right values since even after long searches I wasn't able to find clear explanations about how to do so.
TIA for more info.
Cheers.