ladderlore
  • 输入服务名称,例如 S3 或 IAM。

服务 · Database · 基于 CLF-C02

Amazon DynamoDB

Serverless key-value and document database. Design the key well and choose the capacity mode.

本课尚未翻译,暂以英文显示。

你在云从业者中已学过

  • DynamoDB is serverless, NoSQL and gives single-digit millisecond performance at any scale.
  • On-demand mode charges per request. Provisioned mode suits steady traffic.
  • Global tables are multi-Region and multi-active.
阅读云从业者课程
  • Strongly consistent read

    One unit covers
    1 RCU = one 4 KB read per second
    Example
    8 KB item: 2 RCU
  • Eventually consistent read

    One unit covers
    1 RCU = two 4 KB reads per second
    Example
    8 KB item: 1 RCU
  • Transactional read

    One unit covers
    2 RCU per 4 KB
    Example
    4 KB item: 2 RCU
  • Standard write

    One unit covers
    1 WCU = one 1 KB write per second
    Example
    3 KB item: 3 WCU
  • Transactional write

    One unit covers
    2 WCU per 1 KB
    Example
    1 KB item: 2 WCU
Capacity maths: sizes always round up.

1 / 2

  • Strongly consistent read

    One unit covers
    1 RCU = one 4 KB read per second
    Example
    8 KB item: 2 RCU
  • Eventually consistent read

    One unit covers
    1 RCU = two 4 KB reads per second
    Example
    8 KB item: 1 RCU
  • Transactional read

    One unit covers
    2 RCU per 4 KB
    Example
    4 KB item: 2 RCU

2 / 2

  • Standard write

    One unit covers
    1 WCU = one 1 KB write per second
    Example
    3 KB item: 3 WCU
  • Transactional write

    One unit covers
    2 WCU per 1 KB
    Example
    1 KB item: 2 WCU
Capacity maths: sizes always round up.
  • On-demand

    When
    New, spiky or unknown traffic
    Note
    Pay per request
  • Provisioned + auto scaling

    When
    Steady, predictable traffic
    Note
    Lowest cost at steady load
  • Global secondary index

    When
    Query by other keys, any time
    Note
    Own capacity, up to 20
  • Local secondary index

    When
    Same partition key, other sort key
    Note
    Create with table, up to 5
Capacity mode and index choices.

1 / 2

  • On-demand

    When
    New, spiky or unknown traffic
    Note
    Pay per request
  • Provisioned + auto scaling

    When
    Steady, predictable traffic
    Note
    Lowest cost at steady load
  • Global secondary index

    When
    Query by other keys, any time
    Note
    Own capacity, up to 20

2 / 2

  • Local secondary index

    When
    Same partition key, other sort key
    Note
    Create with table, up to 5
Capacity mode and index choices.

是什么

DynamoDB spreads items over partitions by hashing the partition key. A good key has many different values and spreads traffic evenly, for example a customer ID. A key with few values, or one value that is much busier than the others, creates a hot partition that throttles even when the table has spare capacity. A sort key lets you keep related items together and query them by range.

是什么

Capacity is measured in units. One read capacity unit (RCU) is one strongly consistent read per second of an item up to 4 KB. An eventually consistent read costs half. One write capacity unit (WCU) is one write per second of an item up to 1 KB. Sizes round up. For example, 10 strongly consistent reads per second of 6 KB items need 20 RCUs, because 6 KB rounds up to 8 KB, which is 2 units each. Items can be up to 400 KB.

要记住

  • Hot partition: pick a high-cardinality partition key so traffic spreads evenly.
  • Reads are eventually consistent by default. Strong consistency is optional, and not available on global secondary indexes.
  • On-demand for new or unpredictable traffic. Provisioned with auto scaling for steady traffic, which costs less.

要记住

  • GSI: any keys, add any time, own capacity, up to 20. LSI: same partition key, other sort key, create with the table, up to 5.
  • DynamoDB Streams (24 hours of changes), TTL (free expiry of old items), transactions (all or nothing) and point-in-time recovery (35 days).
  • Global tables: replicate across Regions with multi-active writes.

考试中

  • “Throttling even though total capacity is enough” points to a hot partition, so choose a better partition key.
  • “Query by an attribute that is not the key” points to a global secondary index.
  • “Automatically delete old session items” points to TTL. “React to item changes” points to DynamoDB Streams.
  • “Unpredictable traffic, no capacity planning” points to on-demand mode.