| Subject: | Nginx ridiculously slow with PHP+SSL combined | |
|---|---|---|
| From: | Xeriar (ngin...@nginx.us) | |
| Date: | Jan 26, 2012 7:30:13 am | |
| List: | ru.sysoev.nginx | |
So, I'm having an issue with SSL and fastcgi_pass, specifically to PHP.
PHP over standard http gets me over 6,000 requests per second, without stressing the CPU. It's limited by somaxconn and maximum php children.
Static SSL also easily passes 6,000 requests per second without stressing the CPU. It's limited by raw bandwidth. Setting up a proxy on localhost and forcing it through proxy_pass did not significantly slow this test down.
Calling the same php file over SSL, however, causes nginx to fully utilize all cores - php takes nothing - and only permits 400 requests/second. Taking CPU usage into account, this is roughly fifty times slower than the above two tests. Disabling gzip provides a ~10% boost in speed. Likewise, I got the same result through proxy_pass.
My server is a quad-core nehalem (E5520 - 2.27 ghz) with 12 gigs of RAM, running Debian Squeeze.
I've also done these tests on a Wheezy server, on the hopes that the issue had been resolved in 1.1.12, but no such luck. I hadn't tweaked its settings to handle this sort of load, so the base php and ssl requests/second are much less dramatic than the production server, but the PHP-over-SSL results are the same.
This seems like a rather enormous discrepancy, but I have no idea where to look. Does anyone have an idea of what might be going on?
Siege reports the same limitation for php over SSL, but because it doesn't support keepalive it blows through sockets too fast to meaningfully test my servers for standard php or ssl calls.
apachebench logs follow.
----
ab -k -c 900 -n 90000 http://amaterasu/test.php 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 amaterasu (be patient) Completed 9000 requests Completed 18000 requests Completed 27000 requests Completed 36000 requests Completed 45000 requests Completed 54000 requests Completed 63000 requests Completed 72000 requests Completed 81000 requests Completed 90000 requests Finished 90000 requests
Server Software: nginx Server Hostname: amaterasu Server Port: 80
Document Path: /test.php Document Length: 24 bytes
Concurrency Level: 900 Time taken for tests: 14.159 seconds Complete requests: 90000 Failed requests: 5754 (Connect: 0, Receive: 0, Length: 5754, Exceptions: 0) Write errors: 0 Keep-Alive requests: 0 Total transferred: 14577071 bytes HTML transferred: 2157071 bytes Requests per second: 6356.29 [#/sec] (mean) Time per request: 141.592 [ms] (mean) Time per request: 0.157 [ms] (mean, across all concurrent requests) Transfer rate: 1005.38 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 58 61 3.4 61 122 Processing: 59 80 83.6 70 3084 Waiting: 59 78 83.4 69 3083 Total: 118 141 83.8 131 3145
Percentage of the requests served within a certain time (ms) 50% 131 66% 139 75% 146 80% 151 90% 168 95% 185 98% 200 99% 210 100% 3145 (longest request)
----
ab -k -c 900 -n 90000 https://amaterasu/robots.txt 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 amaterasu (be patient) Completed 9000 requests Completed 18000 requests Completed 27000 requests Completed 36000 requests Completed 45000 requests Completed 54000 requests Completed 63000 requests Completed 72000 requests Completed 81000 requests Completed 90000 requests Finished 90000 requests
Server Software: nginx Server Hostname: amaterasu Server Port: 443 SSL/TLS Protocol: TLSv1/SSLv3,RC4-SHA,2048,128
Document Path: /robots.txt Document Length: 1063 bytes
Concurrency Level: 900 Time taken for tests: 13.838 seconds Complete requests: 90000 Failed requests: 0 Write errors: 0 Keep-Alive requests: 89708 Total transferred: 118881532 bytes HTML transferred: 95670000 bytes Requests per second: 6503.96 [#/sec] (mean) Time per request: 138.377 [ms] (mean) Time per request: 0.154 [ms] (mean, across all concurrent requests) Transfer rate: 8389.77 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 0 20 222.2 0 3959 Processing: 59 117 177.0 107 3496 Waiting: 59 117 177.0 107 3496 Total: 59 137 351.4 107 4083
Percentage of the requests served within a certain time (ms) 50% 107 66% 110 75% 112 80% 113 90% 117 95% 120 98% 125 99% 1590 100% 4083 (longest request)
----
ab -k -c 900 -n 9000 https://amaterasu/test.php 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 amaterasu (be patient) Completed 900 requests Completed 1800 requests Completed 2700 requests Completed 3600 requests Completed 4500 requests Completed 5400 requests Completed 6300 requests Completed 7200 requests Completed 8100 requests Completed 9000 requests Finished 9000 requests
Server Software: nginx Server Hostname: amaterasu Server Port: 443 SSL/TLS Protocol: TLSv1/SSLv3,RC4-SHA,2048,128
Document Path: /test.php Document Length: 24 bytes
Concurrency Level: 900 Time taken for tests: 22.271 seconds Complete requests: 9000 Failed requests: 445 (Connect: 0, Receive: 0, Length: 445, Exceptions: 0) Write errors: 0 Keep-Alive requests: 0 Total transferred: 1457620 bytes HTML transferred: 215620 bytes Requests per second: 404.11 [#/sec] (mean) Time per request: 2227.101 [ms] (mean) Time per request: 2.475 [ms] (mean, across all concurrent requests) Transfer rate: 63.92 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 181 1033 682.6 885 3609 Processing: 59 1169 655.3 1103 3552 Waiting: 59 1157 661.4 1094 3552 Total: 266 2202 796.6 2223 4715
Percentage of the requests served within a certain time (ms) 50% 2223 66% 2369 75% 2474 80% 2720 90% 3140 95% 3775 98% 3982 99% 4005 100% 4715 (longest request)
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,221673,221673#msg-221673
_______________________________________________ nginx mailing list ngi...@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx





