Skip to main content

Memory consumption in Flume


Memory required by each Source or Sink

The heap memory used by a single event is dominated by the data in the event body with some incremental usage by any headers added. So in general, a source or a sink will allocate roughly the size of the event body + maybe 100 bytes of headers (this is affected by headers added by the txn agent). To get the total memory used by a single batch, multiply your average (or 90th percentile) event
size (plus some additional buffer) by the maximum batch size. This will give you the memory needed by a single batch.

The memory required for each Sink is the memory needed for a single batch and the memory required for each Source is the memory needed for a single batch, multiplied by the number of clients simultaneously connected to the Source. Keep this in mind, and plan your event delivery according to your expected throughput.

Memory required by each File Channel

Under normal operation, each File Channel uses some heap memory and some direct memory. Give each File channel roughly 30MB of heap memory for basic operational overhead. Each File channel also needs an amount of direct memory roughly equal to 1MB + (capacity of channel * 8) bytes because Flume is storing the updates in a hashmap.

For fast replay without a checkpoint, the file channel can use up to (channel capacity * 32) bytes of heap memory. The amount of memory actually used depends on the number of events present in the log files being replayed. So, if the file channel holds 100 million events, the replay will require about 3.2 GB of heap memory. In order to enable fast checkpoint-less replay, you must set the configuration option use-fast-replay to true, i.e.: = true

If that option is not explicitly enabled, then replay without a checkpoint will be slower, but it will use significantly less memory: on the order of normal operation of the file channel as specified above.
Memory required by the Flume core itself

Add to the total heap size roughly 50MB for the Flume core. Finally, adding a healthy buffer to calculated estimates is recommended. JVM memory usage in production can be monitored & graphed using JMX, to get a better understanding of real-world memory allocation behavior given a particular workload. I wrote a article about JMX monitoring in past.

Example memory settings

As you know, Flume reads out the environment variables over their, which is disabled per default (named as $FLUME/conf/ Simply rename them into and tweak the settings according your requirements you have calculated. Also it is always a good idea to initialize the needed memory on startup, instead to add them later to avoid Juliet pauses when fresh memory will be allocated.

A example for a larger memory tweaking with GC tuning could look like

# sets minimum memory to 2GB, max to 16GB, max direct memory to 256MB
# also uses the parallel new and concurrent garbage collectors to reduce the likelihood of long stop-the-world GC pauses
JAVA_OPTS="-Xms2000m -Xmx16000m -Xss128k -XX:MaxDirectMemorySize=256m
-XX:+UseParNewGC -XX:+UseConcMarkSweepGC"

Posted in Flume Wiki too


Popular posts from this blog

Deal with corrupted messages in Apache Kafka

Under some strange circumstances it can happen that a message in a Kafka topic is corrupted. This happens often by using 3rd party frameworks together with Kafka. Additionally, Kafka < 0.9 has no lock at at the consumer read level, but has a lock on Log.write(). This can cause a rare race condition, as described in KAKFA-2477 [1]. Probably a log entry looks like: ERROR Error processing message, stopping consumer: ($) kafka.message.InvalidMessageException: Message is corrupt (stored crc = xxxxxxxxxx, computed crc = yyyyyyyyyy Kafka-Tools Kafka stores the offset of every consumer in Zookeeper. To read out the offsets, Kafka provides handy tools [2]. But also can be used, at least to display the consumer and the stored offsets. First we need to find the consumer for a topic (> Kafka 0.9): bin/ --zookeeper management01:2181 --describe --group test Prior to Kafka 0.9 the only possibility to get this inform

Hive query shows ERROR "too many counters"

A hive job face the odd " Too many counters:"  like Ended Job = job_xxxxxx with exception 'org.apache.hadoop.mapreduce.counters.LimitExceededException(Too many counters: 201 max=200)' FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MapRedTask Intercepting System.exit(1) These happens when operators are used in queries ( Hive Operators ). Hive creates 4 counters per operator, max upto 1000, plus a few additional counters like file read/write, partitions and tables. Hence the number of counter required is going to be dependent upon the query.  To avoid such exception, configure " mapreduce.job.counters.max " in mapreduce-site.xml to a value above 1000. Hive will fail when he is hitting the 1k counts, but other MR jobs not. A number around 1120 should be a good choice. Using " EXPLAIN EXTENDED " and " grep -ri operators | wc -l " print out the used numbers of operators. Use this value to tweak the MR s

GPT & GenAI for Startup Storytelling

OpenAI and Bard   are the most used GenAI tools today; the first one has a massive Microsoft investment, and the other one is an experiment from Google. But did you know that you can also use them to optimize and hack your startup?  For startups, creating pitch scripts, sales emails, and elevator pitches with generative AI (GenAI) can help you not only save time but also validate your marketing and wording. Curious? Here are a few prompt hacks for startups to create,improve, and validate buyer personas, your startup's mission/vision statements, and unique selling proposition (USP) definitions. First Step: Introduce yourself and your startup Introduce yourself, your startup, your website, your idea, your position, and in a few words what you are doing to the chatbot: Prompt : I'm NAME and our startup NAME, with website URL, is doing WHATEVER. With PRODUCT NAME, we aim to change or disrupt INDUSTRY. Bard is able to pull information from your website. I'm not sure if ChatGPT