Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

Why is runserver/daphne so slow?

$
0
0

(tl;dr) I installed django-channels and now my runserver command is very very slow. django-debug-toolbar was sort of the culprit (not really, because it was my own fault)

The problem

I've just started a new project using django-channels . Websockets + channels is incredibly powerful, but I noticed something strange: While running django in debug mode, the development server was incredibly slow (on the average of 60s-90s per response).

After a bit of digging, it seemed that django-debug-toolbar was to blame, so I started turning off different panels to see what was the problem. Long story short: the StaticFilesPanel was taking a long time to generate it's data?

Here's why I'm building a chat app using react, and it's in a django app named chat . I've organized my react app so that it's inside my django app's static directory, e.g. my_project/chat/static/my_react_chat As part of my front end development, I end up with a node_modules directory with lots and lots of stuff. In development, I'm using the default staticfiles finders which will happily search through all of your django app's directories looking for static files. This takes some time when you a billion gigs worth of node modules. Daphne's default timeout is 60s, and those static files finders take longer than that.

So, for the moment, I'll either disable the StaticFilesPanel while I'm working on my react app, or I'll just try to remember to blow away my node_modules directory when I don't need it.

I've probably not got my react development organized quite right when integrating with a django app, but I'm doing what makes sense to me. Perhaps I should see what everyone else is doing. \_(ツ)_/


Viewing all articles
Browse latest Browse all 9596

Trending Articles