# Dynamodb Throttling Optimizer

> Optimises DynamoDB throttling prevention across eight dimensions: partition key design (hot partition detection via CloudWatch ThrottledRequests), burst capacity utilization (300-second burst bucket understanding), adaptive capacity (automatic redistribution, not a design substitute), GSI partition key distribution (hot GSI backpressure), write capacity mode (provisioned vs on-demand for bursty writes), batch write API (BatchWriteItem for 16x throughput), exponential backoff with jitter (ProvisionedThroughputExceededException handling), and write sharding (random suffix for high-cardinality hot keys). Covers conditional writes for idempotency, TTL for data lifecycle, partition splitting, and throttling root cause analysis via CloudTrail.

- Skill: `jhkchan/dynamodb-throttling-optimizer` (Agent Skill, multi-file: 21 files)
- Install (CLI): `npx get-skill add jhkchan/dynamodb-throttling-optimizer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jhkchan/dynamodb-throttling-optimizer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: Apache-2.0
- Author: jhkchan (https://skillmd.com/u/jhkchan)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/jhkchan/dynamodb-throttling-optimizer

---


# DynamoDB Throttling Optimizer

## What this skill does

Translates a DynamoDB table's throttling posture into a concrete
prevention recommendation with a throughput-denominated estimated impact.
The verdict is the highest-leverage action across eight dimensions --
partition key design, burst capacity, adaptive capacity, GSI distribution,
write capacity mode, batch write API, exponential backoff, and write
sharding -- applied in priority order. Always pairs the recommendation
with exact CLI commands.

## Quick navigation

| Section | What it covers | When to jump here |
|---|---|---|
| Quick start | Four headline rules and the throttling formula | First read |
| Mindset | Why partition key design is the #1 lever | Understanding the approach |
| Quick reference -- verdict thresholds | Decision matrix at a glance | Classifying a table |
| Pre-flight data gate | CloudWatch metrics, CloudTrail | Before any recommendation |
| Step 0 non-obvious behaviours | Burst capacity, adaptive capacity, GSI backpressure | Edge cases |
| Step 1 Partition key design | Hot partition detection, write sharding | The headline dimension |
| Step 2 Burst capacity | 300-second burst bucket utilization | Intermittent spikes |
| Step 3 Adaptive capacity | Automatic redistribution limits | Hot partition mitigation |
| Step 4 GSI distribution | Hot GSI partition key backpressure | GSI throttling |
| Step 5 Write capacity mode | Provisioned vs on-demand for bursty writes | Capacity mode decision |
| Step 6 Batch write API | BatchWriteItem for 16x throughput | High-volume writes |
| Step 7 Exponential backoff | ProvisionedThroughputExceededException handling | Client-side retry |
| Step 8 Impact estimation | Throughput math and worked examples | Every recommendation |
| Output format | VERDICT block + worked examples | Emitting the result |
| Anti-Patterns -- NEVER | Common misclassifications | Self-check before emit |
| Pre-flight safety checks | CONFIRM gate, GSI backfill | Before any apply CLI |

## Quick start

- **Partition key design is the #1 lever.** DynamoDB distributes data
  across partitions by partition key. A hot partition key (few distinct
  values, uneven write distribution) causes throttling even when total
  consumed capacity is below provisioned. Write sharding (random suffix)
  spreads writes across partitions.
- **Burst capacity gives a 5-minute window.** DynamoDB accumulates
  unused capacity (up to 300 seconds of provisioned throughput) and
  releases it as burst capacity. Intermittent spikes that fit within
  the burst window do NOT throttle. Sustained spikes beyond burst DO
  throttle.
- **Adaptive capacity is a safety net, not a design substitute.** When
  a hot partition exceeds its share of throughput, DynamoDB temporarily
  redirects unused capacity from cold partitions. This prevents
  immediate throttling but does not fix the underlying distribution
  problem. Rely on write sharding, not adaptive capacity.
- **BatchWriteItem is 16x more efficient than PutItem.** A single
  BatchWriteItem request writes up to 16 items (up to 16 MB) in one
  round trip. This reduces request count, network overhead, and
  consumed capacity per item. For high-volume writes, always use batch.

## Mindset

Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).

## Quick reference -- verdict thresholds

| Observation (14-30 day window) | Verdict | Recommendation |
|---|---|---|
| ThrottledRequests > 0 AND partition key cardinality is low (hot partition) | **FURTHER_OPTIMIZATION_AVAILABLE** (write sharding) | Step 1 -- add random suffix to partition key |
| ThrottledRequests > 0 AND burst capacity exhausted (sustained spikes > 5 min) | **FURTHER_OPTIMIZATION_AVAILABLE** (capacity mode) | Step 5 -- switch to on-demand OR increase WCU |
| ThrottledRequests > 0 AND GSI partition key is hot (GSI backpressure) | **FURTHER_OPTIMIZATION_AVAILABLE** (GSI design) | Step 4 -- redesign GSI partition key or use sparse index |
| Sustained writes > 1000 items/s AND using PutItem (not BatchWriteItem) | **FURTHER_OPTIMIZATION_AVAILABLE** (batch) | Step 6 -- migrate to BatchWriteItem |
| ThrottledRequests > 0 AND no exponential backoff on client | **FURTHER_OPTIMIZATION_AVAILABLE** (retry) | Step 7 -- implement backoff with jitter |
| BillingMode = PROVISIONED AND throttling on bursty, unpredictable writes | **FURTHER_OPTIMIZATION_AVAILABLE** (capacity mode) | Step 5 -- switch to on-demand |
| ThrottledRequests = 0 AND partition key well-distributed AND batch writes used | **OPTIMIZED** | Emit post-state verification |
| CloudWatch metrics absent or window < 14 days | **NEED_MORE_INFO** | Pull 14-30 day CloudWatch data, re-evaluate |

## Pre-flight: data gate (run before any optimization decision)

Throttling diagnosis requires CloudWatch metrics and table configuration.
Pull these before any recommendation. Full CLI sequences are in
`references/throttling-metrics-and-write-sharding.md`.

Moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md) - load on demand (see References below).

### Data-quality short-circuits

| Condition | Effect on optimization |
|---|---|
| `ThrottledRequests` Sum = 0 over 14 days | Emit **OPTIMIZED** with note "no throttling observed." |
| `ConsumedWriteCapacityUnits` absent | **NEED_MORE_INFO**. Cannot assess write pressure. |
| Observation window < 14 days | **NEED_MORE_INFO**. Minimum 14 days; 30 days preferred. |
| Table `TableStatus != ACTIVE` | Skip optimization; surface as BLOCKED. |
| GSI `IndexStatus != ACTIVE` (backfilling) | GSI throttling expected during backfill; defer analysis. |

## Process -- Optimization logic (apply in order)

### Step 0: Non-obvious behaviours that change the recommendation

Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).

### Step 1: Partition key design (hot partition detection, write sharding)

Partition key design is the #1 lever because DynamoDB distributes data
and throughput across partitions by partition key value. A hot partition
key (few distinct values, uneven write distribution) causes throttling
even when table-level consumed capacity is below provisioned.

Moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md) - load on demand (see References below).

**Hot partition diagnosis decision tree:**
```
Is ThrottledRequests > 0?
├── NO → No partition-level throttling. Check other dimensions.
└── YES → Is partition key cardinality high (>10,000 distinct values)?
    ├── NO → HOT PARTITION. Apply write sharding (Step 1).
    └── YES → Is write distribution even across keys?
        ├── NO → HOT PARTITION (skewed writes). Apply write sharding.
        └── YES → Check burst capacity exhaustion (Step 2) or GSI (Step 4).
