Opened 20 months ago
Closed 20 months ago
#34442 closed Bug (needsinfo)
runserver is slow to accept http connexions when running on 0.0.0.0
Reported by: | Arthur | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 4.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When running python manage.py runserver
on macOS, a decently sized project takes about 1 second to startup and respond to requests (based on the first access log I can see).
However, when running python manage.py runserver 0.0.0.0:8000
, the server will appear to have started, but will only start responding to requests 7/8 seconds later.
I've been able to consistently reproduce the bug on a freshly installed project aswell (django-admin startproject timings_test
) :
- On 127.0.0.1:8000, the app will start in (08:42:11 - 08:42:11) less than a second
- On 0.0.0.0:8000, the app will start in (08:42:32 - 08:42:26) approximately 6 seconds
bash-3.2$ cd $(mktemp -d) bash-3.2$ django-admin startproject timings_test bash-3.2$ cd timings_test/ bash-3.2$ # I'll now refresh my web browser, pay close attention to the timings bash-3.2$ python3 manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. March 28, 2023 - 08:42:11 Django version 4.1.7, using settings 'timings_test.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Not Found: /__reload__/events/ [28/Mar/2023 08:42:11] "GET /__reload__/events/ HTTP/1.1" 404 2137 [28/Mar/2023 08:42:12] "GET / HTTP/1.1" 200 10681 [28/Mar/2023 08:42:12] "GET /static/admin/css/fonts.css HTTP/1.1" 304 0 [28/Mar/2023 08:42:12] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 304 0 [28/Mar/2023 08:42:12] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 304 0 [28/Mar/2023 08:42:12] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 304 0 Not Found: /favicon.ico [28/Mar/2023 08:42:12] "GET /favicon.ico HTTP/1.1" 404 2116 [28/Mar/2023 08:42:12,122] - Broken pipe from ('127.0.0.1', 54544) [28/Mar/2023 08:42:12] "GET / HTTP/1.1" 200 10681 Not Found: /__reload__/events/ [28/Mar/2023 08:42:14] "GET /__reload__/events/ HTTP/1.1" 404 2137 Not Found: /__reload__/events/ [28/Mar/2023 08:42:17] "GET /__reload__/events/ HTTP/1.1" 404 2137 ^Cbash-3.2$ python3 manage.py runserver 0.0.0.0:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. March 28, 2023 - 08:42:26 Django version 4.1.7, using settings 'timings_test.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C. [28/Mar/2023 08:42:32] "GET / HTTP/1.1" 200 10681 Not Found: /__reload__/events/ [28/Mar/2023 08:42:32] "GET /__reload__/events/ HTTP/1.1" 404 2137 Not Found: /__reload__/events/
Change History (4)
comment:1 by , 20 months ago
comment:2 by , 20 months ago
Component: | Uncategorized → Core (Management commands) |
---|---|
Resolution: | → needsinfo |
Status: | new → closed |
Hi, I don't think you've explained the issue in enough detail to confirm a bug in Django. Please reopen the ticket if you can debug your issue and provide details about why and where Django is at fault. This looks like an issue in your local OS/network configuration, not Django itself.
comment:3 by , 20 months ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
Hi, I doubt it is my OS fault :
- I'm not the only one with the bug (as can be seen here)
- The flask example app started with
flask --app hello run --host 0.0.0.0 --port 8000
will respond in less than a second, so I cannot reproduce the bug with something that's "not django".
I am currently attempting to bisect the bug, but I'd need a failing test first.
comment:4 by , 20 months ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
So ... "Please reopen the ticket if you can debug your issue and provide details about why and where Django is at fault.". Also, I cannot reproduce this behavior on Linux.
I've found traces of this bug from 2020 here.
What I've tried so far :
-X importime
to the startup command : the imports mostly finish in under a second, beforeYou have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
gets printed to the console.Just before the request gets processed, you'll see the following lines :
Quit the server with CONTROL-C.
gets printed : only stops in StatReloader.tick(), so it's probably a threading issue (?)