DynamoDB interview question · Most asked
What read consistency options does DynamoDB offer?
Summary
Eventually consistent reads (the default) may not reflect a write from the last moment but cost half as much; strongly consistent reads (ConsistentRead: true) return the latest committed write in the Region. GSIs and streams support only eventually consistent reads.
Longer Answer
An eventually consistent read usually catches up within a second. Use strong reads for read-after-write flows where it matters (a user immediately viewing what they saved), or design the UI to use the data already in hand. Strongly consistent reads are not available from a GSI, so a pattern needing them must be served by the base table or an LSI. Global tables have their own cross-Region consistency model.
Key Points
- Eventual (default, half price) vs strong.
- No strong reads on GSIs.
- Strong reads for read-after-write needs.
More most-asked DynamoDB questions
- What are DynamoDB Streams, and how are they used?
- Query or Scan: what is the difference, and why avoid Scan?
- What is DynamoDB, and what workloads is it a good fit for?
- What is a hot partition, and how do you avoid one?
- How do you approach data modelling in DynamoDB, and how is it different from relational design?
- Explain partition keys, sort keys and the two kinds of primary key.
- Global secondary index or local secondary index: what is the difference?
- How do conditional writes work, and how do you implement optimistic locking in DynamoDB?