所以,我有一个简单的Flask API应用程序,运行在gunicorn运行龙卷风工作者.gunicorn命令行是:
gunicorn -w 64 --backlog 2048 --keep-alive 5 -k tornado -b 0.0.0.0:5005 --pid /tmp/gunicorn_api.pid api:APP
Run Code Online (Sandbox Code Playgroud)
当我从另一台服务器上直接针对gunicorn运行Apache Benchmark时,以下是相关结果:
ab -n 1000 -c 1000 'http://****:5005/v1/location/info?location=448&ticket=55384&details=true&format=json&key=****&use_cached=true'
Requests per second: 2823.71 [#/sec] (mean)
Time per request: 354.144 [ms] (mean)
Time per request: 0.354 [ms] (mean, across all concurrent requests)
Transfer rate: 2669.29 [Kbytes/sec] received
Run Code Online (Sandbox Code Playgroud)
因此,我们的性能接近3k reqs/sec.
现在,我需要SSL.所以我正在运行nginx作为反向代理.以下是同一服务器上针对nginx的相同基准测试:
ab -n 1000 -c 1000 'https://****/v1/location/info?location=448&ticket=55384&details=true&format=json&key=****&use_cached=true'
Requests per second: 355.16 [#/sec] (mean)
Time per request: 2815.621 [ms] (mean)
Time per request: 2.816 [ms] (mean, across all …Run Code Online (Sandbox Code Playgroud)