Eu vi esta pergunta várias vezes neste site e em outros, mas qualquer uma delas me forneceu uma solução válida para o meu problema.
Eu tenho um servidor Ubuntu 12.04 executando o Apache 2.2.22. O tráfego http está funcionando bem, mas o tráfego SSL está sendo muito lento. Ao carregar um site eu posso ver as imagens carregando enquanto na versão http todas elas quase que imediatamente. Eu corro alguns testes:
HTTP:
ab -n 1000 -c 250 http://IP/test.jpeg
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 IP (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.22
Server Hostname: IP
Server Port: 80
Document Path: /test.jpeg
Document Length: 19558 bytes
Concurrency Level: 250
Time taken for tests: 11.104 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 19842000 bytes
HTML transferred: 19558000 bytes
Requests per second: 90.06 [#/sec] (mean)
Time per request: 2775.995 [ms] (mean)
Time per request: 11.104 [ms] (mean, across all concurrent requests)
Transfer rate: 1745.05 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 254 549 872.4 270 3289
Processing: 518 2046 1584.9 1250 8370
Waiting: 258 1596 1532.1 724 7214
Total: 779 2595 2044.1 1525 10467
Percentage of the requests served within a certain time (ms)
50% 1525
66% 2192
75% 3424
80% 4248
90% 6013
95% 7175
98% 7723
99% 10189
100% 10467 (longest request)
HTTPS:
ab -n 1000 -c 250 https://IP/test.jpeg
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 IP (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.22
Server Hostname: IP
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,DHE-RSA-AES256-SHA,1024,256
Document Path: /test.jpeg
Document Length: 19558 bytes
Concurrency Level: 250
Time taken for tests: 62.911 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 19842000 bytes
HTML transferred: 19558000 bytes
Requests per second: 15.90 [#/sec] (mean)
Time per request: 15727.734 [ms] (mean)
Time per request: 62.911 [ms] (mean, across all concurrent requests)
Transfer rate: 308.01 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1225 8408 3478.8 8733 14994
Processing: 957 6470 3693.6 5922 13997
Waiting: 258 2422 1720.7 1711 8113
Total: 10486 14878 4730.7 12594 27169
Percentage of the requests served within a certain time (ms)
50% 12594
66% 14805
75% 14828
80% 21609
90% 22990
95% 23136
98% 27115
99% 27125
100% 27169 (longest request)
HTTPS com keep alive:
ab -k -n 1000 -c 250 https://IP/test.jpeg
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 IP (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.22
Server Hostname: IP
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,DHE-RSA-AES256-SHA,1024,256
Document Path: /test.jpeg
Document Length: 19558 bytes
Concurrency Level: 250
Time taken for tests: 13.565 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 1000
Total transferred: 19852150 bytes
HTML transferred: 19558000 bytes
Requests per second: 73.72 [#/sec] (mean)
Time per request: 3391.342 [ms] (mean)
Time per request: 13.565 [ms] (mean, across all concurrent requests)
Transfer rate: 1429.14 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1051 2562.0 0 11662
Processing: 258 903 667.8 556 2710
Waiting: 254 466 460.8 268 1840
Total: 258 1954 2982.9 565 12518
Percentage of the requests served within a certain time (ms)
50% 565
66% 830
75% 1096
80% 1361
90% 8746
95% 8753
98% 9244
99% 9595
100% 12518 (longest request)
Eu posso entender que o https pode ser um pouco mais lento que o http e isso deve ser mitigado com o keepalive, mas eu ainda não entendo a grande diferença e porque eu posso realmente ver o carregamento incrivelmente lento. Eu acho que é algum erro de configuração que fiz porque no servidor de pedidos eu instalei https não é tão lento assim de longe.
Outras informações que podem ser úteis são:
cat mods-available/ssl.conf |grep SSLRandomSeed
SSLRandomSeed startup builtin
SSLRandomSeed startup file:/dev/urandom 1024
SSLRandomSeed connect builtin
SSLRandomSeed connect file:/dev/urandom 1024
Foi assim que criei meus certificados:
openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.key
Esta é a configuração do default-ssl:
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
DocumentRoot /var/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Alguma idéia?
ATUALIZAÇÃO:
Está sendo tão lento apenas no Chrome até agora ... Firefox e Safari estão OK, isso pode definitivamente dar uma dica, eu vou investigar isso.