Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace asyncio event pool with with uvloop #1789

Open
asvishnyakov opened this issue Jan 22, 2025 · 1 comment
Open

Replace asyncio event pool with with uvloop #1789

asvishnyakov opened this issue Jan 22, 2025 · 1 comment
Labels
backend Pertains to the Python backend. enhancement New feature or request needs-triage

Comments

@asvishnyakov
Copy link
Contributor

It seems that, for some reason, you replaced uvloop, which is used by uvicorn by default, with the default asyncio event loop. This is negatively impacts performance:

# Start the server
async def start():

server = uvicorn.Server(config)
await server.serve()
# Run the asyncio event loop instead of uvloop to enable re entrance
asyncio.run(start())

or at least, it feels like performance improved when I replaced this code with the following:

    # Start the server
    uvicorn_config = uvicorn.Config(
        app,
        host=host,
        port=port,
        ws=ws_protocol,
        log_level=log_level,
        ws_per_message_deflate=ws_per_message_deflate,
        ssl_keyfile=ssl_keyfile,
        ssl_certfile=ssl_certfile,
    )
    server = uvicorn.Server(uvicorn_config)
    server.run()

Is this true? If so, is there any reason to keep it that way? Is there a workaround or solution to configure it to use uvloop instead?

@dosubot dosubot bot added backend Pertains to the Python backend. enhancement New feature or request labels Jan 22, 2025
@dokterbob
Copy link
Collaborator

I'd be extremely surprised if there's an objectively measurable change in performance in a single user case, as most modern machines are perfectly capable of relaying short strings of text at 100Mbit+ rates.

Could you provide a benchmark?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Pertains to the Python backend. enhancement New feature or request needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants