Exceedingly slow response time for HTTP requests
See original GitHub issueI’m running a very simple (backend-wise) app with Daphne 2.0 as the app server. The app is hosted on Heroku. I recently noticed that HTTP requests on the live webpage are really slow when using Daphne.
I ran some speed tests for Daphne vs. Gunicorn. The web worker run command was the only thing I changed between tests.
My routing.py
file:
application = ProtocolTypeRouter({
'websocket': AuthMiddlewareStack(
URLRouter([
url('^chat/stream/$', ChatbotConsumer),
]),
),
})
However, keep in mind that I never triggered the /chat/stream/
endpoint when running these tests, so requests were all HTTP. As I understand it, leaving 'http'
unrouted defaults to using Django’s usual method of handing HTTP requests.
For a web worker using daphne myproject.asgi:application -b 0.0.0.0 -p $PORT
:
For the exact same app, using gunicorn myproject.wsgi
:
Notice the extreme disparity between the two: 2000 ms vs. 100 ms for small static files. The call to /app-data
simply loads user-based information using the Django ORM.
Some Heroku metrics, tested by clearing the cache and refreshing the page very five minutes. Daphne is on the left and right, Gunicorn in the middle.
I couldn’t definitively determine if the app was also more likely to have a high Dyno Load when using Daphne, but that seemed to be the case. There’s no memory issue; memory usage was slightly lower for Daphne than Gunicorn.
Any ideas?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (5 by maintainers)
@Zarathustra2 It should be fixed in the master branch of channels_redis, just waiting to make sure it’s stable before I do a release. You can use that version and test it out if you want.
@d6tdev @michaelhays - can you guys kindly share some of your local and Heroku settings that worked eventually?
I’m expriencing slowness on both when Debug=False