You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My company uses aiohttp for over 100 microservices. Sometimes we have services that are logically not asynchronous, and instead do lots of CPU work for each request. We still like to use aiohttp for these, though; it has a nice, familiar API, and we have lots of resources (libraries, documentation, etc.) for aiohttp that we want to keep using.
We're not sure how to optimize the deployment for this case, though! It seems that aiohttp provides us no way of limiting concurrency and we can't find a way to set gunicorn up with the aiohttp worker so that it keeps a backlog of requests to avoid overloading workers and grinding the whole system to a halt. We tried creating a middleware that responds with HTTP 503 if a concurrency limit is reached, but requests are very unevenly distributed by gunicorn and without a backlog system from which workers pick up requests when idle, we end up with way too many 503s.
I think it would be nice to have some notes in the server deployment docs about how to optimally operate a CPU-bound app 🙃
Your environment
kubernetes nginx-ingress-controller
gunicorn 19.9.0
aiohttp server 3.5.4
The text was updated successfully, but these errors were encountered:
GitMate.io thinks the contributor most likely able to help you is @asvetlov.
Possibly related issues are #3454 ([Question] - Eventloop busy with CPU bound operations), #2638 (There is no way to set limit size for response.read()), #3274 (1K Request can't be finished in a simultaneous way in aiohttp), #2224 (aiohttp.TCPConnector()), and #2320 (aiohttp-jinja2).
I would like a request backlog that aiohttp workers take requests from one by one instead of all the workers just trying to process unlimited requests (they can take more while the request body is being read asynchronously) and therefore oversubscribing. Setting a backend connection limit on HAProxy to 1 or 2 might be the solution: https://github.com/jcmoraisjr/haproxy-ingress#connection
Long story short
My company uses aiohttp for over 100 microservices. Sometimes we have services that are logically not asynchronous, and instead do lots of CPU work for each request. We still like to use aiohttp for these, though; it has a nice, familiar API, and we have lots of resources (libraries, documentation, etc.) for aiohttp that we want to keep using.
We're not sure how to optimize the deployment for this case, though! It seems that aiohttp provides us no way of limiting concurrency and we can't find a way to set gunicorn up with the aiohttp worker so that it keeps a backlog of requests to avoid overloading workers and grinding the whole system to a halt. We tried creating a middleware that responds with HTTP 503 if a concurrency limit is reached, but requests are very unevenly distributed by gunicorn and without a backlog system from which workers pick up requests when idle, we end up with way too many 503s.
I think it would be nice to have some notes in the server deployment docs about how to optimally operate a CPU-bound app 🙃
Your environment
The text was updated successfully, but these errors were encountered: