-
-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow with Debug=False #1048
Comments
That's strange behaviour indeed. You mention it's slow when "debug is turned on and channels app is installed" - which of these actually causes it? Does it only happen when both are true? Basically, can you fill out the fast/slow for each combination of:
|
So yeah it's installing channels, and running with debug off that causes the slowdown, every other combinations works great. |
OK.
|
Hm, I'm a bit stumped then. Nothing in Channels should be impacting the normal URL path at all, and I definitely have never seen this happen. Looks like everything takes ages to load. Just to check, what are the versions of all the packages you have? And do you have any other apps or middleware that could be interfering? |
I disabled I have the latest version of channels and a lot of other packages that are up to date. |
I have found the reason that this occurs. |
Ah! I would suggest that you have separate local dev settings from deployment settings, in that case, and then you can have it work differently per environment. There should be some articles around for different ways to set that up. |
So I've tried to replicate what's causing this my manually specifying the staticfiles and database attrs. Is there something that channels does to staticfiles that I need to change or add? |
It overrides a few things to make it work, but it shouldn't matter (and you shouldn't be using staticfiles in production, just |
I'm not understanding, I was following this -> So I'm not sure what I'm doing wrong, and how using staticfiles causes the slowdowns |
I don't know what's wrong either, I'm afraid. If the example app serves things quickly it's something else you have installed/configured (since that also uses staticfiles), and I unfortunately don't have the time to help with a detailed dive into why :( |
Ok, so I've tried to use your example app in heroku, and I get the same thing. I deployed it without basically touching it apart from adding heroku config stuff like Whitenoise and django-heroku to set up the environmental variables and DB. I've also disabled the Redis logic so the app doesn't really work, but the admin page takes a considerable time to load just like in my app. https://github.com/dragonbone81/channels-test Sorry for using your time. Maybe if someone else has encountered this they can help out, but I've looked around and I can't find a similar issue. |
Is it ok if the issue is opened again? @andrewgodwin |
Well, an open issue means it is definitely a problem with Channels that can be solved - as in, someone can actively reproduce a bug on a local dev environment and fix it. When you were saying things were slow, was that always on Heroku or on a local dev copy as well? If it's something that only happens on Heroku I'm afraid there's not much I can do; I can't act as their support team if their Python environment is somehow slightly different... |
No I get the same result on my laptop if I use staticfiles with whitenoise and turn debug off. I don't know if this is an explicit issue with channels, but it must be interferering somehow with staticfiles with debug off. If the repo I made with your channels app is run, the issue can be reproduced. |
The slowness comes from |
@andrewgodwin can we reopen this ticket? Seems like @ericls has found the root cause: Channels is breaking Django's API contract which says that a middleware's |
Best to open it as a new ticket - what channels does is still compatible with the API contract, just slower (technically it internally starts a whole new Django stack with each request). I'd class it as an enhancement that we need for speed rather than a bug. |
Thanks @andrewgodwin, we've worked around this by reimplementing |
@sciyoshi Care to elaborate more how you guys solved this? I'm experiencing the same thing on Heroku and it's killing my web-app. |
@typistX - we wrote our own ASGI handler that serves middleware (pretty short, under 100 lines of code), @ericls could give more details about that. There's also a PR in Whitenoise that seems to be similar, maybe you can give that a shot as well. |
Woops, sorry about that. I'm experiencing performance loss on API end-points calls when DEBUG=False as well. Would you have any idea ? |
So I've set up channels, and it works great in debug with websockets connecting and everything is fast.
However as soon as I turn debug=False the speed for any request goes way down (like 5-10 seconds to load the admin page) And as soon as I remove the channels app from installed_apps, the speed is back to normal.
I'm running the server with just the normal (manage.py runserver) as opposed to daphne or something... not sure yet how that works, and I need to limit the workers to only one for now anyways.
Again, it works great with debug on, and with channels app removed, but slows to a crawl when debug is turned on and channels app is installed.
https://github.com/dragonbone81/bobcat-courses-backend
The text was updated successfully, but these errors were encountered: