How do I use mongodb's sharding in a CosmosDB instance

Viewed 1982

I am currently studying using MongoDB for a multi-tenant multi-document type application running on top of a Azure CosmosDB infrastructure.

The partitioning pages on the MSFT documentation (i.e. https://docs.microsoft.com/en-us/azure/cosmos-db/partition-data) explain thoroughly how to implement partitioning strategies if you are using DocumentDB to communicate with Cosmos, but they don't go into any detail as to how I should handle things when using the MongoDB API.

My idea would basically be:

  • A single database
  • A single collection

    Both would map naturally to Cosmos' model for the cheapest experience. I'd aim at 400 RUs as the standard size, as it's the cheapest option.

  • Multiple types of documents, each with a TenantID property that would map to separated tenants in the application with their own (security, user, performance, etc.) concerns, and a DocumentType property to allow for easy filtering.

With the DocumentDB API it'd be natural to use the TenantID as a PartitionKey. With MongoDB API, can I just leave it to Azure? Should I do something 'manually'?

I'm using the C# API, if it matters - I assume the configuration would be similar anywhere else.

1 Answers
Related