We're building an ASGI app using fastapi, uvicorn, sqlalchemy and PostgreSQL. The question is: how should we set pool_size
in create_async_engine
to not make it a bottleneck comparing to a WSGI app with multiple workers?
As far as I understand, in a WSGI app if we run N
processes with M
threads each (and pool_size=M
) we'll get at most N * M
connections. But what about ASGI (if we have a single process) - how many connections can be opened? Also pool_size
(since we create only one AsyncEngine
per process)? Then we should set it as pool_size=N * M
?
And, if we simply increase this number, than we'll be able to make more simultaneous await
able requests to the database, right?
What is the intuition behind it?
Thanks in advance!