Performance degradation for Django with Gunicorn deployed in Heroku

I play with Heroku to check how good this is for Django applications.

I created a simple project with two actions:

  • return of the simple world hello.
  • generate image and send it as response

I used siege -c10 -t30s to test the Django dev and gunicorn server (both were running on Heroku). These are my results:

Simple world greetings
- 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 

- gunicorn

 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 

image generation
- 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 

- gunicorn

 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 

I used - Django 1.4
- Gunicorn 0.14.6
- venv

Why so little machine gun?

// UPDATE
Both tests took place in the environment of Heroku dev server means a standard django server - it can be run python manage.py runserver described here .

+2
source share
3 answers

Are the settings the same? The Django 1.4 dev server has multithreading by default, and in the default configuration of the expander there is only one synchronization desktop.

+4
source

You will need to configure application profiling to get an idea of ​​exactly where the problem is.

+1
source

Maybe your internet connection speed is a bottleneck? Loading data from Heroku is obviously slower than moving through localhost (I assume that the django dev server is running on the local host). This may explain why tests with small answers (hellowords) are equally fast and tests with large answers (images) are slow for Heroku.

+1
source

Source: https://habr.com/ru/post/1438736/


All Articles