limit_zone memory exhausted

Matthieu Tourne matthieu.tourne at
Fri Mar 25 21:35:10 MSK 2011


Yesterday error messages similar to this started filling up the logs :

Mar 25 01:58:22 [nginx_error] 3m2: 2011/03/25 01:58:21 [crit]
26278#0: ngx_slab_alloc() failed: no memory in limit_zone "limit_inbound"

And more importantly nginx started returning "503 Service Temporary
Unavalaible" for every requests

The solution was simple, as to increase the memory assigned to the
limit_zone rbtree.

I was thinking instead of returning NGX_HTTP_SERVICE_UNAVAILABLE when the
allocation fails, maybe NGX_DECLINED should be returned so we keep accepting
requests if there is a problem with ngx_http_limit_zone_module rather than
blocking by default.

I attached a diff for the proposed modification below.

Thank you,

diff --git a/src/http/modules/ngx_http_limit_zone_module.c
index 36da49c..5a20d8c 100644
--- a/src/http/modules/ngx_http_limit_zone_module.c
+++ b/src/http/modules/ngx_http_limit_zone_module.c
@@ -235,7 +235,7 @@ ngx_http_limit_zone_handler(ngx_http_request_t *r)
     node = ngx_slab_alloc_locked(shpool, n);
     if (node == NULL) {
+        return NGX_DECLINED;

     lz = (ngx_http_limit_zone_node_t *) &node->color;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list