Dynamodb hard
A system writes to DynamoDB through a DAX cluster. If an application immediately reads the same item directly from the DynamoDB API (not through DAX), what is the technical consistency risk?
- A The item will be missing because DAX writes are asynchronous.
- B Reading stale data: While DAX is a write-through cache (it updates the DB synchronously), the DB's internal replication to the 3-node storage quorum is asynchronous. A direct read without `ConsistentRead=true` might hit a replica that hasn't received the write yet.
- C The write will fail because DAX locks the backend table during flush.
- D Direct DB reads are prohibited when a DAX cluster is attached to a VPC.
Answer: B. Reading stale data: While DAX is a write-through cache (it updates the DB synchronously), the DB's internal replication to the 3-node storage quorum is asynchronous. A direct read without `ConsistentRead=true` might hit a replica that hasn't received the write yet.
DAX ensures that anything it returns is 'Strongly Consistent' relative to the writes it handles. However, it cannot control the consistency of the underlying DynamoDB service for external callers. To ensure the latest data is seen outside of DAX, you must use Strongly Consistent reads on the base DynamoDB API, which incurs the 2x RCU cost.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- DynamoDB has a strict 400KB limit on the size of a single item. What is the recommended design pattern if you need to store larger documents (e.g., 5MB PDFs)?
- What is the primary role of the 'Partition Key' in ensuring DynamoDB's infinite horizontal scalability?
- Why is the `Query` operation generally preferred over `Scan` for production workloads in DynamoDB?
- DynamoDB is a 'fully managed' serverless database. What is a primary operational benefit of this model for an engineering team?
- In 'Provisioned Capacity' mode, how is the performance budget of a DynamoDB table defined?
- When would an architect choose to implement DAX (DynamoDB Accelerator) in front of an existing DynamoDB table?