<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Apache nifi memory consumption in kubernetes in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Apache-nifi-memory-consumption-in-kubernetes/m-p/412507#M253500</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/20288"&gt;@Shelton&lt;/a&gt;&amp;nbsp;Thank you for the detailed answer, much appreciated !&lt;/P&gt;</description>
    <pubDate>Fri, 26 Sep 2025 11:06:53 GMT</pubDate>
    <dc:creator>hegdemahendra</dc:creator>
    <dc:date>2025-09-26T11:06:53Z</dc:date>
    <item>
      <title>Apache nifi memory consumption in kubernetes</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-nifi-memory-consumption-in-kubernetes/m-p/409048#M252794</link>
      <description>&lt;P&gt;Hello experts,&lt;/P&gt;&lt;P&gt;We are running nifi 1.25.0 version in Kubernetes, single pod in cluster mode.&lt;/P&gt;&lt;P&gt;Memory limit for the pod is 40G and JVM configured for Nifi is 28G.&lt;/P&gt;&lt;P&gt;Now we are facing OOM error once in a while.&lt;/P&gt;&lt;P&gt;When we checked nifi GUI System diagnostic it shows only 3G usage (Heap + non-heap)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hegdemahendra_0-1748582018662.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/45581iA92337025AC9980F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hegdemahendra_0-1748582018662.png" alt="hegdemahendra_0-1748582018662.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But when we checked at pod level memory usage for nifi process it shows very high usage.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hegdemahendra_1-1748582110804.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/45582i01D2F73FC97DE5BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hegdemahendra_1-1748582110804.png" alt="hegdemahendra_1-1748582110804.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What else could be consuming so much memroy?&lt;/P&gt;&lt;P&gt;This pod has only nifi container running&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Mahendra&lt;/P&gt;</description>
      <pubDate>Fri, 30 May 2025 05:15:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-nifi-memory-consumption-in-kubernetes/m-p/409048#M252794</guid>
      <dc:creator>hegdemahendra</dc:creator>
      <dc:date>2025-05-30T05:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Apache nifi memory consumption in kubernetes</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-nifi-memory-consumption-in-kubernetes/m-p/409196#M252829</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/37332"&gt;@hegdemahendra&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a classic case of off-heap memory consumption in NiFi. The 3G you see in the GUI only represents JVM heap + non-heap memory, but NiFi uses significant additional memory outside the JVM that doesn't appear in those metrics. Next time could you share your deployment YAML files&amp;nbsp; that would help with solutioning&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Root Causes of Off-Heap Memory Usage:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Content Repository (Primary Culprit)&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;NiFi uses memory-mapped files for the content repository&lt;/LI&gt;&lt;LI&gt;Large FlowFiles are mapped directly into memory&lt;/LI&gt;&lt;LI&gt;This memory appears as process memory but not JVM memory&lt;/LI&gt;&lt;/UL&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Provenance Repository&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;Uses Lucene indexes that consume off-heap memory&lt;/LI&gt;&lt;LI&gt;Memory-mapped files for provenance data storage&lt;/LI&gt;&lt;/UL&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Native Libraries&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;Compression libraries (gzip, snappy)&lt;/LI&gt;&lt;LI&gt;Cryptographic libraries&lt;/LI&gt;&lt;LI&gt;Network I/O libraries&lt;/LI&gt;&lt;/UL&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Direct Memory Buffers&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;NIO operations use direct ByteBuffers&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Network and file I/O operations&lt;BR /&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;U&gt;Possible Solutions:&lt;/U&gt;&lt;BR /&gt;1. Reduce JVM Heap Size&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Instead of 28G JVM heap, try:
NIFI_JVM_HEAP_INIT: "16g"
NIFI_JVM_HEAP_MAX: "16g"&lt;/LI-CODE&gt;&lt;P&gt;This leaves more room (24G) for off-heap usage.&lt;/P&gt;&lt;H3&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;2. Configure Direct Memory Limit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;P&gt;Add JVM arguments:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;-XX:MaxDirectMemorySize=8g​&lt;/LI-CODE&gt;&lt;H3&gt;&amp;nbsp;&lt;FONT size="4"&gt;&lt;STRONG&gt;3. Content Repository Configuration&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;P&gt;&amp;nbsp; In nifi.properties:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Limit content repository size
nifi.content.repository.archive.max.retention.period=1 hour
nifi.content.repository.archive.max.usage.percentage=50%

# Use file-based instead of memory-mapped (if possible)
nifi.content.repository.implementation=org.apache.nifi.controller.repository.FileSystemRepository&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;FONT size="4"&gt;4. &lt;STRONG&gt;Provenance Repository Tuning&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Reduce provenance retention
nifi.provenance.repository.max.storage.time=6 hours
nifi.provenance.repository.max.storage.size=10 GB&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;&amp;nbsp;Long-term Solutions:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;1. Increase Pod Memory Limit&lt;BR /&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;&lt;LI-CODE lang="markup"&gt;resources:
  limits:
    memory: "60Gi"  # Increase from 40G
  requests:
    memory: "50Gi"&lt;/LI-CODE&gt;&lt;H3&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;2. Monitor Off-Heap Usage&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;Enable JVM flags for better monitoring:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;-XX:NativeMemoryTracking=summary
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintNMTStatistics&lt;/LI-CODE&gt;&lt;H3&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;3. Implement Memory-Efficient Flow Design&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;Process smaller batches&lt;/LI&gt;&lt;LI&gt;Avoid keeping large FlowFiles in memory&lt;/LI&gt;&lt;LI&gt;Use streaming processors where possible&lt;/LI&gt;&lt;LI&gt;Implement backpressure properly&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;4. Consider Multi-Pod Deployment&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;Instead of single large pod, use multiple smaller pods:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# 3 pods with 20G each instead of 1 pod with 40G
replicas: 3
resources:
  limits:
    memory: "20Gi"&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;Monitoring Commands:&lt;BR /&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Check native memory tracking
kubectl exec -it &amp;lt;nifi-pod&amp;gt; -- jcmd &amp;lt;pid&amp;gt; VM.native_memory summary
# Monitor process memory
kubectl top pod &amp;lt;nifi-pod&amp;gt;
# Check memory breakdown
kubectl exec -it &amp;lt;nifi-pod&amp;gt; -- cat /proc/&amp;lt;pid&amp;gt;/status | grep -i mem&lt;/LI-CODE&gt;&lt;P&gt;&lt;FONT size="3"&gt;Start with reducing JVM heap to 16G and implementing content repository limits. This should immediately reduce OOM occurrences while you plan for longer-term solutions. Always remember to share your configuration files with the vital data masked or scramble.&lt;BR /&gt;Happy hadooping&lt;/FONT&gt;&lt;/P&gt;&lt;P class="whitespace-normal break-words"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="whitespace-normal break-words"&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;</description>
      <pubDate>Thu, 05 Jun 2025 06:36:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-nifi-memory-consumption-in-kubernetes/m-p/409196#M252829</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2025-06-05T06:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Apache nifi memory consumption in kubernetes</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-nifi-memory-consumption-in-kubernetes/m-p/412507#M253500</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/20288"&gt;@Shelton&lt;/a&gt;&amp;nbsp;Thank you for the detailed answer, much appreciated !&lt;/P&gt;</description>
      <pubDate>Fri, 26 Sep 2025 11:06:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-nifi-memory-consumption-in-kubernetes/m-p/412507#M253500</guid>
      <dc:creator>hegdemahendra</dc:creator>
      <dc:date>2025-09-26T11:06:53Z</dc:date>
    </item>
  </channel>
</rss>

