A developer is writing a producer application that sends temperature telemetry data from thousands of IoT devices to an Amazon Kinesis data stream with multiple shards. The developer wants to ensure that the data is distributed evenly across all available shards to prevent write throttling. Which strategy should the developer use when specifying the partition key for the PutRecord API call?
- AUse a static string such as 'sensor_data' as the partition key for all records.
- BDeploy the producer application in a private VPC subnet without a NAT Gateway to restrict access to a single shard.
- Use a unique device identifier or a generated UUID as the partition key for each record.Answer
- DConfigure the consumer Lambda function to run with the default 3-second timeout to force faster shard polling.
Answer
Use a unique device identifier or a generated UUID as the partition key for each record.
Using a partition key with high entropy (such as a unique device identifier or a generated UUID) ensures that the MD5 hash of the partition key is distributed evenly across the hash ranges of all shards in the Kinesis stream. This prevents a single shard from receiving a disproportionate volume of data (hot shards) and avoids write throttling.
Step-by-Step Solution
Key Concept
Partition key entropy and shard distribution in Amazon Kinesis