性能:Nginx的SSL缓慢或只是在一般的SSL缓慢?

我有一个Amazon Web Services设置,在Nginx后面有一个Apache实例,Nginx处理SSL并提供除.php页面之外的所有内容。 在我的ApacheBenchtesting中,我看到这是我最昂贵的API调用(通过Memcachedcaching):

100 concurrent calls to API call (http): 115ms (median) 260ms (max) 100 concurrent calls to API call (https): 6.1s (median) 11.9s (max) 

我已经做了一些研究,禁用了最昂贵的SSL密码并启用了SSLcaching(我知道这在这个特殊的testing中没有帮助)。你能告诉我为什么我的SSL需要这么长时间吗? 我已经搭build了一个拥有8个CPU的大规模EC2服务器,甚至连续使用负载也只占CPU总数的50%。 我有8个Nginx工作者和一群Apache。 目前这整个设置是在一个EC2盒子,但我打算分裂它和负载平衡它。 关于这个话题有几个问题,但没有一个答案(禁用昂贵的密码,cachingssl,似乎做任何事情。)下面的示例结果:

 $ ab -k -n 100 -c 100 https://URL 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 URL.com (be patient).....done Server Software: nginx/1.0.15 Server Hostname: URL.com Server Port: 443 SSL/TLS Protocol: TLSv1/SSLv3,AES256-SHA,2048,256 Document Path: /PATH Document Length: 73142 bytes Concurrency Level: 100 Time taken for tests: 12.204 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Keep-Alive requests: 0 Total transferred: 7351097 bytes HTML transferred: 7314200 bytes Requests per second: 8.19 [#/sec] (mean) Time per request: 12203.589 [ms] (mean) Time per request: 122.036 [ms] (mean, across all concurrent requests) Transfer rate: 588.25 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 65 168 64.1 162 268 Processing: 385 6096 3438.6 6199 11928 Waiting: 379 6091 3438.5 6194 11923 Total: 449 6264 3476.4 6323 12196 Percentage of the requests served within a certain time (ms) 50% 6323 66% 8244 75% 9321 80% 9919 90% 11119 95% 11720 98% 12076 99% 12196 100% 12196 (longest request) 

这个问题最终导致我很早就设置了Nginx的速率限制,并影响了我的负载testing。 我知道愚蠢 限速过程中一个有趣的事情是,Nginx不会立即获得超过突发阈值的503错误,而是延迟响应。 只有当队列中的请求太多时才会发送503。