# \[SOLVED\] Redis, memory leak issue

**URL:** <https://discuss.elastic.co/t/solved-redis-memory-leak-issue/35870>\
**Category:** Beats\
**Tags:** packetbeat\
**Created:** [November 30, 2015, 8:41am UTC](https://discuss.elastic.co/t/solved-redis-memory-leak-issue/35870 "2015-11-30T08:41:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamelg](https://avatars.discourse-cdn.com/v4/letter/h/ecae2f/32.png) [@hamelg](https://discuss.elastic.co/u/hamelg)\
**Post date:** [November 30, 2015, 8:41am UTC](https://discuss.elastic.co/t/solved-redis-memory-leak-issue/35870/1 "2015-11-30T08:41:49Z")

</div>

Hello,

Here is our setup :

Packbeat(v0.5) \* 8 \>\> Redis (v3.0.5) \<\< Logstash(v1.5.5) \>\> elasticsearch(v1.7.3)

We are very satisfy with this setup except we notice a memory leak on our redis server. Memory usage increases gradually every time, and finishes to reach the memory limit. When it's happening, we don't have any other choice to restart the redis server and all packetbeat agents.

Here is some graphs which show the activity on 6 hours.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/f/fc4e0c44e16ac85f418c061cf03db115def6897a.jpg)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/6/63e75471cab6689ff15d97cf251835988f8ed598.jpg)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/7/7e6455e14458bca2b64d5306dcfb8505eeec8a2f.jpg)

Anybody encounter this issue ?

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [November 30, 2015, 12:11pm UTC](https://discuss.elastic.co/t/solved-redis-memory-leak-issue/35870/2 "2015-11-30T12:11:01Z")

</div>

Are you sure it is a memory leak? With redis basically acting as a queue between packetbeat and logstash it is more likely your (single?) logstash instance being not able to handle all data in time.

Can you somehow find the rate with data being put into redis and the rate data are pulled from redis? E.g. redis [INFO command](http://redis.io/commands/INFO) returns total\_net\_input\_bytes and total\_net\_output\_bytes.

Have you considered upgrading packetbeat to v1.0.0 ? This version also support load balancing events onto multiple logstash instances.

---

<div class="post-metadata">

**Author:** ![hamelg](https://avatars.discourse-cdn.com/v4/letter/h/ecae2f/32.png) [@hamelg](https://discuss.elastic.co/u/hamelg)\
**Post date:** [November 30, 2015, 1:23pm UTC](https://discuss.elastic.co/t/solved-redis-memory-leak-issue/35870/3 "2015-11-30T13:23:06Z")

</div>

The graph above "Redis - commands queued" shows the metric got with the command "LLEN packetbeat" and "Redis - tps" show the metric total\_commands\_processed per second returned by INFO. When redis-server is reaching memory limit (used\_memory is reaching the redis setting maxmemory), the list is empty. We have tried some commands, like flushdb or flushall, but redis-serveur doesn't free memory.

Currently, I have checked used\_memory, checked total\_net\_input\_bytes and total\_net\_output\_bytes :  
total\_net\_input\_bytes:207476697388  
total\_net\_output\_bytes:395998419730  
used\_memory:1335612104  
"LLEN packetbeat" returns 0, and "KEYS \*" returns "(empty list or set)". What does it mean, total\_net\_input\_bytes should be equal to total\_net\_output\_bytes if all data is consumed by the logstash redis input pluggin ? Why 1Go memory used and no data stored ?

Yes, we have planned to upgrade to 1.0, but I ask me if it could solve our issue.

---

<div class="post-metadata">

**Author:** ![hamelg](https://avatars.discourse-cdn.com/v4/letter/h/ecae2f/32.png) [@hamelg](https://discuss.elastic.co/u/hamelg)\
**Post date:** [December 4, 2015, 9:37am UTC](https://discuss.elastic.co/t/solved-redis-memory-leak-issue/35870/4 "2015-12-04T09:37:37Z")

</div>

solved ! 😀

The memory was used by client connections, not for the data.  
I find out the root cause by reading the redis documentation [https://redis.io/docs/reference/clients/](http://redis.io/topics/clients)

each packetbeat clients were eating all the memory in connection handling, ie :

> client list  
> id=305 addr=10.204.5.199:29916 fd=14 name= age=72991 idle=1 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=2838444 **omem=179613873** events=rw cmd=rpush  
> ...

To fix my issue, I've set this parameter (the default value is unlimited !)  
client-output-buffer-limit normal 32000000 0 0

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 9:57pm UTC](https://discuss.elastic.co/t/solved-redis-memory-leak-issue/35870/5 "2017-07-05T21:57:43Z")

</div>


