Slow runserver start up, how to debug

My project has grown over time, and now when I issue runserver, or when I changed a file, it takes about 5 seconds to get going again. Which is not great when one makes a changed, alt tabs to the browser hits refresh, and it fails, because the server is reloaded.

How can I try figure out what is delaying the project start up?

Python’s -X importtime flag can help you see the time to import various modules. The tool importtime-waterfall can help you visualize its output. The author has a video walking through using it on a real project: how I sped up python by 20ms (intermediate) anthony explains #417 - YouTube

2 Likes