Question

Difficulty: HardDecoupling Architectures and Event-Driven Messaging

A clinical diagnostic laboratory is building an event-driven system to process patient test results generated by multiple automated analyzers. The results for each patient must be processed in the exact sequence they are completed to prevent older results from overwriting newer ones due to network latency. Results for different patients can be processed concurrently. The system must scale automatically to handle sudden increases in test volumes during peak hours.

Which solution meets these requirements with the least operational overhead?

  1. A
    Create a standard Amazon SQS queue and configure an AWS Lambda function as the consumer. Implement sorting logic in the consumer application to order the results by patient ID before processing.
  2. B
    Configure the analyzers to directly invoke an AWS Lambda function for each event. Have the Lambda function execute a continuous polling loop to wait and collect all test results for a patient before processing them.
  3. Create an Amazon SQS FIFO queue and configure an AWS Lambda function as the consumer. Send the events to the queue using the patient ID as the message group ID.Answer
  4. D
    Create an Amazon Kinesis data stream. Configure the analyzers to write events to the stream using the analyzer machine ID as the partition key, and process the events using an AWS Lambda function.

Answer

Create an Amazon SQS FIFO queue and configure an AWS Lambda function as the consumer. Send the events to the queue using the patient ID as the message group ID.
The correct solution uses an Amazon SQS FIFO queue with the patient ID as the message group ID. This setup guarantees that all messages belonging to the same patient (the same message group) are processed sequentially, while allowing different patient groups to be processed in parallel. Using AWS Lambda as a consumer provides automatic scaling and minimal operational overhead.

Step-by-Step Solution

1
Identify the primary requirement for message ordering and concurrency.
Events for the same patient must be processed in order, while events for different patients can be processed concurrently.
This dictates that we need a messaging system that supports message ordering groups.
2
Evaluate Amazon SQS FIFO queues for this scenario.
SQS FIFO queues preserve message order within a specific MessageGroupId.
Using patient ID as the MessageGroupId ensures that all events for a single patient are processed in the order they are received, while allowing concurrent processing of different patient IDs.
3
Compare SQS FIFO with SQS Standard and Amazon Kinesis.
Standard SQS does not guarantee ordering. Kinesis requires partition key design and manual shard scaling.
SQS FIFO provides a serverless, zero-overhead solution for message grouping and ordering, minimizing operational overhead.

Key Concept

Amazon SQS FIFO queues use the MessageGroupId parameter to group messages that must be processed in a strict sequence, allowing multiple consumers to process different message groups concurrently.
Rate this question