Q62 — AWS DVA-C02 Ch.2

Question 62 of 100 | ← Chapter 2

A developer is designing a serverless application for customers to book concert seats. Customers submit booking requests via an Amazon API Gateway API backed by an AWS Lambda function that validates orders and generates order IDs. The application includes two additional Lambda functions: one for inventory management and another for payment processing. Both functions run asynchronously and write order records to an Amazon DynamoDB table. The application must assign seats to customers in strict order of request receipt. If a seat is accidentally oversold, the application must assign the seat to the first-order received. In that case, only the first order’s payment must be processed. However, if the first order’s payment is declined during processing, the second order must receive the seat—and its payment must be processed. Which solution satisfies these requirements?

Correct Answer: A. Send the order ID to an Amazon SNS FIFO topic, which fans out to two separate Amazon SQS FIFO queues—one for inventory management and one for payment processing.

Explanation

Option A ensures strict ordering and decoupled, independent processing: the FIFO SNS topic preserves order and delivers each order ID to two FIFO queues—one for inventory and one for payment. Inventory processing (which assigns seats) and payment processing operate separately but deterministically: the first order’s inventory update succeeds and locks the seat; subsequent orders fail inventory checks and are handled accordingly. Payment processing only proceeds for orders that successfully acquired inventory. FIFO semantics guarantee exactly-once, ordered delivery per queue, satisfying the seat assignment and payment sequencing requirements. Option B introduces synchronous coupling and blocking, risking timeouts and failing to scale. Option C (standard SNS) lacks ordering guarantees. Option D (standard SQS) does not guarantee message ordering or exactly-once processing. Thus, Option A is correct.