question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

High CPU usage when using --reload

See original GitHub issue

Using the example code

async def app(scope, receive, send):
    assert scope['type'] == 'http'

    await send({
        'type': 'http.response.start',
        'status': 200,
        'headers': [
            [b'content-type', b'text/plain'],
        ],
    })
    await send({
        'type': 'http.response.body',
        'body': b'Hello, world!',
    })

and running uvicorn main:app, CPU usage is unnoticeable (less than 1% of 1 core). But when running with uvicorn main:app --reload, CPU usage jumps to 54% of 1 core.

Environment: python -V: Python 3.7.2 uvicorn: 0.6.1 uname -a: Linux architect 5.0.4-arch1-1-ARCH #1 SMP PREEMPT Sat Mar 23 21:00:33 UTC 2019 x86_64 GNU/Linux

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:27 (15 by maintainers)

github_iconTop GitHub Comments

9reactions
kevchentwcommented, Aug 6, 2019

I found that there are --reload-dir settings already. By applying app folder, CPU usage significant decrease.

8reactions
uSpikecommented, Jun 10, 2020

I had this issue with my project.

With only --reload, it was eating up 25% of a 4 core CPU watching 8135 files in my venv/ folder.

By adding --reload-dir src/ where src/ contains my application, the CPU issue went away completely.

Maybe a decent solution is to have uvicorn ignore common virtualenv directory names, like venv/ .venv/, etc?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix High CPU Usage - Intel
Find out all the reasons why your PC displays high CPU usage. Our step-by-step guide will show you how to fix your CPU...
Read more >
Desktop & Apps keep Refreshing, CPU usage going crazy
Hi, for about 2 weeks I my Windows 10 has been having the following issue: The desktop disappears and reappears frequently (as if...
Read more >
CPU usage near 100% when loading/reloading a tab in the ...
CPU usage should show close to 100% while the browser is focused on the tab ... or reloading in the background should load...
Read more >
High CPU usage during UI reload - Elder Scrolls Online forums
Sounds like a RAM or VRAM issue to me. If you have 8 gb or less RAM and keep lots of programs open...
Read more >
CPU Usage high on one core. Reload didn't fix [SOLVED]
It could be a problem of a very high squid hard disk cache. On start of squid this can cause a high CPU...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found