question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exceedingly slow response time for HTTP requests

See original GitHub issue

I’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:

daphne waterfall

For the exact same app, using gunicorn myproject.wsgi:

gunicorn waterfall

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.

selection_014

selection_015

selection_013

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:closed
  • Created 5 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
andrewgodwincommented, Apr 25, 2018

@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.

0reactions
SHxKMcommented, Jul 10, 2018

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

8 Ways to Effectively Reduce Server Response Time
Reducing your web server response time can boost your website performance. Learn how to reduce server response time with this guide.
Read more >
Analysis of HTTP Performance Problems
Latency problems are caused by opening a single connection per request, through connection setup and slow-start costs. Further avoidable latency is incurred due ......
Read more >
Best Practices to avoiding slow API response time
We usually recommend making them every 5 minutes to immediately get the latest updates and have them persisted immediately on your database. In ......
Read more >
Python requests is slow and takes very long to complete HTTP ...
The server response is incorrectly formatted, leading to parsing problems. You can check this by not reading the response you receive from the ......
Read more >
HTTPS response times very slow - TechNet - Microsoft
I think you have found out the reason for slow HTTPS response on that two machines ---they send unauthenticated request for the CRL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found