πŸ”’ Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901 aws-aif-c01
Guided DP-420 Domain 4
Domain 4 β€” Module 3 of 4 75%
20 of 28 overall

DP-420 Study Guide

Domain 1: Design and Implement Data Models

  • Cosmos DB β€” The Big Picture Free
  • Designing Your Data Model Free
  • Partition Key Strategy Free
  • Synthetic and Hierarchical Partition Keys Free
  • Relationships β€” Embedding vs Referencing Free
  • SDK Connectivity and Client Configuration Free
  • SDK CRUD Operations and Transactions Free
  • SQL Queries in Cosmos DB Free
  • SDK Query Pagination and LINQ Free
  • Server-Side Programming Free
  • Transactions in Practice Free

Domain 2: Design and Implement Data Distribution

  • Global Replication and Failover
  • Consistency Levels: Five Choices, Real Trade-Offs
  • Multi-Region Writes and Conflict Resolution

Domain 3: Integrate and Move Data

  • Change Feed with Azure Functions and Processors
  • Analytical Workloads: Synapse Link and Fabric Mirroring
  • Data Movement: ADF, Kafka, and Spark Connectors

Domain 4: Optimize Query and Operation Performance

  • Indexing Policies: Range, Spatial, and Composite
  • Request Units and Query Cost Optimization
  • Integrated Cache and Dedicated Gateway
  • Change Feed Patterns: Materialized Views and Estimator

Domain 5: Maintain an Azure Cosmos DB Solution

  • Monitoring: Metrics, Logs, and Alerts
  • Backup and Restore: Periodic vs Continuous
  • Network Security: Firewalls, VNets, and Private Endpoints
  • Data Security: Encryption, Keys, and RBAC
  • Cost Optimization: Throughput Modes and RU Strategy
  • DevOps: Infrastructure as Code and Deployments
  • Exam Strategy and Cross-Domain Review

DP-420 Study Guide

Domain 1: Design and Implement Data Models

  • Cosmos DB β€” The Big Picture Free
  • Designing Your Data Model Free
  • Partition Key Strategy Free
  • Synthetic and Hierarchical Partition Keys Free
  • Relationships β€” Embedding vs Referencing Free
  • SDK Connectivity and Client Configuration Free
  • SDK CRUD Operations and Transactions Free
  • SQL Queries in Cosmos DB Free
  • SDK Query Pagination and LINQ Free
  • Server-Side Programming Free
  • Transactions in Practice Free

Domain 2: Design and Implement Data Distribution

  • Global Replication and Failover
  • Consistency Levels: Five Choices, Real Trade-Offs
  • Multi-Region Writes and Conflict Resolution

Domain 3: Integrate and Move Data

  • Change Feed with Azure Functions and Processors
  • Analytical Workloads: Synapse Link and Fabric Mirroring
  • Data Movement: ADF, Kafka, and Spark Connectors

Domain 4: Optimize Query and Operation Performance

  • Indexing Policies: Range, Spatial, and Composite
  • Request Units and Query Cost Optimization
  • Integrated Cache and Dedicated Gateway
  • Change Feed Patterns: Materialized Views and Estimator

Domain 5: Maintain an Azure Cosmos DB Solution

  • Monitoring: Metrics, Logs, and Alerts
  • Backup and Restore: Periodic vs Continuous
  • Network Security: Firewalls, VNets, and Private Endpoints
  • Data Security: Encryption, Keys, and RBAC
  • Cost Optimization: Throughput Modes and RU Strategy
  • DevOps: Infrastructure as Code and Deployments
  • Exam Strategy and Cross-Domain Review
Domain 4: Optimize Query and Operation Performance Premium ⏱ ~12 min read

Integrated Cache and Dedicated Gateway

Implement the Cosmos DB integrated cache with a dedicated gateway cluster to reduce RU consumption for read-heavy workloads β€” including staleness configuration and when to use it.

What is the integrated cache?

β˜• Simple explanation

Think of it as a fast shelf next to the warehouse loading dock. Instead of walking to the back of the warehouse every time someone asks for the same product, you keep popular items on the shelf near the door. Much faster, and the warehouse workers aren’t interrupted.

The integrated cache stores frequently-read items in memory at the gateway so repeated reads don’t consume RU/s from the backend.

The integrated cache is a server-side, in-memory cache built into the Cosmos DB dedicated gateway. Key characteristics:

  • Server-side: No client-side caching library needed β€” it’s transparent to your application.
  • RU savings: Cache hits don’t consume provisioned RU/s.
  • Two types: Caches both point reads and query results.
  • Staleness control: You configure how stale cached data can be via MaxIntegratedCacheStaleness.
  • Requires: Dedicated gateway cluster + gateway connection mode.

Amara’s read-heavy dashboard

πŸ“‘ Amara at SensorFlow built a dashboard that shows the latest readings for 10,000 devices. The dashboard auto-refreshes every 30 seconds. That’s 10,000 point reads every 30 seconds β€” about 333 reads/second, costing ~333 RU/s. Most readings haven’t changed since the last refresh.

