Ignorar navegação

Sharing provisioned throughput across multiple containers in Azure #CosmosDB

Postado em 7 maio, 2018

GPM, Azure Cosmos DB

Azure Cosmos DB is Microsoft's globally distributed, multi-model database service for mission-critical applications. Azure Cosmos DB provides turnkey global distribution, elastic scaling of throughput and storage worldwide, single-digit millisecond latencies at the 99th percentile, five well-defined consistency models and guaranteed high availability, all backed by industry-leading comprehensive SLAs. Azure Cosmos DB automatically indexes all your data without requiring you to deal with schema or index management. It is a multi-model service that supports document, key-value, graph and column-family data models and exposes wire-compatible APIs for MongoDB, Apache Cassandra and Apache Gremlin, in addition to a native SQL dialect. As a natively born in the cloud service, Azure Cosmos DB is carefully engineered with multi-tenancy and global distribution from the ground up.

Unlimited flexibility, elasticity and scalability

Azure Cosmos DB offers a provisioned throughput model, where you configure throughput that you need and pay only for the throughput that you have reserved. As a multi-model database, depending on your choice of data model and API, Azure Cosmos DB allows you to create collections, tables or graphs – they all map internally to a Cosmos DB container. Azure Cosmos DB will transparently, automatically and elastically scale throughput and storage of its containers, as you programmatically provision more (or less) throughput or as the storage of the container grows (or shrinks). Throughput in Azure Cosmos DB is defined in terms of Request Units or RUs, which is a normalized way of representing throughput in terms of transactions per second across a wide variety of database operations (e.g., insert, replace, upsert, delete, query).

Starting today, in addition to provisioning throughput for an individual container in Azure Cosmos DB, you can provision throughput collectively, for a set of containers as well, which allows those containers to share the provisioned throughput. This dramatically simplifies the capacity planning, since you can now configure provisioned throughput at different granularities based on your data model or application needs. You now have the ability to control cost at different granularities in your application’s data model (e.g., database, collection, table, etc.).

provisioning_set_containers

Setting provisioned throughput at different granularities

For any Cosmos DB database account, at any time, you can programmatically or through the Azure portal:

  • Provision throughput for a container
  • Provision throughput for a set of containers collectively, all of which will share the throughput

Provisioning throughput for individual containers will guarantee the reservation of throughput for that specific Cosmos DB container (i.e., a table or a collection or a graph) backed by the throughput SLA for that container. This allows you to have a fine-grained control over the throughput you want for a container at any given point in time. On the other hand, provisioning throughput on a Cosmos DB database, allows you to share the throughput among all the containers that belong to that database. This allows you to pool the provisioned throughput across a set of containers within a Cosmos DB database. Within a given Cosmos DB database, you can mix and match containers which share the throughput among themselves as well as, specific containers which have been assigned dedicated throughput. Below are some simple rules of thumb to decide on a particular throughput reservation strategy:

Consider provisioning throughput on a Cosmos DB database (containing a set of containers) if,

  • You have a few dozen collections/tables/graphs and want to share throughput across some or all of them.
  • You are migrating from a (single-tenant) database designed to run on IaaS-hosted VMs or on-premises (e.g., NoSQL or relational databases) to Azure Cosmos DB and have many collections/tables/graphs.
  • You want to absorb unplanned spikes in workloads by virtue of pooled throughput at the database level, shared across containers subjected to unexpected spike in workload.
  • Instead of setting specific throughput on individual containers, you care about getting the aggregate throughput across a set of containers within the database - all sharing the throughput within the database.

Consider provisioning throughput on an individual container if,

  • You have a few Cosmos DB containers.
  • You want to control the throughput on a specific container and get the guaranteed throughput on a given container backed by SLA.

As mentioned earlier, Azure Cosmos DB allows you to mix and match the above two strategies, so you can now have a few containers within your Cosmos DB database, which may share the overall throughput provisioned on the database as well as, a few containers (within the same database) which may have dedicated amounts of provisioned throughput.

As shown in the following table, depending on the choice of API, you can provision throughput at different granularities.

image

By provisioning throughput at different granularities, you can now better optimize your costs based on your workloads’ characteristics. As mentioned earlier, you can programmatically and at any time increase (scale-up) or decrease (scale-down) your provisioned throughput for either individual container(s) or collectively across a set of containers to elastically scale as your workload changes and only pay for the throughput you have configured. If your container or a set of containers are distributed across multiple regions, then the throughput you configure on the container or a set of containers is guaranteed to be made available across all regions.

Next steps with Azure Cosmos DB

Up until now, the provisioned throughput model of Azure Cosmos DB allowed developers to provision throughput at a container level only. By providing the capability to configure the provisioned throughput at different granularities, Cosmos DB allows you to easily transition from IaaS-hosted or on-premises NoSQL and relational databases to Azure Cosmos DB in a cost effective manner.

Our mission is to be the most trusted database service in the world and to enable any developer to build amazingly powerful, planet-scale apps more easily. Try out Azure Cosmos DB for free and let us know what you think! If you need any help or have questions or feedback, please reach out to us through askcosmosdb@microsoft.com. Stay up-to-date on the latest Azure Cosmos DB news (#CosmosDB) and features by following us on Twitter @AzureCosmosDB. We are really excited to see what you will build with Azure Cosmos DB!

— Your friends at Azure Cosmos DB @AzureCosmosDB (#CosmosDB)