```

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

Use write sharding ONLY for genuinely hot keys. Over-sharding low-volume
keys adds read complexity without benefit.

### Step 2: Burst capacity utilization

DynamoDB accumulates unused provisioned throughput (up to 300 seconds)
as burst capacity. Understanding burst utilization is key to diagnosing
intermittent throttling.

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

**Diagnosis:**

| Pattern | Root cause | Fix |
|---|---|---|
| Throttling only during brief spikes (<5 min) | Burst capacity exhausted | Increase WCU or switch to on-demand |
| Throttling during sustained writes (>5 min) | Provisioned too low | Increase WCU or on-demand |
| No throttling, burst heavily used | Near limit | Monitor closely, pre-provision |

### Step 3: Adaptive capacity understanding

Adaptive capacity automatically redistributes unused throughput from
cold partitions to hot partitions. It is a safety net, not a design fix.

**Key facts:**
- Activates within seconds of a hot partition exceeding its share.
- Redirection is temporary (minutes), not permanent.
- Does NOT prevent throttling for sustained hot partitions.
- No configuration needed -- always on for provisioned tables.

**Anti-pattern:** Designing a table with a known hot partition key and
relying on adaptive capacity to prevent throttling. Adaptive capacity
delays throttling; write sharding (Step 1) fixes it permanently.

### Step 4: GSI partition key distribution

GSI partition key design is as critical as base table partition key
design. A hot GSI partition key causes GSI throttling, which
back-pressures and throttles the base table.

Moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md) - load on demand (see References below).

**GSI optimization strategies:**

| Problem | Fix |
|---|---|
| GSI partition key has low cardinality (e.g., `status` with 3 values) | Use composite key: `status#date` or write sharding |
| GSI is a "full table scan" pattern (all items under one key) | Redesign GSI partition key for distribution |
| GSI backfilling causes throttling | Reduce backfill rate or use on-demand temporarily |
| GSI is sparse but back-pressures base table | Ensure GSI partition key distributes writes evenly |

