Kinesis Data Streams and Firehose
Ordered, replayable streams: shards, partition keys, capacity modes, consumers and checkpoints, and Amazon Data Firehose for delivery without code.
SQS queuesEventBridgeLambda concurrency, cold starts and failures
Kinesis Data Streams and Firehose
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A stream is a retained log. Reading does not delete, so several consumers can read the same records at their own pace and go back in time.
- The partition key picks the shard. Order is kept within a shard only, and one very busy key cannot be spread out.
- Each shard takes up to 1,000 records and 1 MB a second of writes and gives 2 MB a second of shared reads.
- Records are kept 24 hours by default and up to 365 days.
- With Lambda, a failing record blocks its shard. Set retry limits, a maximum record age, batch bisection and a failure destination.
- Amazon Data Firehose buffers a stream and writes it to S3, a warehouse or a search service with no consumer code, at the cost of some delay.
A log, not a to-do list
A queue hands out work: once a message is processed and deleted, it’s gone. Some data isn’t a to-do item. Clickstreams, sensor readings and order changes are a history. Fraud detection wants it now, analytics wants it hourly, and next month you may build something that wants to reread last week.
A stream is that history: an append-only log that keeps records for a retention period. Reading removes nothing. Each consumer remembers its own position. Think of a security camera’s recording: any number of people can watch, from any point still on disk, without wearing the tape out. If you know Kafka, this is the same family of idea.
Amazon Kinesis Data Streams is AWS’s managed version. Amazon Data Firehose (formerly Kinesis Data Firehose) is a delivery service that sits beside it.
Shards and partition keys
A stream is split into shards, each an ordered sequence of records. A producer sends a record with a partition key, and a hash of the key chooses the shard. Same key, same shard, preserved order. Across shards there is no order.
I created a 2-shard stream on moto, a local emulator, and wrote three records each for alice, bob and carol, interleaved. Reading each shard from the beginning:
shard 0: alice-1 alice-2 alice-3
shard 1: bob-1 carol-1 bob-2 carol-2 bob-3 carol-3
Each user’s records are in order. Two users share a shard and one has a shard to itself, which is normal: hashing spreads keys, not load. A key such as a single huge customer creates a hot shard that no amount of resharding fixes.
Per shard, writes are limited to 1,000 records and 1 MB a second, and shared reads to 2 MB and 5 read calls a second. A record can be up to 1 MB by default, and a stream can be configured to accept up to 10 MiB. Retention is 24 hours by default and up to 365 days, with extra charges beyond 24 hours.
Who manages the shards
In provisioned mode you choose the shard count and pay per shard hour. In on-demand mode the service adds and removes shards and you pay mainly for data volume; a new on-demand stream starts able to take 4 MB/s of writes. There is also an account-level On-demand Advantage option with warm throughput and different pricing.
Reading
A consumer keeps a checkpoint, the last sequence number it finished, for each shard. The Kinesis Client Library manages that for you; so does a Lambda event source mapping. Crash before checkpointing and you reread, and producer retries can write duplicates too, so processing must be idempotent.
By default consumers share each shard’s read throughput. Enhanced fan-out gives a registered consumer its own 2 MB per second per shard, pushed to it.
AWS has also added queues on on-demand streams, which track delivery per record so independent work can be spread without shard leases. You give up shard order for it.
With Lambda, order has a price. A batch that keeps failing is retried until it succeeds or the records expire, and the shard waits behind it. The defaults for retry attempts and record age are unlimited. Set them, turn on BisectBatchOnFunctionError to narrow down the bad record, consider ReportBatchItemFailures, and configure an on-failure destination.
Firehose: delivery without a consumer
Often the only requirement is “put this somewhere I can query it”. Writing and operating a consumer for that is waste. A Firehose stream accepts records, from producers directly or from a Kinesis data stream, buffers them, optionally transforms them with a Lambda function, and writes them to S3, Redshift, OpenSearch, Apache Iceberg tables, Splunk, Snowflake or an HTTP endpoint.
The buffer is the trade. For S3 the defaults are 5 MiB or 300 seconds, whichever comes first, adjustable from 1 to 128 MiB and 0 to 900 seconds. Bigger buffers make fewer, larger files, which query engines like; smaller ones give fresher data. Delivery to some destinations is at least once. Firehose is not a log you can replay: once delivered, the data lives at the destination.
Kinesis Data Streams itself now also offers direct delivery to S3 and Iceberg tables on on-demand streams, so check which path is simpler when you start.
Picking among the four
- One job per message, consumed once: SQS.
- Same notification to several services: SNS, usually with queues.
- Route by content across many sources: EventBridge.
- Ordered, high-volume, replayable, several readers: Kinesis Data Streams.
About the video
The embed is a clip (3:53 to 22:31) of Be A Better Dev’s Kinesis overview, August 2023. Its chapters in that range are Data Streams and the Firehose overview; the clip stops before the analytics product, which has changed since. It predates on-demand Advantage, larger records, queues and direct delivery, and you may hear the older Firehose name. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from the “English (US) original” audio track. A re:Invent 2025 internals talk is in deeper.
What was run: the partition key experiment ran on moto 5.1.22, an emulator, which shows the API and key-to-shard behaviour, not throughput or throttling. Limits, modes, consumer features and Firehose settings are from the AWS docs, checked 2026-11-29.
Where this fits
That completes messaging. The next group runs your consumers and services as containers, starting with where images live: ECR.
Check yourself
You have 10 shards but one shard is throttled while the rest are idle. Adding shards does not help. Why?
One partition key is carrying most of the traffic, and a key always maps to a single shard. Choose a key with more distinct, evenly busy values, or split the hot key with a suffix if you can give up ordering across the parts.
A team adds a fourth consumer and all of them start lagging. What changed, and what is the fix?
Shared consumers divide each shard's 2 MB a second and its read call limit. Register consumers for enhanced fan-out so each gets dedicated throughput per shard.
A Lambda function on a stream throws on one malformed record and processing on that shard stops for hours. Why?
By default Lambda retries the batch until it succeeds or the records expire, to preserve order. Turn on bisect on error, cap retries and record age, and send discarded batch details to an on-failure destination.
You need click data in S3 for nightly queries and have no other consumers. Do you need to write a consumer?
No. Send to a Firehose stream, which buffers by size or time and writes S3 objects. For S3 the default is 5 MiB or 300 seconds, whichever comes first.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.