我正在使用 Heroku 来测试它对于 Django 应用程序的效果如何。

我创建了一个简单的项目,有两个操作:

  1. 返回简单的你好世界
  2. 生成图像并将其作为响应发送

我用了 siege -c10 -t30s 测试 Django 开发服务器和 Gunicorn(都在 Heroku 上运行)。这些是我的结果:

简单的你好世界
- Django 开发

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 开发

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

我用了
- 姜戈 1.4
- 枪兽 0.14.6
- 维尼夫

为什么gunicorn这么慢?

//更新
这两种测试都在Heroku Envirenment Dev服务器中进行,表示标准Django服务器 - 可以通过 python manage.py runserver 它被描述 这里.

有帮助吗?

解决方案

设置一样吗?Django 1.4 开发服务器默认是多线程的,gunicorn 默认配置中只有 1 个同步工作线程。

其他提示

你必须设置 应用程序分析 深入了解问题的具体位置。

也许您的互联网连接速度是一个瓶颈?从 Heroku 下载数据显然比通过 localhost 移动数据慢(我假设 django 开发服务器在 localhost 运行)。这可以解释为什么 Heroku 的小响应(hellowords)基准同样快,而大响应(图像)基准却很慢。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top