Lesson 5 of 7 Amazon Kinesis and Amazon MSK

Planning Stream Capacity and Consumers

This lesson explains the throughput limits and consumer rules on which streaming questions often hinge, which are the same whether data arrives through Kinesis Data Streams or Amazon MSK, with different names.

Learning outcomes

After completing this lesson, you will be able to:

  • Apply Kinesis shard write and read limits to plan a stream's capacity.
  • Explain why standard consumers throttle each other and when enhanced fan-out is worth its cost.
  • Map Kinesis terms to their Kafka equivalents.

Kinesis Data Streams capacity

The lesson Streaming Data in Real Time with Kinesis Data Streams introduced the per-shard limits: 1 MB or 1,000 records per second of writes, and 2 MB per second of reads shared by standard consumers. Planning capacity means applying both write limits to the expected traffic and taking the larger result, because a stream of many small records reaches the record limit long before the byte limit. Reads need the same check: the shards needed for reading are the write rate multiplied by the number of standard consumers, divided by the 2 MB per second that each shard serves.

Standard consumers also share a second, less obvious limit: each shard serves only five GetRecords calls per second across all of them. A typical consumer polls each shard about once a second, so with more than two or three standard consumers the calls themselves start to be throttled, which adds latency even when there is spare bandwidth. This is why enhanced fan-out, which pushes data to each registered consumer instead of waiting for it to poll, is the fix for several consumers on one stream.

In provisioned mode, capacity is changed by resharding: UpdateShardCount splits or merges shards evenly to reach a new total, so the stream can be scaled before a known peak. On-demand mode scales automatically and suits unpredictable load. A hot shard, shown by ProvisionedThroughputExceededException on writes while total capacity is spare, is fixed by choosing a higher-cardinality partition key. Adding a random suffix to the key also spreads the load, but records for the same entity then land on different shards and lose their relative order, so it suits only data that does not need per-key ordering. The following table summarises the limits used for planning.

Limit (per shard, provisioned mode)Value
Writes1 MB/s or 1,000 records/s
Reads, shared (GetRecords)2 MB/s across all standard consumers, 5 calls/s
Reads, enhanced fan-out2 MB/s per registered consumer, pushed over HTTP/2
Fill in the value

Capacity planning

Exam skills 1.1.1 · 1.1.10

Plan read and write capacity for a provisioned stream.

Log in to try this activity Interactive activities are free with an account.

Consumers

How a consumer is built decides how it shares a stream. Enhanced fan-out gives each registered consumer dedicated throughput, but it is charged per consumer and per gigabyte retrieved, so it is used where several applications genuinely need low latency at full throughput; one or two standard consumers remain the cheaper choice when they keep up.

The Kinesis Client Library (KCL) distributes shards across a consumer application's workers, using a DynamoDB lease table to track which worker owns which shard, and records checkpoints of each worker's progress, so a restarted worker resumes from its last checkpoint. The metric GetRecords.IteratorAgeMilliseconds shows how far a consumer lags behind the newest records; a rising iterator age means the consumer cannot keep up. For Lambda consumers, the parallelisation factor processes up to 10 batches per shard concurrently, which raises throughput while still keeping records with the same partition key in order.

The following diagram compares five standard consumers with five enhanced fan-out consumers on one shard.

Five standard consumers compared with five enhanced fan-out consumers on one shard. Standard consumers share the shard's 2 MB per second and five GetRecords calls per second, so each receives about 0.4 MB per second and iterator age rises. Enhanced fan-out pushes a dedicated 2 MB per second to each registered consumer.
The 0.4 MB per second share assumes the five consumers read evenly.

Kafka equivalents on MSK

Kinesis and Kafka solve the same problems with different names, and exam scenarios may use either vocabulary. A Kinesis shard corresponds to a Kafka partition: both are the unit of parallelism and of ordering. A Kinesis partition key corresponds to a Kafka message key, which decides where a record goes. A KCL application, which tracks its progress in a DynamoDB lease table, corresponds to a Kafka consumer group, which commits offsets.

How far consumers are behind is iterator age in Kinesis and consumer lag in Kafka. Where Kinesis needs enhanced fan-out to give consumers dedicated throughput, each Kafka consumer group already reads the topic independently. The following table summarises the equivalents.

KinesisKafka / MSK
ShardPartition (the unit of parallelism and ordering)
Partition keyMessage key
KCL application with lease tableConsumer group with committed offsets
Iterator ageConsumer lag
Enhanced fan-outEach consumer group reads independently
Match the pairs

Kinesis and Kafka terms

Exam skills 1.1.1

Match each Kinesis term with its Kafka equivalent.

Log in to try this activity Interactive activities are free with an account.
Worked example

Five applications read the same Kinesis data stream with the KCL. Since the fifth was added, all consumers show rising iterator age, although write volume has not changed and no consumer is CPU-bound.

Five standard consumers share each shard's 2 MB/s and 5 GetRecords calls per second, so they throttle each other. Register the consumers for enhanced fan-out so each gets its own 2 MB/s per shard. Adding shards would also help but costs more and does not address the shared read limit directly.

Check yourself

Several applications read the same stream and slow each other down. What fixes this?

Show answer

Enhanced fan-out, which gives each registered consumer its own 2 MB per second per shard instead of a shared 2 MB.

Exam Tips

Remember for the exam

  • A shard takes 1 MB/s or 1,000 records/s of writes and serves 2 MB/s of shared reads.
  • Use enhanced fan-out when several consumers read the same stream.
  • Throttling with spare total capacity means a hot shard; fix the partition key.
  • Rising iterator age (or consumer lag on MSK) means consumers are falling behind.
  • On-demand mode for unpredictable traffic; provisioned for steady, cost-sensitive traffic.