[Python] How can I maintain an async CosmosDB connection pool in a FastAPI app?

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have a FastAPI app that uses the azure-cosmos library to store data in a CosmosDB. I'm expecting to have a ton of traffic, so I want to create a pool of async CosmosDB clients.

    Is that something the azure-cosmos library supports? I can't seem to find any examples of using a connection pool for Cosmos DB. Does it even make sense to have a pool of async CosmosDB clients? Or can one connection handle massive amounts of traffic?

    If azure-cosmos has no direct support for connection pools, but it makes sense to have a pool, is there a generic library that can assist with maintaining a pool of connections?

    Continue reading...

Compartilhe esta Página