Build and Install Apache 2.2.14 with MPM-EVENT on Debian Lenny

In this article we will discuss the building and installation of the last version of Apache in date (10/05/2009) on a Debian System. I started this serie because I wanted to try the new mpm engine implemented by the Apache foundation in its httpd server: mpm-event

First, get the last version of the httpd server from the official page and untar the source code in a specific repository.

Build it

Then, make sure you have the classic building packages like gcc or make and also some specific ones like libssl-dev.

The configure command I used is as follow.

CFLAGS="-O3 -falign-functions=4 -falign-jumps -falign-loops" \
./configure --prefix=**/targetfolder/apache-httpd-2.2.14/** \
--with-included-apr --enable-non-portable-atomics=yes **--with-mpm=event** \
--enable-mods-shared="auth-dbm auth-digest cache disk-cache file-cache \
mem-cache headers info logio deflate expires proxy proxy-ajp proxy-http \
proxy-balancer ssl mime-magic"

Then follow the regular make and make install commands. Everything can be run as user, as long as your targetfolder is accessible to the user.

Basic configuration

The content of the targetfolder is pretty easy to understand :

$ ls -l
total 60
drwxr-xr-x  2 julien julien  4096 oct  6 17:29 bin
drwxr-xr-x  2 julien julien  4096 oct  6 17:29 build
drwxr-xr-x  2 julien julien  4096 oct  6 17:29 cgi-bin
drwxr-xr-x  4 julien julien  4096 oct  6 17:34 conf
drwxr-xr-x  3 julien julien  4096 oct  6 17:29 error
drwxr-xr-x  2 julien julien  4096 sep 24 01:28 htdocs
drwxr-xr-x  3 julien julien  4096 oct  6 17:29 icons
drwxr-xr-x  2 julien julien  4096 oct  6 17:29 include
drwxr-xr-x  3 julien julien  4096 oct  6 17:28 lib
drwxr-xr-x  2 julien julien  4096 oct  6 17:34 logs
drwxr-xr-x  4 julien julien  4096 oct  6 17:29 man
drwxr-xr-x 14 julien julien 12288 sep 24 01:29 manual
drwxr-xr-x  2 julien julien  4096 oct  6 17:29 modules

Let's edit conf/httpd.conf and change the Listen directive to another port than 80 (since this one is already in use on the system, by another Apache instance.

$vim conf/httpd.conf
[...]
Listen 12345

Also, edit the LoadModule list to comment everything. We don't need same and they will add some unwanted memory usage.

 54 #LoadModule auth_digest_module modules/mod_auth_digest.so
 55 #LoadModule file_cache_module modules/mod_file_cache.so
 56 #LoadModule cache_module modules/mod_cache.so
 57 #LoadModule disk_cache_module modules/mod_disk_cache.so
 58 #LoadModule mem_cache_module modules/mod_mem_cache.so
 59 #LoadModule deflate_module modules/mod_deflate.so
 60 #LoadModule logio_module modules/mod_logio.so
 61 #LoadModule mime_magic_module modules/mod_mime_magic.so
 62 #LoadModule expires_module modules/mod_expires.so
 63 #LoadModule headers_module modules/mod_headers.so
 64 #LoadModule proxy_module modules/mod_proxy.so
 65 #LoadModule proxy_connect_module modules/mod_proxy_connect.so
 66 #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
 67 #LoadModule proxy_http_module modules/mod_proxy_http.so
 68 #LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
 69 #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
 70 #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
 71 #LoadModule ssl_module modules/mod_ssl.so
 72 #LoadModule info_module modules/mod_info.so

Start the instance :

$ bin/apachectl graceful

Try to connect:

$ nc localhost 12345
GET /index.html HTTP/1.0

HTTP/1.1 200 OK
Date: Tue, 06 Oct 2009 15:47:54 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8g
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "9803b-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Connection: close
Content-Type: text/html


<html><body><h1>It works!</h1></body></html>

Good, it's working fine.

MPM conf

To change the settings of the mpm engine, we need to edit httpd.conf and include the mpm configuration file. Go to conf/httpd.conf and uncomment the following line:

388 # Server-pool management (MPM specific)
389 Include conf/extra/httpd-mpm.conf

Then, go to conf/extra/httpd-mpm.conf and add an entry for the mpm engine. This entry is not present by default, you need to add it manually.

I personnally commented out all of the other engine (except the ones with a ”!”) and added the following:

 60 <IfModule mpm_event_module>        
 61     StartServers         1
 62     ServerLimit          1
 63     MaxClients           50
 64     MinSpareThreads       1
 65     MaxSpareThreads      10
 66     ThreadsPerChild      50
 67     MaxRequestsPerChild   0
 68 </IfModule>

Ok, don't jump yet, this is just some extreme setting to study the behavior of apache when just one process is handling all the requests. We define up to 50 clients, and thus need 50 threads in the main process to handle them. (note for later: with epoll, do we still need one thread per client? I need to clarify this…)

Benchmark

OK, server is on and listening. We will now launch some basic benchmark to see how it reacts out of the box:

$ /home/julien/inject29 -u 10 -H "Host: localhost" -G "localhost:12345/"                      

   hits ^hits hits/s  ^h/s     bytes  kB/s  last  errs  tout htime  sdht ptime
   4048  4048   4658  4658   1190112  1369  1369     0     0 9.9 1.9 9.9
   8240  4192   4115  3699   2422560  1210  1087     0     0 12.2 1.0 12.2
  11968  3728   3988  3728   3518592  1172  1096     0     0 12.2 1.0 12.2
  15760  3792   3935  3780   4633440  1156  1111     0     0 12.0 1.2 12.0
  19520  3760   3896  3748   5738880  1145  1102     0     0 12.1 1.1 12.1
  23248  3728   3869  3728   6834912  1137  1096     0     0 12.2 1.0 12.2
  27008  3760   3854  3763   7940352  1133  1106     0     0 12.1 1.1 12.1

[.... snip .... ]

Fin.                      
Clients : 24063            
Hits    : 1924624 + 0 abortés
Octets  : 565839456            
Duree   : 522327ms           
Debit   : 1083kB/s           
Reponse : 3684hits/s           
Erreurs : 0            
Timeouts: 0            
Temps moyen de hit: 12.0ms 
Temps moyen d'une page complete: 12.0ms
Date de demarrage: 1255598701 (15 Oct 2009 - 11:25:01)
Ligne de commande : /home/julien/inject29 -u 10 -H Host: localhost -G localhost:12345/

Around 3684hits per seconds without any configuration and with the injector running on the same machine as the server… We can certainly do better, but for a start it's definitely not too bad !

And memory usage ?

During the injection, I launch the following command to check the memory usage of apache. And, it is, well… quite huge !

$ for i in `ps -edf|grep httpd|awk {'print $2'}`;do echo -n "httpd $i ==> ";pmap $i|grep total;done
httpd 8437 ==>  total     4864K
httpd 8570 ==>  total     5000K
httpd 8571 ==>  total   434084K

430Mo of memory to handle 50 simultaneous clients… Apache definitely has a big butt !

~~DISCUSSION~~

en/ressources/dossiers/apache/build_install.txt · Last modified: 2011/03/16 01:30 (external edit)
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0