Soru

Zorluk: OrtaSet Consistency Levels for Azure Cosmos DB

A gaming platform uses Azure Cosmos DB API for NoSQL to store player profiles and game state. The database account has a single write region in East US and a read replica in West US. Players connect to the game via stateless Web APIs running in both regions. The platform must ensure that when a player updates their profile, they immediately see their own updates on subsequent page refreshes, even if their requests are routed to different instances of the Web API. The client application retrieves and passes the SDK session token between requests. Other players can tolerate a delay in seeing these updates. Which consistency level should you configure for the Azure Cosmos DB account to meet these requirements with the lowest Request Unit (RU) cost?

  1. A
    Strong
  2. B
    Bounded Staleness
  3. SessionCevap
  4. D
    Consistent Prefix

Cevap

Session consistency is the optimal choice because it guarantees read-your-own-writes when the session token is passed between stateless instances, while maintaining a read cost of 1 RU1\text{ RU} and minimal latency.
Session consistency provides the required read-your-own-writes guarantee within a session. Because the client application retrieves and passes the SDK session token between stateless Web API instances, the session context is preserved. This level costs 1 RU1\text{ RU} for reads, which satisfies the requirement for the lowest RU cost.

Adım Adım Çözüm

1
Analyze the requirements for read consistency and cost.
The application requires 'read-your-own-writes' consistency for individual players (updating a profile and immediately seeing it on refresh) with the lowest possible Request Unit (RU) cost.
This narrows the choices down to levels that support read-your-own-writes (Session, Bounded Staleness, Strong) and compares their RU costs (Session is 1 RU1\text{ RU}, others are 2 RUs2\text{ RUs}).
2
Evaluate the role of the session token and stateless Web API instances.
Since the client application explicitly retrieves and passes the Cosmos DB SDK session token between stateless Web API requests, Session consistency can span these stateless instances and guarantee read-your-own-writes.
Session consistency is scoped to the client session. Passing the token allows different client instances to share the same session context, avoiding the need to upgrade to Strong consistency.
3
Select the level that satisfies the consistency requirement with the lowest RU cost.
Session consistency satisfies the consistency requirement and costs 1 RU1\text{ RU} per read, whereas Strong and Bounded Staleness cost 2 RUs2\text{ RUs}.
Selecting Session consistency minimizes request costs and latency while fully meeting the functional requirements.

Anahtar Kavram

Azure Cosmos DB consistency levels and session token management
Tahmini Süre:1m 30s
Bu soruyu puanla