# Root Causing InfluxDB's High Memory Usage

**URL:** <https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745>\
**Category:** InfluxDB 2\
**Tags:** influxdb\
**Created:** [August 26, 2020, 12:38pm UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745 "2020-08-26T12:38:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrAbhishek](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mrAbhishek](https://community.influxdata.com/u/mrAbhishek)\
**Post date:** [August 26, 2020, 12:38pm UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/1 "2020-08-26T12:38:03Z")

</div>

Hi,

I am running influxdb version 1.7 inside a docker container but recently i saw that the memory usage went up to 95% i.e. using 30gb of ram out of 32gb.I was not able to root cause it as to know what is causing such high memory usage so that i can work on it. Therefore, i wanted to know if there is any way to diagnose the problem or any CLI commands to check what is causing this issue.I did check the cardinality which is estimated at 118666. I am not so sure whether cardinality is an issue or there is any other problem.Please help.

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [August 27, 2020, 7:13pm UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/2 "2020-08-27T19:13:23Z")

</div>

@mrAbhishek - How much data do you have (in GB)? If more than 30GB, then this memory profile is not unexpected as InfluxDB memory maps the storage files into memory for better performance - it will attempt to use as much as the OS (or docker container) will give it.

If you’re not experiencing any problems, I would not dwell on the memory usage taking up most of what is available.

---

<div class="post-metadata">

**Author:** ![mrAbhishek](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mrAbhishek](https://community.influxdata.com/u/mrAbhishek)\
**Post date:** [August 28, 2020, 6:04am UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/3 "2020-08-28T06:04:22Z")

</div>

hey @philjb, thanks for replying.Sorry i mistakenly wrote that it is taking 30gb ram out of 32 gb(it was total ram usage), actually it is using around 18-20 gb of ram and i checked out that influxdb occupies 6.3gb of data on disk.So,

1. This is not the expected behavior and how can i debug to know what is causing this issue
2. Is there any setting in configuration of influx so that i can limit the memory usage by influx.

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [August 28, 2020, 6:54pm UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/4 "2020-08-28T18:54:15Z")

</div>

Using the new numbers, and generally speaking, your memory usage is not unexpected given we need to account for golang’s heap, the series file index, and memory mapping of the data store.

You can decrease the memory in the container which will set a cap on the amount influxdb will use. You can also reduce your data usage by decreasing the retention period.

Are you seeing adverse behavior or problems?

---

<div class="post-metadata">

**Author:** ![mrAbhishek](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mrAbhishek](https://community.influxdata.com/u/mrAbhishek)\
**Post date:** [September 1, 2020, 8:02am UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/5 "2020-09-01T08:02:13Z")

</div>

There are no adverse problems but we are still looking on how to limit the ram usage by influx. Do you think `cache-snapshot-memory-size` might help or any other configuration setting because we don’t want to cap it from the container side.

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [September 1, 2020, 4:14pm UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/6 "2020-09-01T16:14:40Z")

</div>

There’s no setting specifically for controlling memory usage within Influx 1.x. You can use OS level settings to change how much memory is available for mmap. Indirectly, you can reduce data stored in Influx through a smaller retention period and/or downsampling. If you do constrain memory, I would expect to see decreased performance as the OS pulls mmap’d data in and out more frequently.

---

<div class="post-metadata">

**Author:** ![mrAbhishek](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mrAbhishek](https://community.influxdata.com/u/mrAbhishek)\
**Post date:** [September 2, 2020, 8:58am UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/7 "2020-09-02T08:58:20Z")

</div>

I have one more question say if we don’t configure anything , will influx take up all the memory and OOM will happen or will influx bring down memory usage automatically when its nearing hundred?

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [September 2, 2020, 5:17pm UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/8 "2020-09-02T17:17:09Z")

</div>

Most of the memory usage by Influxdb is memory mapped files which the OS controls. The OS should release pages as it needs memory for other uses, at the expensive of more disk io.

---

<div class="post-metadata">

**Author:** ![watery](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/watery/32/9661_2.png) [@watery](https://community.influxdata.com/u/watery)\
**Post date:** [March 11, 2022, 10:54am UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/9 "2022-03-11T10:54:25Z")

</div>

Hi, using InfluxDB 1.8 inside a Docker container on an Ubuntu 20 virtual machine, with 32GB RAM and 8GB swap (as reported by `htop`).

Data on disk is more than 110GB and the kernel keeps killing the process due to Out Of Memory errors (found usign `dmesg`).

What should I do? Increasing the available RAM won’t be an option - we may add another 16GB but that would be a hard limit.

The data has been collected in around a year of usage. I think I could reduce various settings about data you already mentioned (retention, etc), but I guess this will only move the OOM forward in time, not avoid it at all, am I right?

---

<div class="post-metadata">

**Author:** ![Aliaksandr\_Valialkin](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/aliaksandr_valialkin/32/7365_2.png) [@Aliaksandr\_Valialkin](https://community.influxdata.com/u/Aliaksandr_Valialkin)\
**Post date:** [June 4, 2023, 9:54pm UTC](https://community.influxdata.com/t/root-causing-influxdbs-high-memory-usage/15745/10 "2023-06-04T21:54:21Z")

</div>

Try VictoriaMetrics. It uses up to 10x less RAM than InfluxDB on the same workload - [FAQ · VictoriaMetrics](https://docs.victoriametrics.com/FAQ.html#how-does-victoriametrics-compare-to-influxdb)
