Dynamodb medium
When is an 'Atomic Counter' (using `SET x = x + 1`) insufficient for maintaining an accurate count in a production environment?
- A When the count is expected to exceed 1,000 per hour.
- B When idempotent operations are required: Atomic counters are not idempotent. If a network retry occurs, the counter might be incremented twice, leading to over-counting.
- C When the table is in On-Demand mode.
- D When the attribute being incremented is a String instead of a Number.
Answer: B. When idempotent operations are required: Atomic counters are not idempotent. If a network retry occurs, the counter might be incremented twice, leading to over-counting.
Atomic counters are 'Update and Forget'. If the network fails but the write actually succeeded, your client might retry and increment again. For 100% accuracy, you should use Conditional Writes (optimistic locking) or Transactions, which can detect if the change was already applied.
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?