# Consul cache OOM

**URL:** <https://discuss.hashicorp.com/t/consul-cache-oom/6516>\
**Category:** Consul\
**Created:** [March 4, 2020, 5:13pm UTC](https://discuss.hashicorp.com/t/consul-cache-oom/6516 "2020-03-04T17:13:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amit-handda](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/amit-handda/32/4624_2.png) [@amit-handda](https://discuss.hashicorp.com/u/amit-handda)\
**Post date:** [March 4, 2020, 5:13pm UTC](https://discuss.hashicorp.com/t/consul-cache-oom/6516/1 "2020-03-04T17:13:54Z")

</div>

I am trying to play around with consul caching behaviour. (use\_cache: true)  
If I do DNS querying for non-existent services (1 million of them), I can swamp the agent/server cache.

What can I do to prevent consul from this ddos behaviour ? (aside from disabling the cache altogether ?)

I see that there is an issue already created in consul for the same … hope I am not missing anything.

> <https://github.com/hashicorp/consul/issues/4968>
>
> Currently cache can grow without bound. I think there are several aspects we should address here but not sure how yet.
> Reduced...

---

<div class="post-metadata">

**Author:** ![jsosulska](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jsosulska/32/2344_2.png) [@jsosulska](https://discuss.hashicorp.com/u/jsosulska)\
**Post date:** [March 9, 2020, 8:50pm UTC](https://discuss.hashicorp.com/t/consul-cache-oom/6516/2 "2020-03-09T20:50:45Z")

</div>

Hi @amit-handda

I’ll follow up on this and get back to you in the next few days. Since this is an older issue, I’d like to collect some data 🙂  
Can you please provide some information around what your Consul deployment looks like? How many Servers/Agents are you running?  
How are you doing this testing?  
What use case are you testing for?

Thanks again for a great question 🙂

---

<div class="post-metadata">

**Author:** ![amit-handda](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/amit-handda/32/4624_2.png) [@amit-handda](https://discuss.hashicorp.com/u/amit-handda)\
**Post date:** [March 9, 2020, 9:13pm UTC](https://discuss.hashicorp.com/t/consul-cache-oom/6516/3 "2020-03-09T21:13:11Z")

</div>

Hi (again),

consul server cluster: 3 node cluster(ec2 nodes c5.2xlarge)  
single consul agent on another node : c4.2XL  
note: use\_cache is true for the cluster and agent.

benchmarking tool: an adaptation of [https://github.com/rakyll/hey](https://github.com/rakyll/hey)

**testing methodology**

DDOS the agent’s dns port with service resolution requests (@1200 concurrency).  
total service resolutions invoked are around 1 million . most of these services are not registered in the cluster/agent.

I am testing for the performance and resiliency of the consul setup.

**Issue** is (as detailed in original post), agent/servers consume all of the server RAM -\> go out of memory. Hence, it would be nice to fix the indicated consul issue (#4968) to control the agent cache.
