I'm repeatedly seeing this error in my nginx logs:
[crit] 30165#0: ngx_slab_alloc() failed: no memory in cache keys zone "api-data-cache"
Looking at the directory used for the cache key zone, I can see it's hovering around the 326MB mark:
du -s /usr/local/nginx/cache/
326652
However my nginx.conf specifies a max_size
of 1GB, so there should be plenty of room:
proxy_cache_path /usr/local/nginx/cache levels=1:2 keys_zone=api-data-cache:8m max_size=1g inactive=600m;
proxy_cache_key "$scheme$host$request_uri/$device_type$cookie_w3tc_referrer";
proxy_cache_use_stale updating timeout http_500 http_502 http_503 http_504;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
What could be going on here? There's plenty of disk space available (>50GB free) and after finding nothing relevant in the documentation, I'm at a bit of a loss.
You need to increase the size of shared memory on
keys_zone
instead ofmax_size
.Stealing answer from this thread
From the official documentation, it says one megabyte zone can store about 8 thousand keys. So, depending on your application you need to increase it as needed.