# What can lead to a zone memory exhaustion and how Nginx reacts to it?

**URL:** <https://www.ruby-forum.com/t/what-can-lead-to-a-zone-memory-exhaustion-and-how-nginx-reacts-to-it/226476>\
**Category:** NGINX\
**Created:** [December 7, 2012, 10:28pm UTC](https://www.ruby-forum.com/t/what-can-lead-to-a-zone-memory-exhaustion-and-how-nginx-reacts-to-it/226476 "2012-12-07T22:28:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mehhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@Mehhy](https://www.ruby-forum.com/u/Mehhy)\
**Post date:** [December 7, 2012, 10:28pm UTC](https://www.ruby-forum.com/t/what-can-lead-to-a-zone-memory-exhaustion-and-how-nginx-reacts-to-it/226476/1 "2012-12-07T22:28:38Z")

</div>

What is a possible scenario for exhausting the memory designated to a  
connection zone with limit\_conn\_zone directive and what are the  
implication  
in this case?

Suppose I have this in my configuration:

```
http {
  limit_conn_zone $binary_remote_addr zone=connzone:1m;
  ...
  server {
    limit_conn connzone 5;

```

which, according to the documentation, allocates 16000 states for  
‘connzone’  
on a 64-bit server. It also says that “If the storage for a zone is  
exhausted, the server will return error 503 (Service Temporarily  
Unavailable) to all further requests”.

Well, Ok. But what does it mean on practice? When does this happen? Who  
receives those 503s? Does it mean that if the number of IPs _somehow_  
associated with ‘connzone’ hits 16000 everyone gets a 503 and it’s all  
over?  
How does Nginx decide? The documentation is weirdly vague on this.

So, considering the example config, who would actually get a 503 and  
under  
which circumstances and how would things go from there? Same with  
request  
zones?

Posted at Nginx Forum:

> **[What can lead to a zone memory exhaustion and how Nginx reacts to it?](https://forum.nginx.org/read.php?2,233709,233709#msg-233709)**
>
> What is a possible scenario for exhausting the memory designated to a connection zone with limit\_conn\_zone directive and what are the implication in this case? Suppose I have this in my configuration: http { limit\_conn\_zone $binary\_remote\_addr...

---

<div class="post-metadata">

**Author:** ![Mehhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@Mehhy](https://www.ruby-forum.com/u/Mehhy)\
**Post date:** [December 8, 2012, 6:35am UTC](https://www.ruby-forum.com/t/what-can-lead-to-a-zone-memory-exhaustion-and-how-nginx-reacts-to-it/226476/2 "2012-12-08T06:35:46Z")

</div>

On Fri, Dec 07, 2012 at 04:28:21PM -0500, Mehhy wrote:

> ```
> limit_conn connzone 5;
> 
> ```
> 
> So, considering the example config, who would actually get a 503 and under  
> which circumstances and how would things go from there? Same with request  
> zones?

The server will be able to track the number of connections for  
~16k distinct client IP addresses. If you happen to have that  
many active clients, then the next connection attempt from the  
client whose IP is not yet known will attempt to create a new  
state, that will fail because zone is exhausted and the client  
will be returned 503.

---

<div class="post-metadata">

**Author:** ![Mehhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@Mehhy](https://www.ruby-forum.com/u/Mehhy)\
**Post date:** [December 8, 2012, 1:16pm UTC](https://www.ruby-forum.com/t/what-can-lead-to-a-zone-memory-exhaustion-and-how-nginx-reacts-to-it/226476/3 "2012-12-08T13:16:27Z")

</div>

Thanks a bunch.

Posted at Nginx Forum:

> **[Re: What can lead to a zone memory exhaustion and how Nginx reacts to it?](https://forum.nginx.org/read.php?2,233709,233729#msg-233729)**
>
> What is a possible scenario for exhausting the memory designated to a connection zone with limit\_conn\_zone directive and what are the implication in this case? Suppose I have this in my configuration: http { limit\_conn\_zone $binary\_remote\_addr...