### Step 5: Write capacity mode (provisioned vs on-demand)

**Capacity mode decision matrix:**

| Pattern | Recommended mode | Rationale |
|---|---|---|
| Steady, predictable traffic | Provisioned + auto-scaling | Lower cost; predictable capacity |
| Bursty, unpredictable traffic | On-demand | No throttling from capacity limits |
| Spikes >2x previous peak | Provisioned with headroom | On-demand 2x spike limit may throttle |
| Low traffic (<1000 WCU sustained) | On-demand | Simpler; no auto-scaling config needed |
| High traffic (>50,000 WCU sustained) | Provisioned | On-demand cost premium too high |

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

### Step 6: Batch write API (BatchWriteItem for 16x throughput)

BatchWriteItem writes up to 16 items (up to 16 MB total) in a single
request. This reduces request count, network overhead, and client-side
latency.

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

Moved verbatim to [references/error-handling.md](references/error-handling.md) - load on demand (see References below).

### Step 7: Exponential backoff with jitter

When `ProvisionedThroughputExceededException` occurs, the client must
retry with exponential backoff and jitter. The AWS SDK retries
automatically by default, but custom retry logic with jitter is more
effective for sustained throttling.

Moved verbatim to [references/error-handling.md](references/error-handling.md) - load on demand (see References below).

**Retry best practices:**

| Strategy | When to use |
|---|---|
| SDK default retry (3 attempts) | Low-volume, occasional throttling |
| Custom backoff with jitter (10 attempts) | Sustained throttling, batch workloads |
| Adaptive retry (circuit breaker) | High-volume, latency-sensitive APIs |

### Step 8: Conditional writes and TTL

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

Moved verbatim to [references/worked-examples.md](references/worked-examples.md) - load on demand (see References below).

TTL reduces table size over time, which reduces storage cost and scan
time. TTL deletions consume background WCU -- stagger TTL values to
avoid batch-expiry throttling on provisioned tables.

