Domain 2 β€” Module 10 of 11 91%
25 of 31 overall
Domain 2: Secure, optimize, and deploy database solutions Free ⏱ ~16 min read

Cost Optimization: Throughput Modes and RU Strategy

Choose between serverless, provisioned manual, and autoscale throughput β€” then apply cost reduction strategies including TTL cleanup, reserved capacity, consistency choices, and indexing optimisation.

The cost equation

Simple explanation

Think of throughput modes like phone plans. Serverless is pay-as-you-go (great for light use, expensive at scale). Provisioned is a fixed plan (predictable cost, wasted if you don’t use it). Autoscale is a plan that flexes between a minimum and maximum (best of both worlds, slightly more expensive at peak).

Marcus’s cost challenge

βš™οΈ Marcus at FinSecure manages three environments with very different patterns:

  • Production: Predictable traffic with a 2Γ— spike during market hours (9am-4pm)
  • Staging: Used 8 hours/day, idle 16 hours
  • Dev/test: Sporadic use, often idle for days

Each environment needs a different throughput strategy.

Throughput modes comparison

AspectServerlessProvisioned (Manual)Autoscale
BillingPer-RU consumedPer-RU/s provisioned (hourly)Per max RU/s used in each hour
Throughput range5,000 RU/s per physical partitionStarts at 400 RU/s; resource minima apply10%–100% of configured max
ScalingAutomatic burstManual adjustmentAutomatic within range
Minimum costNo idle RU charge; stored data is chargedProvisioned RU/s plus storageAt least the 10% RU/s floor plus storage
RegionsSingle region onlyMulti-region supportedMulti-region supported
SLASLA with availability zones (single-region)99.99% / 99.999%99.99% / 99.999%
Logical-partition storageStandard 20 GB per complete keyStandard 20 GB per complete keyStandard 20 GB per complete key
Best forDev/test, low/sporadic trafficPredictable, steady workloadsVariable but somewhat predictable traffic

Serverless deep dive

Serverless pricing:
  - Pay per RU consumed (not provisioned)
  - 5,000 RU/s per physical partition (scales with partitions)
  - Single region only
  - SLA with availability zones in designated regions
  - Standard 20 GB per complete logical-partition key
  - Can convert to provisioned throughput (NoSQL API)

Marcus’s choice: Consider serverless for the sporadic single-region dev/test workload. Idle requests do not reserve RU/s, but stored data still costs money and availability requirements still apply.

Autoscale deep dive

Autoscale example:
  Max RU/s configured: 10,000
  Minimum (10%): 1,000 RU/s
  
  Idle hours: billed at 1,000 RU/s
  Peak hours: scales up to 10,000 RU/s as needed
  
  Hourly billing uses the highest throughput reached in that hour.
  Compare actual hourly demand, topology and current rates with manual throughput.

Marcus’s choice: Autoscale for production β€” handles the 2Γ— market-hours spike automatically.

Exam tip: autoscale minimum is 10%

Autoscale has a 10% throughput floor. If the configured max is 10,000 RU/s, the floor is 1,000 RU/s; a higher peak within the billing hour can increase that hour’s bill. Storage and other applicable charges remain separate. Compare serverless for suitable sporadic single-region workloads rather than assuming it is always cheaper.

The exam tests this: β€œA developer sets autoscale max to 100,000 RU/s. What’s the minimum billed throughput?” β†’ 10,000 RU/s.

Cost factors beyond throughput

FactorCost ImpactOptimisation
Multi-regionProvisioned throughput and storage are charged across configured regions; topology affects ratesChoose regions and write topology from availability and application requirements, then compare actual costs
ConsistencyStrong/Bounded = 2Γ— read RUUse Session for most workloads
IndexingMore indexed paths = higher write RUExclude unused paths
Document sizeLarger docs = more RU per operationKeep documents lean
Cross-partition queriesRequest charge sums the actual work across participating partitionsUse partition-aware queries where the access pattern supports them

TTL for automatic cleanup

TTL (Time to Live) automatically deletes expired documents β€” no background jobs needed:

// Enable TTL on the container (allow per-item TTL)
ContainerProperties props = new ContainerProperties("sessions", "/userId")
{
    DefaultTimeToLive = -1  // container TTL enabled, no default expiry
};

// Set TTL per item (in seconds)
var session = new {
    id = "session-123",
    userId = "user-456",
    data = "...",
    ttl = 3600  // expire after 1 hour
};
Container TTLItem TTLBehaviour
Not setAnyTTL disabled for entire container
-1Not setItems never expire (opt-in per item)
-13600Item expires after 1 hour
86400Not setItems expire after 1 day (container default)
864003600Item expires after 1 hour (item overrides container)

Cost benefit: TTL removes expired items from query results and eventually reclaims their live storage when background deletion runs. Do not assume retained backups or their charges disappear immediately. For provisioned throughput accounts, TTL deletes use leftover RUs not consumed by user requests. For serverless accounts, TTL deletes are charged at the same RU rate as explicit delete operations.

Reserved capacity

Reserved capacity can discount eligible provisioned-throughput charges when a commitment matches a predictable workload. Compare the current offer and utilization rather than memorizing a universal discount:

TermDecision
1 yearCompare the shorter commitment with expected eligible throughput usage
3 yearsEvaluate the longer commitment and the risk of unused reserved capacity

Marcus’s choice: Evaluate a reservation against the predictable eligible baseline and compare how autoscale usage consumes the commitment. Storage and other ineligible charges are separate.

🎬 Video walkthrough

Flashcards

Question

What is the minimum billing for autoscale at max 10,000 RU/s?

Click or press Enter to reveal answer

Question

What are key characteristics of serverless Cosmos DB?

Click or press Enter to reveal answer

Question

Do TTL-expired document deletions consume RU/s?

Click or press Enter to reveal answer

Question

Which consistency levels increase read cost?

Click or press Enter to reveal answer

Knowledge Check

Knowledge Check

Marcus's staging environment must retain multiple regions and needs 5,000 RU/s during active periods, with long idle periods. Which change provides automatic throughput adjustment without removing a required region or manually scheduling throughput changes?

Knowledge Check

For an autoscale resource configured with max 50,000 RU/s, what is the minimum throughput floor?

Knowledge Check

Marcus wants to reduce storage costs for his session data that's only relevant for 24 hours. What should he configure?


Before moving on: Check that capacity, region and retention choices meet the workload requirements, then compare measured usage and current pricing.