How to fanout an AWS kinesis stream?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Understanding AWS Kinesis Streams
AWS Kinesis is a platform on AWS to collect, process, and analyze real-time, streaming data to enable timely insights. One of the core components of AWS Kinesis is the Kinesis Data Streams service, which is designed to capture gigabytes of data per second from hundreds of thousands of sources such as website clickstreams, database event streams, and financial transactions.
Kinesis Streams consist of shards, which are uniquely identifiable sequences of data records within the stream in real time. When we talk about "fanout," we refer to distributing these records to multiple downstream consumers for processing.
Fanout in AWS Kinesis Streams
Fanout is the process where a published data stream is distributed to multiple destinations. In Kinesis Data Streams, there are primarily two methods for fanout:
- Enhanced Fan-Out: This allows multiple consumers to read data from a Kinesis stream with their own read throughput. Each consumer receives its own 2 MB/second outbound throughput per shard. It reduces latency and negates the need for complex data coordination across consumers.
- Standard Fan-Out: This allows all consumers to share the read throughput of the stream, up to the 5 transactions/second, 2 MB/second per shard limit.
Technical Explanation & Example
Enhanced Fan-Out
Enhanced Fan-Out enables real-time latency for your consumer applications. Each enhanced consumer gets a dedicated read throughput per shard, so reads are not subject to the total read caps of the shard. Here's how you can implement it:
- Create a Data Stream: Use the AWS Management Console or CLI to create a new Kinesis data stream.
- Scaling: Understand the scaling limits of your application. Enhanced Fan-Out provides greater scalability due to dedicated throughput.
- Cost Implications: Be aware of the cost implications of Enhanced Fan-Out. While it's more performant, it's also more expensive.
- Error Handling: Implement comprehensive error handling mechanisms to manage record processing failures, leveraging AWS CloudWatch logs and metrics.
- Utilize CloudWatch for monitoring data stream performance, shard usage, and consumer activity.
- Implement AWS X-Ray for debugging and analyzing the performance of your application components integrated with Kinesis.
Related reading
- how to fetch a field in ConsumerRecord
- How to fetch offset id while consuming Kafka from Spark, save it in Cassandra and use it to restart Kafka?
- How to fetch recent messages from Kafka topic
- How to filter messages from Kafka based on headers value in AWS lambda?
- how to figure out all messages with a specific groupId has been read from the queue in SQS?
- How to find AMI ID of CentOS 7 image in AWS Marketplace?
- how to find consumer group coordinator in kafka?
- How to find RabbitMQ URL?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.