## Configuration dependency graph

```
                ┌──────────────────────────┐
                │ ThrottledRequests > 0?   │
                └────────────┬─────────────┘
                             │
              ┌──────────────┴──────────────┐
              YES                           NO
              │                             │
       ┌──────▼──────┐              ┌───────▼───────┐
       │ Partition   │              │ Batch write   │
       │ key hot?    │              │ used?         │
       └──────┬──────┘              └───────┬───────┘
              │                             │
       ┌──────┴──────┐              ┌───────┴───────┐
      YES          NO              YES             NO
       │            │               │               │
 ┌─────▼─────┐ ┌────▼────┐  ┌───────▼───┐   ┌───────▼───────┐
 │ Write     │ │ GSI     │  │ OPTIMIZED │   │ Check        │
 │ sharding  │ │ hot?    │  │           │   │ capacity     │
 │ (Step 1)  │ └────┬────┘  └───────────┘   │ mode (Step 5)│
 └───────────┘      │                       └──────────────┘
               YES  │  NO
               │    └──→ Burst capacity (Step 2)
         ┌─────▼─────┐
         │ GSI       │
         │ redesign  │
         │ (Step 4)  │
         └───────────┘
```

Decision order: partition key (write sharding) -> GSI distribution ->
burst/capacity mode -> batch write -> exponential backoff.

## Output format

```text
TARGET: <table-name>
VERDICT: OPTIMIZED | FURTHER_OPTIMIZATION_AVAILABLE
REASON: <1-2 sentences naming the recommendation and the supporting data>
RECOMMENDATION:
  Current: <billing-mode>, <WCU>, <partition key>, <GSI status>, <batch write status>
  Proposed: <billing-mode>, <WCU>, <partition key>, <GSI status>, <batch write status>
  Dimensions changed: <partition_key | burst | adaptive | gsi | capacity_mode | batch_write | backoff>
  Dimensions checked: <list ALL eight, each ✓ (no finding) or → (finding)>
  Confidence: <HIGH/MEDIUM/LOW> -- <one-line rationale>
ESTIMATED_THROUGHPUT_IMPACT:
  Current throttled requests/day: <count>
  Projected throttled requests/day: <count>
  Throughput improvement: <description>
  Root cause: <hot partition | burst exhaustion | GSI backpressure | insufficient capacity>
MIGRATION_STEPS:
  1. <specific action with CLI command>
  2. <verification step>
CONFIRM: Before executing any state-changing CLI, emit and await operator
  approval: "CONFIRM: About to <action> on <table-name> in <region>.
  Proceed? (yes/no)"
```

Full worked examples are in `references/worked-examples.md`.

## STRICT output contract

The rules below are hard constraints. Self-check EVERY emitted block
against these rules before returning. Do NOT substitute markdown headings
or camelCase for the literal labels.

### FORBIDDEN output patterns

1. **NEVER emit `VERDICT: FURTHER_OPTIMIZATION_AVAILABLE` with
   `Projected throttled requests/day` equal to current.** If every
   dimension nets zero improvement, verdict MUST be `OPTIMIZED`.

2. **NEVER recommend write sharding without warning about read
   complexity.** Write sharding adds parallel read overhead. The
   MIGRATION_STEPS MUST note the read pattern change.

3. **NEVER recommend on-demand mode without citing the cost premium.**
   On-demand is significantly more expensive than provisioned for
   steady workloads. Always pair with a cost-justification note.

4. **NEVER recommend BatchWriteItem as a throttling fix without noting
   that consumed WCU is unchanged.** BatchWriteItem reduces request
   count, not consumed capacity. It helps with client-side latency and
   connection pool pressure, not partition-level throttling.

5. **NEVER attribute throttling to insufficient capacity without checking
   partition key distribution.** Throttling is per-partition. A hot
   partition throttles even when table-level consumed < provisioned.
   Always check partition key cardinality and write distribution first.

