Amazon DynamoDB Tutorial 0/6 lessons ~6 min read Lesson 4

    DynamoDB Read and Write Capacity, Consistency Models, and Performance

    DynamoDB performance depends on how many reads and writes your table can handle, how large your items are, which consistency model you choose, and whether your traffic is predic…

    Course progress0%
    Focus
    15 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    DynamoDB performance depends on how many reads and writes your table can handle, how large your items are, which consistency model you choose, and whether your traffic is predictable or spiky.

    Imagine a movie ticket booking application. On a normal day, 5,000 users access the application every minute. When booking opens for a blockbuster movie, 3 million users log in, 500,000 users search for seats, and thousands of payments happen every second. Traditional databases often require manual server upgrades, replicas, load balancing, and close CPU or memory monitoring.

    DynamoDB removes much of that infrastructure work, but you still need to understand capacity units, billing modes, consistency, throttling, and cost behavior to design production-ready systems.

    Purpose of this lesson

    By the end of this lesson, you will understand Read Capacity Units, Write Capacity Units, On-Demand and Provisioned capacity modes, strong and eventual consistency, adaptive capacity, throttling, throughput calculations, and cost optimization.

    Understanding the topic

    Capacity represents how many read and write operations your DynamoDB table can process. Think of it like road capacity: a two-lane road handles limited traffic, while a six-lane highway can handle much more.

    Capacity Units

    How DynamoDB Measures Throughput

    item size matters

    Read Capacity Unit (RCU)

    reads
    1 RCU = 1 strongly consistent read per second for an item up to 4 KB.
    1 RCU = 2 eventually consistent reads per second for items up to 4 KB.

    Write Capacity Unit (WCU)

    writes
    1 WCU = 1 write per second for an item up to 1 KB.
    A 3 KB item consumes 3 WCUs because write capacity rounds up by 1 KB chunks.
    OperationCapacity RuleImportant Detail
    Strong Read1 RCU per read up to 4 KBLatest committed data
    Eventually Consistent Read1 RCU per 2 reads up to 4 KBCheaper and higher throughput
    Write1 WCU per write up to 1 KBRounds up by item size

    Internal architecture

    DynamoDB supports two capacity modes. On-Demand is best when traffic is unpredictable. Provisioned Capacity is useful when traffic is predictable and you want tighter cost control.

    On-Demand Capacity

    AWS Adjusts Automatically

    Morning100 requests
    Afternoon5,000 requests
    Night launch200,000 requests

    Best for new apps, seasonal traffic, startups, and event-driven workloads.

    Provisioned Capacity

    You Define RCUs and WCUs

    Read Capacity: 5000 RCUs
    Write Capacity: 3000 WCUs
    Auto Scaling
    1000 → 3000 → 6000 RCUs

    Best for stable enterprise workloads where usage is known and budget planning matters.

    Data flow

    Capacity calculations become straightforward when you know request volume, item size, and read consistency.

    Throughput Calculation

    2,000 Reads and 500 Writes per Second

    Reads

    2 KB item, eventually consistent reads.

    2000 reads / 2 reads per RCU
    = 1000 RCUs

    Writes

    2 KB item, 500 writes per second.

    500 writes x 2 WCUs
    = 1000 WCUs
    Final capacity estimate: 1000 RCUs and 1000 WCUs. Add headroom or auto scaling for real production traffic.

    Visual explanation

    DynamoDB offers two read consistency models. Use strong consistency only where correctness requires the latest committed value immediately.

    Read Consistency

    Strong vs Eventually Consistent Reads

    Eventually Consistent

    A read immediately after a write may briefly return older data while replicas synchronize.

    • Lower cost
    • Higher throughput
    • Great for product catalogs, feeds, and recommendations

    Strongly Consistent

    A read returns the latest committed data after a successful write.

    • Latest data
    • Higher read cost
    • Useful for balances, payment confirmation, and critical state
    FeatureStrongEventual
    Latest dataYesUsually, after brief replication delay
    Read costHigherLower
    ThroughputLowerHigher
    Best useCritical stateMost read-heavy application views

    Real-world use

    Streaming platforms, ticketing systems, and flash-sale e-commerce apps often see unpredictable traffic spikes. On-Demand capacity is attractive for these workloads because the table can absorb sudden increases without pre-planning every spike.

    • Netflix-style launches: new series releases create sudden read spikes for watch history, profiles, and recommendations.
    • Ticket booking: blockbuster openings create huge bursts of seat searches and payment status checks.
    • E-commerce sales: traffic may double or triple during festive campaigns.
    • Enterprise systems: predictable business-hour usage may be cheaper with Provisioned Capacity plus Auto Scaling.

    Scalability analysis

    Adaptive Capacity helps when traffic is uneven. If one partition becomes busier than others, DynamoDB can automatically allocate more resources to reduce throttling and improve latency.

    Uneven Traffic

    Hot Access Pattern

    Customer 101
    100,000 requests
    Customer 102
    20 requests

    Adaptive Capacity

    Automatic Rebalancing Support

    • Reduces throttling on busy partitions.
    • Improves response time for uneven workloads.
    • Requires no direct developer action.

    Cost analysis

    Good DynamoDB design is not only about speed. Item size, consistency choice, scans, and capacity mode directly affect AWS cost.

    • Use eventually consistent reads whenever the latest value is not mandatory.
    • Keep item sizes small and avoid unnecessary attributes.
    • Prefer Query over Scan.
    • Choose On-Demand for unpredictable traffic.
    • Choose Provisioned Capacity for predictable traffic.
    • Enable Auto Scaling for provisioned tables.
    • Monitor consumed capacity, throttled requests, and latency in CloudWatch.

    Failure scenarios

    Throttling occurs when incoming requests exceed available capacity. DynamoDB temporarily rejects some requests to protect the table and partitions.

    Throttling

    When Requests Exceed Capacity

    Provisioned
    100 RCUs
    Incoming
    500 reads
    Result
    100 served / 400 throttled
    Fixes include increasing capacity, enabling Auto Scaling, using On-Demand mode, optimizing partition keys, retrying with backoff, and replacing scans with queries.

    Best practices

    • Choose On-Demand for new applications until traffic patterns are known.
    • Monitor consumed capacity regularly.
    • Avoid scans in production request paths.
    • Design efficient partition keys to distribute traffic.
    • Enable Auto Scaling for Provisioned tables.
    • Estimate throughput before deployment.
    • Use CloudWatch alarms for capacity utilization and throttling.
    • Use strong consistency only for workflows that truly require it.

    Common mistakes

    • Choosing Provisioned Capacity without traffic analysis.
    • Ignoring throttling metrics.
    • Reading large items unnecessarily.
    • Using strong consistency for every query.
    • Forgetting that item size affects capacity consumption.
    • Using scans for high-traffic APIs.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    5 questions
    1BeginnerQuestionWhat is an RCU?+

    Answer

    A Read Capacity Unit represents one strongly consistent read per second for an item up to 4 KB, or two eventually consistent reads per second for an item up to 4 KB.
    2BeginnerQuestionWhat is a WCU?+

    Answer

    A Write Capacity Unit allows one write per second for an item up to 1 KB. Larger items consume additional WCUs because DynamoDB rounds up by 1 KB chunks.
    3IntermediateQuestionWhat is the difference between On-Demand and Provisioned Capacity?+

    Answer

    On-Demand automatically adjusts to traffic and charges per request. Provisioned Capacity requires you to define RCUs and WCUs in advance and is often cheaper for predictable workloads.
    4IntermediateQuestionWhat is Adaptive Capacity?+

    Answer

    Adaptive Capacity automatically reallocates resources to busy partitions, reducing throttling and improving performance for uneven workloads without manual developer action.
    5AdvancedQuestionWhat causes throttling in DynamoDB?+

    Answer

    Throttling occurs when read or write requests exceed available table or partition capacity. Common causes include under-provisioned capacity, hot partitions, inefficient keys, large items, and scan-heavy access patterns.

    Hands-on exercise

    Design a DynamoDB capacity plan for an online shopping application with 10,000 reads per second, 2,000 writes per second, average item size of 2 KB, and traffic that doubles during festive sales.

    • Should you use On-Demand or Provisioned Capacity?
    • Calculate approximate RCUs and WCUs required.
    • Would you enable Auto Scaling? Why?
    • Which consistency model would you choose for product catalog, shopping cart, and payment confirmation?
    • List three CloudWatch metrics you would monitor to ensure the table performs efficiently.

    Summary

    DynamoDB performance planning starts with capacity units. RCUs measure read throughput, WCUs measure write throughput, item size affects both, and consistency choice can double or halve read capacity needs. On-Demand mode simplifies unpredictable traffic, while Provisioned Capacity can reduce cost for stable workloads.

    You also learned how Adaptive Capacity helps uneven traffic, how throttling happens, and how to optimize costs through smaller items, better access patterns, Auto Scaling, CloudWatch monitoring, and careful consistency choices.

    Next: Lesson 5 covers creating and managing DynamoDB tables using the AWS Console, AWS CLI, and SDKs, plus primary key configuration, capacity modes, PITR, encryption, IAM, tagging, and lifecycle operations.

    Ready to mark this lesson complete?Track your journey across the entire course.