Amazon DynamoDB Tutorial 0/30 lessons ~6 min read Lesson 29

    Monitoring, Performance Tuning, and Cost Optimization

    A healthy DynamoDB table is one where throttling is rare, latency is flat, and the bill matches the workload.

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

    Introduction

    A healthy DynamoDB table is one where throttling is rare, latency is flat, and the bill matches the workload. CloudWatch metrics, Contributor Insights, and a few design habits cover most of that.

    Purpose of this lesson

    You will set up the core alarms, choose a capacity mode, and apply the main cost levers: capacity mode, table class, item size, projections, TTL, and caching.

    Understanding the topic

    Metrics to alarm on:

    • ThrottledRequests, ReadThrottleEvents, WriteThrottleEvents (table and each GSI).
    • SuccessfulRequestLatency by operation.
    • SystemErrors (service-side) and UserErrors (validation and condition failures from your code).
    • ConsumedReadCapacityUnits / ConsumedWriteCapacityUnits versus provisioned capacity.
    • Lambda IteratorAge for stream consumers and ReplicationLatency for global tables.
    • Contributor Insights to find the hottest and most-throttled keys.

    Informative example

    Alarm on write throttling (CloudFormation snippet):

    yaml
    ShopTableWriteThrottleAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
    AlarmName: shoptable-write-throttles
    Namespace: AWS/DynamoDB
    MetricName: WriteThrottleEvents
    Dimensions:
    - Name: TableName
    Value: ShopTable
    Statistic: Sum
    Period: 60
    EvaluationPeriods: 5
    Threshold: 1
    ComparisonOperator: GreaterThanOrEqualToThreshold
    TreatMissingData: notBreaching
    AlarmActions:
    - !Ref OnCallTopic

    Cost analysis

    Cost levers:

    • On-demand for spiky, unpredictable, or new workloads; provisioned with auto scaling (and reserved capacity) for steady, predictable traffic.
    • Standard-Infrequent Access table class lowers storage cost and raises request cost — use it when storage dominates the bill.
    • Item size: capacity is billed per 1 KB written and 4 KB read, and attribute names count toward size. Keep large blobs in S3 and store a pointer.
    • Projections: KEYS_ONLY or INCLUDE GSIs cost less than ALL.
    • TTL deletes old data without write cost.
    • Eventually consistent reads cost half of strongly consistent reads.
    • DAX or an application cache for read-heavy hot items, with microsecond reads from cache.

    Best practices

    • Alarm on throttling for the table and every GSI.
    • Use ReturnConsumedCapacity in load tests to estimate cost per request.
    • Review the top cost driver monthly (storage, reads, writes, replication, backups).

    Common mistakes

    • Provisioning for peak with no auto scaling.
    • Storing images or documents in items instead of S3.
    • Paying for ALL projections on rarely used GSIs.

    Advanced interview questions

    Interview Prep

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

    2 questions
    1IntermediateQuestionHow do you choose between on-demand and provisioned capacity?+

    Answer

    On-demand charges per request and suits unknown, spiky, or low-traffic workloads with no capacity planning. Provisioned with auto scaling is cheaper for steady, predictable traffic, especially with reserved capacity. Many teams start on-demand and switch once traffic is understood.
    2BeginnerQuestionHow many RCUs does a strongly consistent read of a 9 KB item use?+

    Answer

    Three. Reads are billed in 4 KB units rounded up (9 KB → 3 units). An eventually consistent read of the same item uses 1.5 RCU, and a transactional read uses 6.

    Hands-on exercise

    Hands-on: using ReturnConsumedCapacity: "TOTAL", measure the RCU of reading one order with strongly consistent and eventually consistent reads, and the WCU of writing a 3.5 KB item versus a 900-byte item. Explain the numbers using the 4 KB / 1 KB rounding rules.

    Summary

    Monitor throttling, latency, errors, iterator age, and replication latency. Control cost with the right capacity mode, table class, small items, lean projections, TTL, and caching.

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