6. **NEVER omit a dimension from the RECOMMENDATION block.** The
   `Dimensions checked` line MUST list all eight dimensions.

7. **NEVER emit scratch lines** ("WAIT -- recompute", "Hmm, let me redo")
   in the output.

### Perfect example output -- FURTHER_OPTIMIZATION_AVAILABLE

```text
TARGET: user-events-prod
VERDICT: FURTHER_OPTIMIZATION_AVAILABLE
REASON: PROVISIONED table with 45,000 ThrottledRequests on Write over 30
  days. Partition key (user_id) has high write skew -- top 1% of user_ids
  generate 80% of writes (detected via CloudTrail). Write sharding with
  random suffix (10 shards) will spread writes across 10 partitions,
  eliminating hot-partition throttling.
RECOMMENDATION:
  Current: PROVISIONED, 3000 WCU, pk=user_id (skewed), 1 GSI, PutItem
  Proposed: PROVISIONED, 3000 WCU, pk=user_id#NN (10 shards), 1 GSI, BatchWriteItem
  Dimensions changed: partition_key (Step 1) + batch_write (Step 6)
  Dimensions checked: partition_key → (shard)  burst ✓  adaptive ✓
    gsi ✓ (well-distributed)  capacity_mode ✓  batch_write → (migrate)
    backoff ✓ (SDK default active)
  Confidence: HIGH -- CloudTrail confirms 80/20 write skew on user_id.
ESTIMATED_THROUGHPUT_IMPACT:
  Current throttled requests/day: 1,500
  Projected throttled requests/day: 0
  Throughput improvement: 10x write capacity on hot keys (1 partition → 10)
  Root cause: hot partition (write skew on user_id)
MIGRATION_STEPS:
  1. Add sharding suffix to partition key on write:
     pk = f"{user_id}#{random.randint(1,10).zfill(2)}"
  2. Update reads to fan out across 10 shards in parallel:
     Query all 10 suffixes, merge results.
  3. Migrate high-volume PutItem calls to BatchWriteItem (16 items/batch):
     with table.batch_writer() as batch: ...
  4. Backfill existing items with sharded keys (one-time migration).
  5. Monitor ThrottledRequests for 7 days post-migration.
CONFIRM: About to apply write sharding (10 suffixes) to user-events-prod
  partition key. Read queries will need parallel fan-out. Proceed? (yes/no)
```

**Self-check before emit:**
- [ ] All eight dimensions listed in `Dimensions checked`?
- [ ] Every `→` dimension has a corresponding MIGRATION_STEPS entry?
- [ ] Write sharding recommendation includes read-pattern warning?
- [ ] No scratch/recompute text in the block?

## Verdict semantics

| Verdict | When to emit |
|---|---|
| `FURTHER_OPTIMIZATION_AVAILABLE` | At least one dimension has a concrete throttling-prevention recommendation. |
| `OPTIMIZED` | All dimensions pass (no throttling, partition keys well-distributed, batch writes used, backoff configured). |
| `NEED_MORE_INFO` | Data gate failed: ThrottledRequests metrics absent, window < 14 days, or CloudTrail unavailable. |
| `BLOCKED` | Hard precondition prevents evaluation: TableStatus != ACTIVE, GSI backfilling. |

## Anti-Patterns -- NEVER (top 5)

1. **NEVER recommend increasing WCU as the first fix for throttling.**
   Throttling is per-partition. A hot partition throttles regardless of
   table-level WCU. Always check partition key distribution first.

2. **NEVER rely on adaptive capacity as a design strategy.** Adaptive
   capacity is a temporary safety net. It delays throttling for minutes;
   it does not fix sustained hot partitions. Write sharding is the
   durable fix.

3. **NEVER recommend on-demand mode without citing the cost premium.**
   On-demand can be 3-5x more expensive than provisioned for steady
   workloads. Always pair with a cost-justification check.

