Flume use case reading from HTTP and push to HDFS via Kafka
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Flume is a distributed, reliable, and available system for efficiently collecting, aggregating, and moving large volumes of log data. Its primary use is to gather log data from various sources and send it to a centralized data store. The integration of Apache Flume with Apache Kafka and HDFS (Hadoop Distributed File System) broadens its usability, enabling robust data ingestion pipelines that are scalable and fault-tolerant. In this article, we discuss a specific use case: reading data from an HTTP source and pushing it to HDFS via Kafka, detailing how each component fits into the architecture and provides practical configuration snippets.
Overview of Components
Apache Flume
Flume's architecture is straightforward, consisting of sources, channels, and sinks. In our use case:
- Source: HTTP Source — collects data sent over HTTP.
- Sink: Kafka Sink — pushes data to a Kafka topic.
Apache Kafka
A distributed streaming platform that can publish, subscribe to, stream, store, and process streams of records in real time. In this scenario, it acts as a message buffer and transportation layer between Flume and HDFS.
HDFS
A distributed file system designed to store very large datasets reliably, and to stream those data sets at high bandwidth to user applications. In this case, it acts as the final destination for the data.
Architecture Flow
- Data Ingestion: Data is sent to Flume via an HTTP POST request.
- Flume Configuration: The HTTP Source receives this data and passes it onto a channel.
- Data Transfer via Kafka: Data in the channel is consumed by a Kafka Sink, which pushes it to a Kafka topic.
- Data Consumption: A separate Flume agent with a Kafka Source and an HDFS Sink reads from the Kafka topic and writes into HDFS.
Configuration Examples
1. Flume Configuration for HTTP Source to Kafka Sink
2. Flume Configuration for Kafka Source to HDFS Sink
Key Points Summary
| Component | Role | Configuration Key | Remarks |
| HTTP Source | Collects Data | type: http, port: 5140, bind: 0.0.0.0 | Listens for incoming data over HTTP. |
| Kafka Sink | Pushes to Kafka | type: kafka, brokerList, topic | Ensures reliable delivery to Kafka topic. |
| Kafka Source | Reads from Kafka | type: kafka, zookeeperConnect, topic | Retrieves data from Kafka for processing or storage. |
| HDFS Sink | Writes to HDFS | type: hdfs, hdfs.path, hdfs.fileType | Stores data into HDFS. Configurable to handle data formats and replication factors. |
Additional Considerations
- Scalability: Both Kafka and Flume are horizontally scalable. You can increase the number of Flume agents and Kafka brokers based on throughput requirements.
- Fault Tolerance: Kafka provides built-in fault tolerance through replication. Ensure that Flume's channel is configured to handle failures (e.g., by using a file channel instead of memory for higher reliability).
- Monitoring and Management: Utilize tools like Apache NiFi or commercial solutions for more intricate setups or when additional features like visual management, enhanced security, and fine-grained control are necessary.
Conclusion
Integrating Flume with Kafka and HDFS provides a potent solution for robust data pipelines capable of handling high throughput and providing reliability, making it suitable for scenarios where data loss is not acceptable. This setup is commonly used in logging and event processing in large-scale systems, where resilience, scalability, and data integrity are paramount.
Related reading
- For AvroProducer to Kafka, where are avro schema for key and value?
- For how long data is stored in kafka server?
- Force Confluent s3 sink to flush
- Force kafka consumer to poll partition with highest lag
- General techniques to work with huge amounts of data on a non-super computer
- Get context from Pod launched with Airflow KubernetesPodOperator
- Flush CoreDNS Cache on Kubernetes Cluster
- Forbidden to access Kubernetes API Server

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.