Forum: NGINX Cache calculating erroneous size

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Giovani Rinaldi (Guest)
on 2016-07-05 21:44
(Received via mailing list)

I've been experiencing a rather strange situation regarding the cache
occupation (calculated by nginx's cache manager and reported in debug
versus the real occupied size as reported by `df`. Just exemplifying:

- reported by cache manager:  76009.340M disk space used,  19458391 disk
blocks (4K) used, 2583292 unique files in cache.
- reported by df: 64203.512M of disk space used, 16436099 disk blocks
used, 2583861 unique files in cache (this number is an approximation,
to find command taking more time to return).

So, in resume, Nginx is counting files correctly, but not their
sizes/blocks used (it is my understanding that it count blocks, not

As a consequence, when the calculated cache size reaches the max_size
defined in proxy_cache_path, forced evictions start occurring. I must
out that these evictions are due to max_size reached and not inactive
(I differentiate both of these cases in debug log messages) or file
watermark (related to keyzone capacity) being reached.

Here's the configuration of my proxy cache:

proxy_cache_path /xfs/http levels=1:2 keys_zone=smallfiles:800m
> max_size=100g inactive=90d;
proxy_temp_path /tmp;

First I thought this could be related to allocsize in XFS (, but the problem persists even
when utilizing 4K instead of the default (64K).

Also I must point out that there's another cache zone being utilized
with XFS but in another disk)  by the same nginx servers, though it is
utilized for caching larger files (more than 1Mb in size in average),
it does not suffer from this cache size discrepancy.

Restarting Nginx (or upgrading it) solves temporarily the problem, as
cache loader correctly calculates the total cache size.

This topic is locked and can not be replied to.