With the integrated cache, repeat reads of unchanged data are served from cache at zero RU cost.

How it works

Application
    β”‚
    β–Ό
Dedicated Gateway (with integrated cache)
    β”‚
    β”œβ”€β”€ Cache HIT  β†’ return from memory (0 RU)
    β”‚
    └── Cache MISS β†’ fetch from backend (normal RU cost)
                     β†’ store in cache for next request

Setting up the dedicated gateway

Step 1: Provision a dedicated gateway cluster:

az cosmosdb service create \
  --resource-group rg-sensorflow \
  --account-name sensorflow-cosmos \
  --name "SqlDedicatedGateway" \
  --kind "SqlDedicatedGateway" \
  --count 3 \
  --size "Cosmos.D4s"

Step 2: Connect via gateway mode (required for cache):

CosmosClientOptions options = new CosmosClientOptions
{
    // Use the dedicated gateway endpoint, not the standard endpoint
    ConnectionMode = ConnectionMode.Gateway
};

// The dedicated gateway endpoint follows this pattern:
// https://<account-name>.sqlx.cosmos.azure.com
CosmosClient client = new CosmosClient(
    "https://sensorflow-cosmos.sqlx.cosmos.azure.com",
    key,
    options
);
πŸ’‘ Exam tip: gateway mode is mandatory

The integrated cache only works with ConnectionMode.Gateway via the dedicated gateway endpoint (.sqlx.cosmos.azure.com). If you use ConnectionMode.Direct (the default and recommended for production), the cache is bypassed entirely.

This is a key exam trap: direct mode has lower latency but skips the cache. Gateway mode adds a network hop but enables caching. Choose based on your read pattern.

MaxIntegratedCacheStaleness

Control how stale cached data can be:

// Cache results for up to 2 minutes
FeedIterator<SensorReading> iterator = container.GetItemQueryIterator<SensorReading>(
    query,
    requestOptions: new QueryRequestOptions
    {
        DedicatedGatewayRequestOptions = new DedicatedGatewayRequestOptions
        {
            MaxIntegratedCacheStaleness = TimeSpan.FromMinutes(2)
        }
    }
);
Staleness ValueBehaviour
TimeSpan.ZeroAlways fetch fresh data (bypass cache)
Small (seconds)Near-real-time with minimal caching benefit
Large (minutes)Higher cache hit rate, more stale data
Not setUses the server default

When to use the integrated cache

ScenarioIntegrated Cache?Why
Read-heavy dashboard with repeated queriesβœ… YesSame data read repeatedly β€” high cache hit rate
IoT ingestion (write-heavy)❌ NoWrites don't benefit from read cache
Unique queries (low repetition)❌ NoLow cache hit rate β€” most reads are cache misses
Session-scoped point readsβœ… YesSame session data read multiple times per session
Serverless accounts❌ NoDedicated gateway not supported on serverless
Applications using Direct mode❌ NoCache requires Gateway mode via dedicated gateway

Limitations

  • Serverless: Not supported on serverless accounts
  • Multi-region writes: Cache is per-gateway, region-local
  • Write-through: Writes always go to the backend β€” cache is read-only
  • Size: Cache size depends on the dedicated gateway SKU
  • Cost: Dedicated gateway cluster has its own pricing (separate from RU/s)

🎬 Video walkthrough

🎬 Video coming soon

Integrated Cache and Dedicated Gateway β€” DP-420 Module 20

Integrated Cache and Dedicated Gateway β€” DP-420 Module 20

~12 min

Flashcards

Question

What connection mode is required to use the integrated cache?

Click or press Enter to reveal answer

Answer

Gateway mode via the dedicated gateway endpoint (.sqlx.cosmos.azure.com). Direct mode (the default) bypasses the cache entirely. This is a common exam trap.

Click to flip back

Question

Does a cache hit consume provisioned RU/s?

Click or press Enter to reveal answer

Answer

No β€” cache hits are served from in-memory at the dedicated gateway and consume zero RU/s. Only cache misses incur normal RU charges when fetching from the backend.

Click to flip back

Question

What does MaxIntegratedCacheStaleness control?

Click or press Enter to reveal answer

Answer

How long cached data remains valid before a fresh read from the backend is required. A longer staleness window gives higher cache hit rates but older data. TimeSpan.Zero forces fresh reads every time.

Click to flip back

Knowledge Check

Knowledge Check

Amara's dashboard reads the same 10,000 device readings every 30 seconds. She enables the integrated cache with 2-minute staleness. What happens to RU consumption?

Knowledge Check

A developer enables the integrated cache but sees no RU savings. Their connection string uses the standard endpoint. What's wrong?


Next up: Change Feed Patterns β€” materialized views, denormalization propagation, and the change feed estimator for lag monitoring.

← Previous

Request Units and Query Cost Optimization

Next β†’

Change Feed Patterns: Materialized Views and Estimator

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.