Tech challenge · AWS

Kinesis writes throttle although the stream has spare capacity

HardAWS

A Kinesis data stream has 10 shards. Producers get ProvisionedThroughputExceededException, yet the stream's total incoming bytes are well under 10 MB per second. The partition key is country, and 70% of traffic comes from one country. Explain and fix it.

Think it through or sketch an answer first, then open the hint or the solution.

Show a hint

Limits apply per shard, and the partition key decides the shard.

Show the solution

Each shard accepts up to 1 MB per second or 1,000 records per second for writes. The partition key is hashed to choose the shard, so all records for the big country go to one hot shard and are throttled while the other shards sit idle. Use a high-cardinality key that spreads load (for example user or device id), keeping ordering only where it is needed. On-demand capacity mode and producer retries with backoff help with bursts but not with a single hot key.

Common mistakes

  • Adding shards: with the same key, the hot country still maps to one shard.
  • Using a random key everywhere, which loses per-entity ordering that consumers may rely on.

Learn more

More AWS challenges

Today's challenge and the full archive