Search code examples
azureazure-cosmosdb

Should we create one Azure CosmosDB per web application or multiple ones?


I setup a web app with Azure cosmos db. I came across that we have a limit on the number of containers per DB. Now it is 25 containers when we have shared throughput. What is the best practice here:

  1. Creating multiple databases per application although the app is not microservices.
  2. User serverless cosmos db
  3. Put the throughput on the container level.

please advise.


Solution

  • I have a container for each entity like Organizations and Users... So the containers number reaches this limit easily.

    I think you need to rethink you design. From the docs:

    A container is a schema-agnostic container of items. Items in a container can have arbitrary schemas. For example, an item that represents a person and an item that represents an automobile can be placed in the same container. By default, all items that you add to a container are automatically indexed without requiring explicit index or schema management. You can customize the indexing behavior by configuring the indexing policy on a container.

    Do not fall into the trap of trying to map a relational database schema to the resource model of Cosmos DB. Do not think of a container as a table. Have you read the modeling guide already?