Exams / SAA-C03 / Decoupling with queues / Question 3
SAA-C03 practice question: Decoupling with queues (3 of 6)
Design Resilient Architectures A free question from our original SAA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
A bank's payments platform sends account transactions to a queue for processing by a fleet of workers. Transactions for the same account must be applied in the order they were sent, but transactions for different accounts should be processed in parallel so that the fleet can scale out. When a send times out, the producer retries it within a few seconds, and a retried transaction must not be applied twice. Which solution meets these requirements with the LEAST custom code?
Choose one answer.
- AA. Use an Amazon SQS FIFO queue, set the message group ID to the account ID, and set the deduplication ID to the transaction ID.
- BB. Use an Amazon SQS FIFO queue with one message group ID for all messages, and turn on content-based deduplication for the queue.
- CC. Use an Amazon Kinesis data stream with the account ID as the partition key, and run one consumer for the records of each shard.
- DD. Use an Amazon SQS standard queue, and record each processed transaction ID in a DynamoDB table so workers skip duplicates.
Show the answer and explanation
Answer: A
- A. Right: Correct. A FIFO queue keeps strict order within each message group, and different groups can be processed by different workers at the same time, so each account stays in order while the fleet scales. A send with the same deduplication ID within the 5-minute deduplication interval is not added to the queue again, which covers the producer's quick retries. Learn more: FIFO queue delivery logic in Amazon SQS (opens in a new tab)
- B. Wrong: Content-based deduplication would remove retried sends, and order would be kept. However, with a single message group every message is part of one ordered sequence, so only one transaction can be in flight at a time and the fleet cannot process accounts in parallel. Using the account ID as the group ID fixes this. Learn more: Exactly-once processing in Amazon SQS (opens in a new tab)
- C. Wrong: Records with the same partition key go to the same shard, so per-account order is kept and shards give parallelism. However, a producer retry after a timeout can write the same transaction twice as two records with different sequence numbers. The consumers would need their own deduplication code, which a FIFO queue's deduplication ID avoids. Learn more: Handle duplicate records in Kinesis Data Streams (opens in a new tab)
- D. Wrong: The DynamoDB table would catch duplicates, but it is custom code. More importantly, a standard queue only makes a best-effort attempt to keep order, so transactions for one account could be applied out of sequence. A FIFO queue with per-account message groups guarantees the order. Learn more: Amazon SQS standard queues (opens in a new tab)
Explanation
Three requirements interact: order per account, parallelism across accounts, and no duplicates from producer retries. An SQS FIFO queue with the account ID as the message group ID gives order within each account and parallel processing across accounts, and a deduplication ID drops retries sent within 5 minutes. A single group removes parallelism, Kinesis needs consumer-side deduplication, and a standard queue does not guarantee order.
Study
Keep practising
Answer questions with a score at the end, or practise just this topic with the explanation after each one. No sign-up needed.