prefork vs. worker - multicore machine
I wanted to find out which apache mpm configuration is best suited for simple static content.
I performed some test on multicore machine using Abache Bench tool (ab) which is comes with httpd. Prefork won with Worker by only 5% - it is not much.
Detailed results below. Check out this page for low end 1 CPU machine.
The answer which is better is not very obvious here. Despite those results, it is a fact that for slower machines worker mode works better and generates lower CPU usage & load.
The machine is and quite high-end IBM server with 16 core (4 CPU) and 16 GB of RAM running Linux:
Linux 2.6.18-36.el5 #1 SMP Fri Jul 20 14:26:46 EDT 2007 x86_64 x86_64 x86_64
I used self compiled apache 2.2.8 with such configuration for prefork:
./configure --with-mpm=prefork --prefix=$HOME/apache \
--with-included-apr --with-expat=builtin
make -j 10 (yep its multicore ;-)
make install
And for the worker:
./configure --with-mpm=worker --prefix=$HOME/apache \
--with-included-apr --with-expat=builtin
make -j 10 (yep its multicore ;-)
make install
Configuration for the mpm for prefork/worker modes was:
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 75
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
Testing methodology was very simple. Make 10000 requests with 10 concurent "clients"
$ ./ab -n 10000 -c 10 http://172.30.72.194:2080/index.html
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.30.72.194 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests
Server Software: Apache/2.2.8
Server Hostname: 172.30.72.194
Server Port: 2080
Document Path: /index.html
Document Length: 44 bytes
Concurrency Level: 10
Time taken for tests: 2.73096 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2930293 bytes
HTML transferred: 440044 bytes
Requests per second: 4823.70 [#/sec] (mean)
Time per request: 2.073 [ms] (mean)
Time per request: 0.207 [ms] (mean, across all concurrent requests)
Transfer rate: 1380.06 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 0 1 0.7 1 3
Waiting: 0 0 0.8 1 2
Total: 0 1 0.7 1 4
WARNING: The median and mean for the waiting time are not within a normal deviation
These results are probably not that reliable.
Percentage of the requests served within a certain time (ms)
50% 1
66% 2
75% 2
80% 2
90% 2
95% 2
98% 2
99% 3
100% 4 (longest request)
What was quite supprising for me that the 'Requests per second' value for more that one concurent ab testing thread was almost the same! Value was different for only few percents!
-c 50 - Requests per second: 4640.77 [#/sec] (mean), Time per request: 10.512 [ms] (mean)
-c 20 - Requests per second: 4764.38 [#/sec] (mean), Time per request: 4.198 [ms] (mean)
-c 10 - Requests per second: 4662.70 [#/sec] (mean), Time per request: 2.145 [ms] (mean)
-c 5 - Requests per second: 4698.37 [#/sec] (mean), Time per request: 1.064 [ms] (mean)
-c 1 - Requests per second: 2469.26 [#/sec] (mean), Time per request: 0.405 [ms] (mean)
Results for the worker mode are:
$ ./ab -n 10000 -c 10 http://172.30.72.194:2080/index.html
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.30.72.194 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests
Server Software: Apache/2.2.8
Server Hostname: 172.30.72.194
Server Port: 2080
Document Path: /index.html
Document Length: 44 bytes
Concurrency Level: 10
Time taken for tests: 2.178024 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2930000 bytes
HTML transferred: 440000 bytes
Requests per second: 4591.32 [#/sec] (mean)
Time per request: 2.178 [ms] (mean)
Time per request: 0.218 [ms] (mean, across all concurrent requests)
Transfer rate: 1313.58 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 0 1 0.8 2 3
Waiting: 0 0 0.3 0 1
Total: 0 1 0.8 2 3
WARNING: The median and mean for the processing time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the total time are not within a normal deviation
These results are probably not that reliable.
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 2
95% 2
98% 2
99% 2
100% 3 (longest request)
-c 20 - Requests per second: 4653.92 [#/sec] (mean), Time per request: 4.297 [ms] (mean)
-c 10 - Requests per second: 4591.32 [#/sec] (mean), Time per request: 2.178 [ms] (mean)
-c 5 - Requests per second: 4482.53 [#/sec] (mean), Time per request: 1.115 [ms] (mean)
-c 2 - Requests per second: 4006.64 [#/sec] (mean), Time per request: 0.499 [ms] (mean)
-c 1 - Requests per second: 2212.52 [#/sec] (mean), Time per request: 0.452 [ms] (mean)
As I mentioned the beggining. For powerful machines serving static content prefork mpm is faster about 5% faster. Well, it is not much. For slower machines check out this article
post info - 4 comments | en | pl | Add comment