我正在使用 Heroku 来测试它对 Django 应用程序的好处。
我创建了一个包含两个操作的简单项目:
- 返回简单的hello world
- 生成图像并将其作为响应发送
我曾经siege -c10 -t30s
测试过 Django 开发服务器和 gunicorn(都在 Heroku 上运行)。这些是我的结果:
简单的hello world
- django dev
Lifting the server siege... done.
Transactions: 376 hits
Availability: 100.00 %
Elapsed time: 29.75 secs
Data transferred: 0.00 MB
Response time: 0.29 secs
Transaction rate: 12.64 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 3.65
Successful transactions: 376
Failed transactions: 0
Longest transaction: 0.50
Shortest transaction: 0.26
- 独角兽
Lifting the server siege... done.
Transactions: 357 hits
Availability: 100.00 %
Elapsed time: 29.27 secs
Data transferred: 0.00 MB
Response time: 0.27 secs
Transaction rate: 12.20 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 3.34
Successful transactions: 357
Failed transactions: 0
Longest transaction: 0.34
Shortest transaction: 0.26
生成图像
- django dev
Lifting the server siege... done.
Transactions: 144 hits
Availability: 100.00 %
Elapsed time: 29.91 secs
Data transferred: 0.15 MB
Response time: 1.52 secs
Transaction rate: 4.81 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 7.32
Successful transactions: 144
Failed transactions: 0
Longest transaction: 4.14
Shortest transaction: 1.13
- 独角兽
Lifting the server siege... done.
Transactions: 31 hits
Availability: 100.00 %
Elapsed time: 29.42 secs
Data transferred: 0.05 MB
Response time: 7.39 secs
Transaction rate: 1.05 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 7.78
Successful transactions: 31
Failed transactions: 0
Longest transaction: 9.13
Shortest transaction: 1.19
我用过
- Django 1.4
- Gunicorn 0.14.6
- venv
为什么gunicorn这么慢?
//更新
这两个测试都在 Heroku 环境开发服务器中运行意味着标准 django 服务器 - 它可以由它运行在这里python manage.py runserver
描述。