5

We have two Nginx servers with independent local caches for caching images. Periodically there is problem with unmanaged growth of cache's size. This size may be far larger than max_size in nginx.conf. As a result cache occupies all free disk space.

I want to understand what the reason of this issue might be.

Proxy cache config (nginx.conf):

proxy_cache_path /opt2/nginx-cache-images1 max_size=150g levels=2:2 keys_zone=images1:1024m inactive=24h;
proxy_temp_path /opt2/proxy_temp 1 2;

Size of /opt2/nginx-cache-images1 is ~200GB.

Config of site location:

location / {
   proxy_set_header Host $host;
   proxy_set_header X-Forwarded-For $remote_addr;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Is-Referer-Search-Engine $is_referer_search_engine;
   proxy_hide_header Set-Cookie;
   proxy_hide_header Content-Disposition;
   proxy_pass http://ua-image-proxy;
   default_type image/jpeg;

   proxy_cache images1;
   proxy_cache_key ua$request_uri$is_referer_search_engine;
   proxy_cache_valid 200 24h;
   proxy_cache_valid 301 24h;
   proxy_cache_valid 404 1h;
}

Nginx version: 1.7.7 and 1.7.9. It was compiled on Ubuntu 14.04.

  • What is output of du -kcd1 /opt2/nginx-cache-images1 ? – masegaloeh Apr 23 '15 at 6:05
  • After restarting nginx service all things goes ok. But periodically this issue happens. Full output of du - link. – Vladyslav Zakhozhai Apr 23 '15 at 13:10
  • Also when the issue will happen I'll post another result of du command. – Vladyslav Zakhozhai Apr 23 '15 at 13:12
  • Now I have the same problem. Cache size is bigger than max_size. Result of du command you can see on the following link: link. Is it useful? – Vladyslav Zakhozhai Apr 23 '15 at 18:09
  • 1
    We have this on one of our busiest caches. It's like the cache manager just stops deleting anything for a period of time. Sometimes it recovers after a while and starts deleting a lot of files, only to start rising again. Often these situations seem to coincide with a burst of traffic. Judging by reports elsewhere this has been a problem since at least nginx 1.6.1. – GreenReaper Dec 28 '15 at 10:19
0

For me this was fixed in nginx 1.13.1:

Workaround: now cache manager ignores long locked cache entries when cleaning cache based on the "max_size" parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.