Soru

Zorluk: OrtaStream Processing and Event Routing with Amazon Kinesis and EventBridge

A developer is implementing a web analytics pipeline where user interaction events are sent to a custom Amazon EventBridge event bus. The developer configures an EventBridge rule to route these events to an Amazon Kinesis Data Stream for real-time analytics. The stream has 10 active shards to handle the expected volume. The developer wants to ensure that all events for any given user session are processed in chronological order by the consumer application, while also distributing the write load evenly across all shards to prevent write throttling.

Which target configuration in EventBridge meets these requirements?

  1. Configure the target with a PartitionKeyPath pointing to the user session ID field ($.detail.sessionId) in the event payload.Cevap
  2. B
    Configure the target with a PartitionKeyPath pointing to the event type field ($.detail.eventType) in the event payload.
  3. C
    Omit the PartitionKeyPath setting, allowing EventBridge to assign a static default string as the partition key.
  4. D
    Route the events to an AWS Lambda function that writes to the stream using the current timestamp as the partition key.

Cevap

Configure the target with a PartitionKeyPath pointing to the user session ID field ($.detail.sessionId) in the event payload.
Configuring the EventBridge target with a PartitionKeyPath pointing to the user session ID ensures that all events from a given session share the same partition key. Kinesis Data Streams maps records with the same partition key to the same shard, preserving the order of execution. Because there are many unique user sessions (high cardinality), the traffic is distributed evenly across all shards, preventing throttling.

Adım Adım Çözüm

1
Analyze the requirements for stream ingestion and processing.
The solution requires two things: preserving chronological ordering of events within a user session, and distributing events evenly across Kinesis shards.
Understanding these twin constraints is necessary to choose the correct partition key configuration.
2
Determine the mechanism for ordering and load distribution in Kinesis Data Streams.
Kinesis determines the destination shard by hashing the partition key of each record. Records with the same partition key are sent to the same shard and processed in order.
This shows that the partition key must represent the logical grouping that requires ordering (the user session).
3
Evaluate the cardinality of potential partition keys.
A high-cardinality key like user session ID distributes events evenly across 10 shards. A low-cardinality key or static string causes hot shards. A timestamp fails to guarantee that all events of a specific session land on the same shard.
Selecting the high-cardinality session ID via PartitionKeyPath meets both the scaling and ordering requirements.

Anahtar Kavram

Selecting high-entropy partition keys using PartitionKeyPath on EventBridge targets is crucial for Kinesis Data Streams to achieve balanced shard utilization and maintain order.
Bu soruyu puanla