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
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
| Aspect | Serverless | Provisioned (Manual) | Autoscale |
|---|---|---|---|
| Billing | Per-RU consumed | Per-RU/s provisioned (hourly) | Per max RU/s used in each hour |
| Throughput range | 5,000 RU/s per physical partition | Starts at 400 RU/s; resource minima apply | 10%β100% of configured max |
| Scaling | Automatic burst | Manual adjustment | Automatic within range |
| Minimum cost | No idle RU charge; stored data is charged | Provisioned RU/s plus storage | At least the 10% RU/s floor plus storage |
| Regions | Single region only | Multi-region supported | Multi-region supported |
| SLA | SLA with availability zones (single-region) | 99.99% / 99.999% | 99.99% / 99.999% |
| Logical-partition storage | Standard 20 GB per complete key | Standard 20 GB per complete key | Standard 20 GB per complete key |
| Best for | Dev/test, low/sporadic traffic | Predictable, steady workloads | Variable 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
| Factor | Cost Impact | Optimisation |
|---|---|---|
| Multi-region | Provisioned throughput and storage are charged across configured regions; topology affects rates | Choose regions and write topology from availability and application requirements, then compare actual costs |
| Consistency | Strong/Bounded = 2Γ read RU | Use Session for most workloads |
| Indexing | More indexed paths = higher write RU | Exclude unused paths |
| Document size | Larger docs = more RU per operation | Keep documents lean |
| Cross-partition queries | Request charge sums the actual work across participating partitions | Use 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 TTL | Item TTL | Behaviour |
|---|---|---|
| Not set | Any | TTL disabled for entire container |
-1 | Not set | Items never expire (opt-in per item) |
-1 | 3600 | Item expires after 1 hour |
86400 | Not set | Items expire after 1 day (container default) |
86400 | 3600 | Item 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:
| Term | Decision |
|---|---|
| 1 year | Compare the shorter commitment with expected eligible throughput usage |
| 3 years | Evaluate 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
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?
For an autoscale resource configured with max 50,000 RU/s, what is the minimum throughput floor?
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.