A developer is designing a real-time order processing system for an e-commerce platform. The system must ingest order events, execute real-time fraud analysis, and route notifications to third-party shipping partners. Order volume spikes unpredictably during promotional events, and the events must be processed in the strict order they are received for each unique customer. The developer decides to use Amazon Kinesis Data Streams for ingestion and Amazon EventBridge for event routing. Which TWO configurations or practices should the developer implement to meet these requirements?
- Use the customer ID as the partition key when publishing events to the Kinesis Data Stream to ensure that events for the same customer are routed to the same shard and processed in order.Answer
- Create an EventBridge rule with an event pattern that filters for specific order status events and routes them to shipping partners using API destinations.Answer
- CUse a fixed string such as 'order_event' as the partition key for all records published to Kinesis Data Streams to simplify shard management.
- DPlace the downstream consumer Lambda function in a private VPC subnet without a NAT Gateway or VPC endpoint to read events directly from Kinesis.
- EInitialize the database connection pool outside the Lambda handler and set the Lambda function timeout to 3 seconds to guarantee in-memory state preservation across all concurrent requests.
Answer
Use the customer ID as the partition key when publishing events to the Kinesis Data Stream, and create an EventBridge rule with an event pattern that filters for specific order status events and routes them to shipping partners using API destinations.
Using the customer ID as the partition key ensures that all records containing events for the same customer map to the same shard. Since Kinesis guarantees ordered delivery within a single shard, events are processed sequentially. Additionally, EventBridge rules combined with API destinations provide a native way to filter events and post them to third-party shipping HTTP endpoints without managing custom polling logic.
Step-by-Step Solution
Key Concept
Preserving order in Kinesis streams using high-entropy partition keys and routing events to HTTP targets via EventBridge API destinations.