4. **NEVER recommend BatchWriteItem as a partition-level throttling fix.**
   BatchWriteItem reduces request count, not consumed capacity per item.
   It helps with client-side patterns, not partition-level hot-spot
   throttling.

5. **NEVER add a GSI without checking its partition key distribution.**
   A hot GSI partition key causes GSI throttling, which back-pressures
   the base table. GSI partition key design is as important as base
   table partition key design.

Extended anti-patterns in `references/error-handling-and-edge-cases.md`.

## Expert heuristic

Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).

## Pre-flight safety checks (run before any remediation CLI)

- **MANDATORY CONFIRMATION GATE.** Before any state-changing operation,
  emit and await operator approval.
- **Write sharding changes the partition key.** All reads must be
  updated to fan out across suffixes. Test read paths before deploying.
- **GSI changes require backfill time.** Creating or modifying a GSI
  takes minutes to hours depending on table size. Plan for backfill.
- **Capacity mode switch is instant but has implications.** Provisioned
  to on-demand is instant; on-demand to provisioned requires setting
  WCU/RCU. Test auto-scaling after switching to provisioned.
- **BatchWriteItem migration requires code changes.** Ensure the client
  handles `UnprocessedItems` correctly.
- **TTL activation has a delay.** TTL deletions begin within 48 hours
  of enabling. Stagger TTL values to avoid batch-expiry throttling.
- **Bulk-operation limit:** 5 tables per batch. Sort by ThrottledRequests
  count.

## Recent AWS features (2024-2026)

Moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md) - load on demand (see References below).

## References

- `references/throttling-metrics-and-write-sharding.md` -- CloudWatch
  metrics reference, write sharding patterns, BatchWriteItem examples,
  exponential backoff code, capacity mode decision matrix, GSI
  distribution analysis, partition splitting strategies.
- `references/worked-examples.md` -- write sharding migration, GSI
  redesign, capacity mode switch, batch write migration, already-
  optimized, NEED_MORE_INFO, end-to-end walkthrough.
- `references/error-handling-and-edge-cases.md` -- CLI/data-source
  failure handling, GSI backfill edge cases, TTL batch-expiry
  throttling, extended NEVER list, partition splitting guidance.

## References (load on demand)

- [references/advanced-patterns.md](references/advanced-patterns.md) — Mindset five principles, Step 0 non-obvious behaviours, expert heuristic, and 2024-2026 feature changes moved from SKILL.md
- [references/diagnostic-commands.md](references/diagnostic-commands.md) — Pre-flight data-gate sources plus hot-partition and per-GSI ThrottledRequests metric commands moved from SKILL.md
- [references/error-handling.md](references/error-handling.md) — ProvisionedThroughputExceededException backoff-with-jitter code and BatchWriteItem UnprocessedItems retry handling moved from SKILL.md
- [references/worked-examples.md](references/worked-examples.md) — write-sharding, burst-math, capacity-mode-switch, batch-write, conditional-write and TTL code patterns moved from SKILL.md (extends the existing worked examples)

## Domain

AWS CloudOps / DynamoDB Throttling Prevention & Partition Key Optimization.

## AWS documentation

- **DynamoDB Developer Guide** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Welcome.html
- **DynamoDB partition key design** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-design.html
- **DynamoDB burst capacity** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/burst-capacity.html
- **DynamoDB adaptive capacity** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-design.html#bp-partition-key-adaptive
- **DynamoDB BatchWriteItem** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.BatchOperations
- **DynamoDB error handling** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html
- **DynamoDB capacity modes** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html
- **DynamoDB GSI** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html
- **DynamoDB TTL** -- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html
- **AWS CLI DynamoDB reference** -- https://docs.aws.amazon.com/cli/latest/reference/dynamodb/
- **Well-Architected -- Performance Efficiency** -- https://docs.aws.amazon.com/wellarchitected/latest/performance-efficiency-pillar/welcome.html

