Azure Cosmos DB Emulator and Production Account: Partition Key and Consistency Interoperability
0 reputation · 05 Sept 2020, 15:34 UTC
0 reputation · 05 Sept 2020, 15:34 UTC
Designing an application against Azure Cosmos DB requires understanding where the local emulator and a provisioned production account diverge. The emulator defaults to Session consistency, while production accounts support Strong, BoundedStaleness, Session, ConsistentPrefix, and Eventual consistency. The emulator may also handle partition key routing differently, potentially accepting query patterns that a production account enforces more strictly, and it does not fully replicate production network isolation or request unit throttling behavior.
The uncertainty is whether these differences are documented development conveniences or behavioral gaps that demand separate validation. A query pattern or consistency setting validated locally might behave differently once deployed, but the exact boundary between supported emulator behavior and production enforcement is not always clear.
Assuming the Core (SQL) API and a current emulator release, are partition key routing requirements and consistency guarantees enforced identically across both environments? Which specific divergences—such as cross-partition query limits or RU consumption patterns—are known to differ and require explicit production testing? What verification approach confirms that a locally validated configuration will maintain the same routing and consistency constraints in a production account?
35775 reputation · 05 Sept 2020, 15:56 UTC
For the Core (SQL) API with a current emulator release, partition key routing and consistency enforcement are not enforced identically across the emulator and production account. The emulator provides development convenience but does not replicate production network isolation, RU throttling, or multi-region consistency nuances.
Both environments enforce the same hard limits: max 100 items per partition and max 4MB result set. These are not a source of divergence.
EnablePartitionKeyRerouting emulator flag to mirror production routing behavior, then validate consistency outcomes.The emulator is a development convenience, not a production replica. Queries validated locally must undergo explicit production testing for RU efficiency, consistency behavior, and partition routing. The single missing diagnostic detail that would refine this guidance is: what specific query patterns or consistency settings are you planning to use?
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 05 Sept 2020, 18:38 UTC
One critical divergence to track is that the emulator does not simulate production-grade throughput throttling. While a production account will return 429 (Too Many Requests) when Request Unit (RU) limits are exceeded, the emulator typically allows requests to proceed regardless of the configured throughput.
To bridge this gap, focus on the x-ms-request-charge response header. While the emulator's RU calculations are approximations and should not be used for final capacity planning, comparing this header across both environments can highlight inefficient query patterns—such as unexpected cross-partition scans—that would trigger throttling in production.