Service · Database · CLF-C02 အပေါ် ဆက်လေ့လာရန်
Amazon DynamoDB
Serverless key-value and document database. Design the key well and choose the capacity mode.
ဒီသင်ခန်းစာကို မြန်မာဘာသာ မပြန်ရသေးလို့ အင်္ဂလိပ်လို ပြထားပါတယ်။
Cloud Practitioner မှ သင်သိပြီးသားများ
- 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
| Operation | One unit covers | Example |
|---|---|---|
| Strongly consistent read | 1 RCU = one 4 KB read per second | 8 KB item: 2 RCU |
| Eventually consistent read | 1 RCU = two 4 KB reads per second | 8 KB item: 1 RCU |
| Transactional read | 2 RCU per 4 KB | 4 KB item: 2 RCU |
| Standard write | 1 WCU = one 1 KB write per second | 3 KB item: 3 WCU |
| Transactional write | 2 WCU per 1 KB | 1 KB item: 2 WCU |
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
| Operation | One unit covers | Example |
|---|---|---|
| Strongly consistent read | 1 RCU = one 4 KB read per second | 8 KB item: 2 RCU |
| Eventually consistent read | 1 RCU = two 4 KB reads per second | 8 KB item: 1 RCU |
| Transactional read | 2 RCU per 4 KB | 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
| Operation | One unit covers | Example |
|---|---|---|
| Standard write | 1 WCU = one 1 KB write per second | 3 KB item: 3 WCU |
| Transactional write | 2 WCU per 1 KB | 1 KB item: 2 WCU |
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
| Choose | When | Note |
|---|---|---|
| On-demand | New, spiky or unknown traffic | Pay per request |
| Provisioned + auto scaling | Steady, predictable traffic | Lowest cost at steady load |
| Global secondary index | Query by other keys, any time | Own capacity, up to 20 |
| Local secondary index | Same partition key, other sort key | Create with table, up to 5 |
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
| Choose | When | Note |
|---|---|---|
| On-demand | New, spiky or unknown traffic | Pay per request |
| Provisioned + auto scaling | Steady, predictable traffic | Lowest cost at steady load |
| Global secondary index | Query by other keys, any time | Own capacity, up to 20 |
2 / 2
Local secondary index
- When
- Same partition key, other sort key
- Note
- Create with table, up to 5
| Choose | When | Note |
|---|---|---|
| Local secondary index | Same partition key, other sort key | Create with table, up to 5 |
ဘာလဲ
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.
ဒါတွေနဲ့ မရောပါနဲ့
Amazon Keyspaces (for Apache Cassandra)A serverless, managed database that is compatible with Apache Cassandra.
Amazon DocumentDBA managed document database that is compatible with MongoDB.
Amazon ElastiCacheIn-memory cache. Choose Valkey or Redis OSS for rich features, Memcached for a simple multithreaded cache.