Soru

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

A developer is maintaining a real-time smart home telemetry system. Devices send sensor updates to an Amazon Kinesis Data Stream with 4 shards. A consumer AWS Lambda function, triggered by an event source mapping, processes these records. During peak hours, the developer notices a high rate of ProvisionedThroughputExceededException errors on the stream. CloudWatch metrics indicate that two of the shards are receiving almost all of the traffic, while the other two shards remain idle. The stream partition key is currently set to the device's region_id (representing one of four geographic zones). Which two actions should the developer take to resolve the throttling and ensure data is distributed evenly? (Select TWO.)

  1. Modify the producer application to use the unique device_id as the partition key instead of the region_id to ensure even data distribution across all shards.Cevap
  2. Configure the producer application to retry requests with exponential backoff and jitter when encountering ProvisionedThroughputExceededException.Cevap
  3. C
    Change the partition key to a static string to ensure all events are sent to the same shard for strict chronological ordering.
  4. D
    Increase the Lambda function execution timeout to 15 minutes to allow the event source mapping to poll the stream more frequently.
  5. E
    Deploy the consumer Lambda function in a private VPC subnet without a NAT Gateway or VPC Endpoint to isolate Kinesis polling traffic.

Cevap

To resolve the throttling and ensure data is distributed evenly, the developer must modify the producer to use the unique device ID as the partition key to achieve high entropy across shards, and configure the producer to retry throttled requests with exponential backoff and jitter.
The combination of using the unique device identifier as the partition key and configuring exponential backoff on the producer resolves both the structural bottleneck (hot shards) and handles temporary congestion elegantly. The high entropy of the device ID ensures uniform shard utilization, and retries with backoff mitigate stream ingestion errors under peak load.

Adım Adım Çözüm

1
Analyze the shard utilization metrics.
Two shards are heavily utilized (hot shards) and two are idle, which indicates uneven distribution of records due to low-entropy partition keys.
The partition key region_id has only four possible values, mapping unevenly to Kinesis shards.
2
Select a high-entropy attribute for the partition key.
Using the unique device ID as the partition key distributes the write load uniformly across all shards.
A high number of unique keys ensures that the hash function spreads the payload across all available stream shards.
3
Implement transient error handling in the producer.
The producer handles ProvisionedThroughputExceededException by waiting and retrying with randomized delays.
Exponential backoff with jitter prevents retry storms and allows the stream to recover during transient load spikes.

Anahtar Kavram

Partition key entropy and producer-side error handling in Amazon Kinesis Data Streams
Bu soruyu puanla