Resources:
1, Backpressure explained — the resisted flow of data through software
2, Flask Author: I'm not feeling the async pressure
3, Answer from Starlette author: Back pressure? :
However network backpressure isn't actually the only thing we'd like to have in place here. We also want to ensure resource limiting at any potential bottlenecks. The most notable case here would be the number of available database connections.
Uvicorn currently allows you to set a --limit-concurrency
which hard-limits the maximum number of allowable tasks which may be running before 503's will be returned. In the most constrained case you could just set this based on the number of available database connections.
4, Answer from FastAPI: Back pressure? :
the author of starlette has been aware of this issue for (at least) going on two years so I don't think there is any reason to panic
... in practice you can usually prevent backpressure issues by just using a rate-limiting load balancer and a good auto-scaling policy. This won't handle all cases, and won't save you from particularly bad design choices, but for 99% of deployed python applications this would already be overkill.
Normally, nginx is supposed to control the backpressure for your backend ...
6, Pymongo's connection pool size
maxPoolSize (optional): The maximum allowable number of concurrent connections to each connected server. Requests to a server will block if there are maxPoolSize outstanding connections to the requested server. Defaults to 100. Cannot be 0.