Question

Difficulty: EasyStream Processing and Event Routing with Amazon Kinesis and EventBridge

A developer is building a producer application that sends real-time traffic sensor data to an Amazon Kinesis data stream consisting of multiple shards. The developer wants to ensure that the data is distributed evenly across all available shards to prevent write throttling. Which partition key strategy should the developer implement?

  1. Use a high-entropy identifier, such as the unique sensor ID, as the partition key for each record.Answer
  2. B
    Use a single, constant string value like 'sensor_data' as the partition key for all records.
  3. C
    Use a static partition key and increase the processing Lambda function's execution timeout.
  4. D
    Use the private subnet ID of the producer's VPC as the partition key.

Answer

Use a high-entropy identifier, such as the unique sensor ID, as the partition key for each record.
The correct strategy is to use a high-entropy identifier, such as the unique sensor ID. Amazon Kinesis distributes incoming records to shards by hashing the partition key. A high-entropy partition key ensures that records are evenly distributed across all shards, minimizing the risk of hot shards and ingestion throttling.

Step-by-Step Solution

1
Determine how Amazon Kinesis routes records to specific shards.
Amazon Kinesis applies an MD5 hash function to the partition key to assign the record to a shard.
This is the fundamental routing mechanism of Kinesis Data Streams.
2
Evaluate the entropy of the partition keys.
Using a high-entropy partition key (like a unique sensor ID) yields a wide spread of hash values, while low-entropy keys (like static values) hash to the same value.
High entropy ensures that records are distributed evenly across the shards rather than overloading a single shard.

Key Concept

Kinesis Data Streams Shard Distribution and Partition Keys
Rate this question