Amazon Kinesis
Amazon Kinesis is AWS's family of managed services for streaming data. The one that matters most in interviews is Kinesis Data Streams (KDS): a durable, ordered, replayable stream of records, split into shards, that many applications can read at once. It does the same job as Kafka, a partitioned log you write events to and read them back from, but as a fully managed AWS service with a pay-per-shard model and no brokers to run. Alongside it sit Amazon Data Firehose (formerly Kinesis Data Firehose), which loads streams into S3, Redshift or OpenSearch with no code, and Managed Service for Apache Flink for stream processing.
The properties that define Kinesis Data Streams:
- Sharded: a stream is a set of shards, and each shard has fixed, published throughput limits. Capacity planning is literally counting shards.
- Ordered per shard: records with the same partition key go to the same shard and get increasing sequence numbers, so per-key ordering is preserved.
- Retained and replayable: records stay for 24 hours by default, extendable to 7 days or up to a year. Consumers track their own position and can rewind.
- Multiple consumers: several applications can read the same stream independently, each at its own pace.
- Fully managed and durable: AWS replicates every record across three availability zones before acknowledging the write. You never see a broker, a disk or a replica.
Kinesis comes up in interviews whenever a design is on AWS and needs a stream: clickstream ingestion, ad click aggregation, IoT telemetry, log and metrics pipelines, change data capture. Saying "Kinesis" instead of "Kafka" is perfectly fine, but interviewers often check that you know the shard limits and do the math, because those limits shape the design more directly than Kafka's do. This post covers the model, the numbers, the consumers and the trade-offs.
The Core Concepts
Stream: a named, ordered log of records, for example clickstream-prod.
Shard: a slice of the stream with a fixed capacity. A stream with 40 shards has 40 independent ordered sequences. Each shard owns a contiguous range of the 128-bit hash key space.
Record: the unit of data, made of a partition key (a string up to 256 characters), a data blob (up to 1 MB by default) and a sequence number that Kinesis assigns on write. Sequence numbers increase within a shard.
Partition key: Kinesis takes the MD5 hash of the partition key, a 128-bit number, and writes the record to the shard whose hash key range contains it. Same key, same shard, same order. A producer can also pass an explicit hash key to target a particular part of the range.
Producer: anything that calls PutRecord or PutRecords (up to 500 records per call).
Consumer: an application that reads records shard by shard, either by polling with GetRecords or, with enhanced fan-out, by having records pushed to it over HTTP/2.
The Shard Limits
These numbers drive every Kinesis design, so they're worth memorizing:
| Per shard | Limit |
|---|---|
| Writes | 1 MB/s or 1,000 records/s, whichever comes first |
| Reads (shared, polling) | 2 MB/s and 5 GetRecords calls/s, shared by all polling consumers |
| Reads (enhanced fan-out) | 2 MB/s per registered consumer |
| Maximum record size | 1 MB (by default) |
Writes beyond a shard's limit are rejected with ProvisionedThroughputExceededException, and the producer has to back off and retry.
A worked example. A clickstream peaks at 60,000 events per second, at about 800 bytes each:
- By bytes: 60,000 × 800 B = 48 MB/s, so at least 48 shards.
- By records: 60,000 / 1,000 = 60 shards.
- So records, not bytes, are the constraint: you need 60 shards, plus headroom for uneven keys, call it 80.
Now suppose three applications read the stream: a real-time aggregator, an archiver and a fraud model. Together they read 3 × 48 = 144 MB/s. With shared polling, 80 shards give 160 MB/s of read capacity, which is barely enough, and the five-calls-per-second limit is shared among them too. Add a fourth reader and you're over. With enhanced fan-out, each consumer gets its own 2 MB/s per shard, and the problem goes away. That's exactly the kind of arithmetic interviewers like to see.
Small records hit the 1,000 records/s limit long before the 1 MB/s limit. The fix is aggregation: the Kinesis Producer Library (KPL) packs many small user records into one Kinesis record, and the consumer library unpacks them. Packing 100-byte events 10 at a time cuts the shard count for record limits by 10x. Mention it when your events are tiny.