Stress Test Apache

O meio mais eficaz de realizar um Stress Test simples no Apache é utilizando o programa ab (ApacheBench), mantido pela própria Apache Foundation.

Abaixo, em um teste em um Notebook Core 2 Duo (T4300) e 4GB de RAM, com Ubuntu 10.4 Desktop, (testei também em CentOS 5.4, os resultados foram similares)  é demonstrado que a configuração padrão do Apache não é para qualquer carg

Começando com uma carga baixa, de 1000 requisições, com concorrência 10 – o seja, 10 requisições de cada vez. Sem problemas, todas as 1000 requisições foram completadas com sucesso.

ricardo@ricardo-laptop:~$ ab -n 1000 -c 10 http://localhost/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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        Apache/2.2.14
Server Hostname:        localhost
Server Port:            80

Document Path:          /index.html
Document Length:        177 bytes

Concurrency Level:      10
Time taken for tests:   0.293 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      456724 bytes
HTML transferred:       178062 bytes
Requests per second:    3418.59 [#/sec] (mean)
Time per request:       2.925 [ms] (mean)
Time per request:       0.293 [ms] (mean, across all concurrent requests)
Transfer rate:          1524.76 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    1   0.5      1       4
Processing:     1    2   0.5      2       5
Waiting:        0    1   0.5      1       3
Total:          2    3   0.6      3       6

Percentage of the requests served within a certain time (ms)
50%      3
66%      3
75%      3
80%      3
90%      4
95%      4
98%      4
99%      5
100%      6 (longest request)

Agora aumentando apenas a concorrência para 100, o Apache também respondeu bem.

ricardo@ricardo-laptop:~$ ab -n 1000 -c 100 http://localhost/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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        Apache/2.2.14
Server Hostname:        localhost
Server Port:            80

Document Path:          /index.html
Document Length:        177 bytes

Concurrency Level:      100
Time taken for tests:   0.327 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      473522 bytes
HTML transferred:       184611 bytes
Requests per second:    3062.08 [#/sec] (mean)
Time per request:       32.657 [ms] (mean)
Time per request:       0.327 [ms] (mean, across all concurrent requests)
Transfer rate:          1415.98 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        2    8   3.7      8      19
Processing:     9   23   5.0     23      35
Waiting:        2   16   3.0     16      35
Total:         14   31   3.8     31      40

Percentage of the requests served within a certain time (ms)
50%     31
66%     33
75%     33
80%     34
90%     35
95%     36
98%     37
99%     38
100%     40 (longest request)

Aumentando a concorrência para 1000, mas sem aumentar o número de requisições, não há problemas.

ricardo@ricardo-laptop:~$ ab -n 1000 -c 1000 http://localhost/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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        Apache/2.2.14
Server Hostname:        localhost
Server Port:            80

Document Path:          /index.html
Document Length:        177 bytes

Concurrency Level:      1000
Time taken for tests:   1.587 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      464896 bytes
HTML transferred:       181248 bytes
Requests per second:    630.17 [#/sec] (mean)
Time per request:       1586.874 [ms] (mean)
Time per request:       1.587 [ms] (mean, across all concurrent requests)
Transfer rate:          286.10 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        2   19  11.6     15      37
Processing:    14  232 395.6     50    1550
Waiting:        3  227 397.4     43    1548
Total:         35  252 400.7     63    1579

Percentage of the requests served within a certain time (ms)
50%     63
66%     66
75%     83
80%    698
90%    712
95%   1571
98%   1577
99%   1578
100%   1579 (longest request)

Agora aumentando a concorência para 1000, com 100000 requisições, já temos problemas.

ricardo@ricardo-laptop:~$ ab -n 100000 -c 1000 http://localhost/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 localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
apr_socket_recv: Connection reset by peer (104)
Total of 99877 requests completed

Repetindo o teste, os problemas continuam.


ricardo@ricardo-laptop:~$ ab -n 100000 -c 1000 http://localhost/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 localhost (be patient)
Completed 10000 requests
apr_socket_recv: Connection reset by peer (104)
Total of 19096 requests completed
ricardo@ricardo-laptop:~$ ab -n 100000 -c 1000 http://localhost/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 localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
apr_socket_recv: Connection reset by peer (104)
Total of 99674 requests completed


ricardo@ricardo-laptop:~$ ab -n 100000 -c 1000 http://localhost/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 localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests

apr_poll: The timeout specified has expired (70007)
Total of 99857 requests completed

Voltando a utilizar uma carga menor, o Apache volta a responder bem.

ricardo@ricardo-laptop:~$ ab -n 10000 -c 100 http://localhost/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 localhost (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.14
Server Hostname:        localhost
Server Port:            80

Document Path:          /index.html
Document Length:        177 bytes

Concurrency Level:      100
Time taken for tests:   2.142 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      4558614 bytes
HTML transferred:       1777257 bytes
Requests per second:    4668.95 [#/sec] (mean)
Time per request:       21.418 [ms] (mean)
Time per request:       0.214 [ms] (mean, across all concurrent requests)
Transfer rate:          2078.51 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0   10   2.7     10      23
Processing:     3   11   2.9     11      29
Waiting:        1    9   3.0      9      22
Total:          8   21   3.3     20      45

Percentage of the requests served within a certain time (ms)
50%     20
66%     21
75%     23
80%     23
90%     27
95%     28
98%     29
99%     32
100%     45 (longest request)

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.