Throughput and Consistency in CosmosDB
Syntax
To manage throughput, you can use these Azure Portal pages:
- Scale and Settings page: Use this page to view and configure the provisioned throughput for your Cosmos DB account, as well as define the autoscale settings.
- Service-level agreements page: Use this page to view your Cosmos DB account's service level agreements (SLAs).
- Metrics page: Use this page to analyze your account's request units (RUs) usage.
Example
const database = client.database('mydb');
const container = database.container('mycontainer');
const options = { offerThroughput: 400 };
await container.create({ throughput: 400 });
Output
The output for managing CosmosDB throughput and consistency can vary based on your specific configuration and operations.
Explanation
Throughput in CosmosDB refers to the amount of data that can be read and written to and from the database in a given second. Consistency, on the other hand, refers to the level of agreement between replicas of the data in a distributed system, including how and when those replicas are updated.
By managing throughput and consistency in your CosmosDB instance, you can ensure that your database is well-tuned for your specific use case.
Use
You may want to manage your CosmosDB throughput and consistency in a number of scenarios, including:
- Ensuring that your database can handle the required amount of read and write traffic
- Optimizing the performance of your database
- Balancing the costs of operation with the demands of your application
Important Points
Some important points to keep in mind when managing CosmosDB throughput and consistency include:
- Throughput and consistency can be configured on a per-container basis
- Autoscaling is available to help you manage your throughput automatically based on usage patterns
- Different consistency levels can impact read consistency and availability in different ways
Summary
Throughput and consistency are critical parts of managing your CosmosDB instance. By effectively managing these factors, you can ensure that your database is well-tuned for your specific use case, optimized for performance, and cost-effective to operate.