Apache Tuning

Consegui os resultados esperados no Apache 2.2.3 utilizando (e otimizando) o MPM (Multi-Processing Module) worker, ao invés no padrão, que é o prefork.
Para habilitar o MPM worker no CentOS 5, a seguinte linha deve ser descomentada no arquivo “/etc/sysconfig/httpd”:

HTTPD=/usr/sbin/httpd.worker

Mesmo com o MPM worker, com as configurações padrão, não foi possível atender as 1000 requisições simultâneas. Eu consegui atingir este resultado com as seguintes configurações no arquivo “/etc/sysconfig/httpd”:

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
# StartServers         2
# MaxClients         150
# MinSpareThreads     25
# MaxSpareThreads     75
# ThreadsPerChild     25
# MaxRequestsPerChild  0
StartServers         100
MaxClients          1024
MinSpareThreads      100
MaxSpareThreads     1000
ThreadsPerChild       64
MaxRequestsPerChild    0
</IfModule>

A seguir, o resultado. As 10000 requisições com paralelismo de 1000 foi atendida, mas com tempo ainda inferior ao resultado com a configuração padrão do IIS 7:

ricardo@ricardo-laptop:~$ ab -n 10000 -c 1000 http://192.168.56.101/index.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.56.101 (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
Completed 10000 requests
Finished 10000 requests
Server Software:        Apache/2.2.3
Server Hostname:        192.168.56.101
Server Port:            80
Document Path:          /index.html
Document Length:        287 bytes
Concurrency Level:      1000
Time taken for tests:   16.418 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Non-2xx responses:      10000
Total transferred:      4660000 bytes
HTML transferred:       2870000 bytes
Requests per second:    609.10 [#/sec] (mean)
Time per request:       1641.754 [ms] (mean)
Time per request:       1.642 [ms] (mean, across all concurrent requests)
Transfer rate:          277.19 [Kbytes/sec] received
Connection Times (ms)
 min  mean[+/-sd] median   max
Connect:        0  171 793.2      1    9007
Processing:     2 1367 3701.9    163   16342
Waiting:        2 1269 3657.0    161   16334
Total:          3 1538 3749.8    169   16376
Percentage of the requests served within a certain time (ms)
 50%    169
 66%    215
 75%    339
 80%    560
 90%   3964
 95%  15136
 98%  16070
 99%  16194
 100%  16376 (longest request)
ricardo@ricardo-laptop:~$

Abaixo um print com o Load da VM durante o teste:

Leave a Reply

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Esse site utiliza o Akismet para reduzir spam. Aprenda como seus dados de comentários são processados.