admin管理员组

文章数量:1401291

I can't find a way to serve our large Django application using all three of preload, ASGI, and SO_REUSEPORT.

Without preload and fork we use much more memory (gigabytes).

Without ASGI we can't serve websockets (and starting another server just for websockets would violate our memory constraints).

Without SO_REUSEPORT we can run multiple preloaded/forked workers but traffic biases heavily (70%) to one worker, negating much of the benefit.

We currently use gunicorn + uvicorn workers to achieve preload + ASGI. Gunicorn has an unreleased reuse_port mode that doesn't seem to do anything when using gunicorn + uvicorn.

We looked at using granian or uvicorn itself as the process manager, but neither support preload/fork and so won't work due to our memory constraints.

I can't find a way to serve our large Django application using all three of preload, ASGI, and SO_REUSEPORT.

Without preload and fork we use much more memory (gigabytes).

Without ASGI we can't serve websockets (and starting another server just for websockets would violate our memory constraints).

Without SO_REUSEPORT we can run multiple preloaded/forked workers but traffic biases heavily (70%) to one worker, negating much of the benefit.

We currently use gunicorn + uvicorn workers to achieve preload + ASGI. Gunicorn has an unreleased reuse_port mode that doesn't seem to do anything when using gunicorn + uvicorn.

We looked at using granian or uvicorn itself as the process manager, but neither support preload/fork and so won't work due to our memory constraints.

Share Improve this question edited Mar 23 at 4:45 Beau asked Mar 23 at 4:36 BeauBeau 11.4k8 gold badges46 silver badges38 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It turns out gunicorn HEAD + uvicorn worker does work with reuse_port=True, so it is possible to achieve all three of ASGI, preload, and SO_REUSEPORT. When you test your setup ensure that you turn off HTTP keepalives or you will bias to one worker for that reason, which is why I initially thought the new reuse_port=True option did not work.

本文标签: