[Django] #34442: runserver is slow to accept http connexions when running on 0.0.0.0

8 views
Skip to first unread message

Django

unread,
Mar 28, 2023, 4:46:18 AM3/28/23
to django-...@googlegroups.com
#34442: runserver is slow to accept http connexions when running on 0.0.0.0
-----------------------------------------+------------------------
Reporter: Arthur | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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/

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34442>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 28, 2023, 4:56:14 AM3/28/23
to django-...@googlegroups.com
#34442: runserver is slow to accept http connexions when running on 0.0.0.0
-------------------------------+--------------------------------------

Reporter: Arthur | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Arthur):

I've found traces of this bug from 2020
[https://stackoverflow.com/a/61732944/3738545 here].

What I've tried so far :

- Adding `-X importime` to the startup command : the imports mostly finish
in under a second, before `You 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 :
{{{
import time: 245 | 245 | stringprep
import time: 435 | 680 | encodings.idna
import time: 520 | 520 |
django.contrib.messages.storage.cookie
import time: 241 | 241 |
django.contrib.messages.storage.session
[28/Mar/2023 08:47:55] "GET / HTTP/1.1" 200 10681
}}}

- Running cProfile : couldn't find the right incantation to make it accept
arguments.
- Pause the program in PyCharm debugger after `Quit the server with
CONTROL-C.` gets printed : only stops in StatReloader.tick(), so it's
probably a threading issue (?)
- Searching for issues here : nothing found about this.

--
Ticket URL: <https://code.djangoproject.com/ticket/34442#comment:1>

Django

unread,
Mar 28, 2023, 5:03:06 AM3/28/23
to django-...@googlegroups.com
#34442: runserver is slow to accept http connexions when running on 0.0.0.0
-------------------------------------+-------------------------------------
Reporter: Arthur | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: 4.1
commands) |
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo
* component: Uncategorized => Core (Management commands)


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34442#comment:2>

Django

unread,
Mar 28, 2023, 5:09:02 AM3/28/23
to django-...@googlegroups.com
#34442: runserver is slow to accept http connexions when running on 0.0.0.0
-------------------------------------+-------------------------------------
Reporter: Arthur | Owner: nobody
Type: Bug | Status: new

Component: Core (Management | Version: 4.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Arthur):

* status: closed => new
* resolution: needsinfo =>


Comment:

Hi, I doubt it is my OS fault :

- I'm not the only one with the bug (as can be seen
[https://stackoverflow.com/a/61732944/3738545 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34442#comment:3>

Django

unread,
Mar 28, 2023, 5:17:47 AM3/28/23
to django-...@googlegroups.com
#34442: runserver is slow to accept http connexions when running on 0.0.0.0
-------------------------------------+-------------------------------------
Reporter: Arthur | Owner: nobody
Type: Bug | Status: closed

Component: Core (Management | Version: 4.1
commands) |
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34442#comment:4>

Reply all
Reply to author
Forward
0 new messages