# Proxy\_cache calculating size error under SSD drive but not SATA drive

**URL:** <https://www.ruby-forum.com/t/proxy-cache-calculating-size-error-under-ssd-drive-but-not-sata-drive/245841>\
**Category:** NGINX\
**Created:** [July 18, 2013, 1:46pm UTC](https://www.ruby-forum.com/t/proxy-cache-calculating-size-error-under-ssd-drive-but-not-sata-drive/245841 "2013-07-18T13:46:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 18, 2013, 1:46pm UTC](https://www.ruby-forum.com/t/proxy-cache-calculating-size-error-under-ssd-drive-but-not-sata-drive/245841/1 "2013-07-18T13:46:49Z")

</div>

Hello:

I think I am on the right way, but not sure…

The scenario:

- Have 2 drives:  
 → SSD drive - XFS - default options (with  
noatime, discard) - almost empty  
 → SATA drive - XFS - default options -  
almost  
empty

- Kernel variables, shared memory, ulimits, max-file, etc… all  
correctly  
configured

- Nginx and virtualhost correctly configured.

- proxy\_cache\_path levels=1:2 keys\_zone=catalogo\_fotos:2500m  
max\_size=2500m inactive=120d;

Ok… here I am… it depends of the path… the problem is:

- If the path is at SATA drive → cache is growing until maximum 2500m  
are  
reached… no problem here. Normal…
- If the path is at SSD drive → cache is not growing until limit… it  
stale… problem… why?

If debug see:

2013/07/18 13:15:52 [debug] 17641#0: http file cache size: 640039  
2013/07/18 13:15:52 [debug] 17641#0: http file cache forced expire  
2013/07/18 13:15:52 [debug] 17641#0: http file cache forced expire: #0 1  
933590ab  
2013/07/18 13:15:52 [debug] 17641#0: http file cache expire:  
“/DATA/cache/catalogo\_fotos/7/3a/c1de7a39f5393c24933590ab20ba43a7”

while:

root@megaserver1 /DATA/cache # du -hs catalogomodacom\_fotos/  
1.8G catalogo\_fotos/  
root@megaserver1 /DATA/cache # find ./catalogo\_fotos/ -type f | wc -l  
17134

What happens?

Every 10 seconds, http file cache size detects max size and starts to  
force  
expire and delete cached files…

What is that “http file cache size: 640039” ??? That number, which way  
is  
calculated??? What it is?

I have enough shared memory, already properly configured (1Gb for each  
app  
and 14Gb total)… and the question is if I change path and set it  
under  
SATA drive there is no problem.

I am thinking at all at this “http file cache size: 640039”… I think  
it  
is the key about what is happening… that number is not near the max  
size  
of 2500m defined for the cache deposit, and is not near the number of  
files  
actually at cache, around 17134…

Could you help me please?

Thanks so much in advance.

Gino.

Posted at Nginx Forum:

> **[proxy\_cache calculating size error under SSD drive but not SATA drive](https://forum.nginx.org/read.php?2,240993,240993#msg-240993)**
>
> Hello: I think I am on the right way, but not sure... The scenario: - Have 2 drives: -\> SSD drive - XFS - default options (with noatime, discard) - almost empty -\> SATA drive - XFS

---

<div class="post-metadata">

**Author:** ![feanorknd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ec9cab/32.png) [@feanorknd](https://www.ruby-forum.com/u/feanorknd)\
**Post date:** [July 18, 2013, 4:44pm UTC](https://www.ruby-forum.com/t/proxy-cache-calculating-size-error-under-ssd-drive-but-not-sata-drive/245841/2 "2013-07-18T16:44:27Z")

</div>

Hello!

On Thu, Jul 18, 2013 at 07:46:01AM -0400, feanorknd wrote:

> empty  
> Ok.. here I am… it depends of the path… the problem is:
> 
> - If the path is at SATA drive → cache is growing until maximum 2500m are  
> reached… no problem here. Normal..
> - If the path is at SSD drive → cache is not growing until limit… it  
> stale… problem… why?

Try looking into this ticket:

> **[\#157 (cache max\_size limit applied incorrectly with xfs)
          – nginx](https://trac.nginx.org/nginx/ticket/157)**

With XFS, a file size reported on just created files before a file  
is closed is incorrect, and this might confuse nginx.

[…]

> What is that “http file cache size: 640039” ??? That number, which way is  
> calculated??? What it is?

This is the cache size in blocks.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![feanorknd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ec9cab/32.png) [@feanorknd](https://www.ruby-forum.com/u/feanorknd)\
**Post date:** [July 19, 2013, 2:55am UTC](https://www.ruby-forum.com/t/proxy-cache-calculating-size-error-under-ssd-drive-but-not-sata-drive/245841/3 "2013-07-19T02:55:38Z")

</div>

Thanks thanks so much!!! 😃

I even saw that ticket before posting, but I figured out it was not the  
problem just because I do use XFS for my nginx\_caches at 4 servers  
without  
this problem, and also I did test changing the path to point to a XFS  
partition on SATA drive, and the problem dissapeared.

If you have a look at the ticket, that user also use a SSD drive and  
have  
the alloc problem… it seems like if only at SSD drives, the size  
notification is incorrect because of the allocsize, but not on SATA  
drives,  
although the allocsize is default for both of them, at least in my  
case!!!

Have a look at my first post and see at SATA drive, with XFS defaults,  
the  
cache gets fullfilled exactly and if I configure 2500Gb, the “du -hs”  
when  
core starts force expiring objects, is just that 2500Gb… the  
measures al  
exact and real.

Not the same for SSD.. do you think people is something to review by  
developers somehow?

Thanks.

## Maxim D. Wrote:

> [nginx: donation](http://nginx.org/en/donation.html)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,240993,241022#msg-241022](http://forum.nginx.org/read.php?2,240993,241022#msg-241022)

---

<div class="post-metadata">

**Author:** ![feanorknd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ec9cab/32.png) [@feanorknd](https://www.ruby-forum.com/u/feanorknd)\
**Post date:** [July 19, 2013, 12:05pm UTC](https://www.ruby-forum.com/t/proxy-cache-calculating-size-error-under-ssd-drive-but-not-sata-drive/245841/4 "2013-07-19T12:05:58Z")

</div>

Hello!

On Thu, Jul 18, 2013 at 08:54:48PM -0400, feanorknd wrote:

> although the allocsize is default for both of them, at least in my case!!!
> 
> Have a look at my first post and see at SATA drive, with XFS defaults, the  
> cache gets fullfilled exactly and if I configure 2500Gb, the “du -hs” when  
> core starts force expiring objects, is just that 2500Gb… the measures al  
> exact and real.
> 
> Not the same for SSD.. do you think people is something to review by  
> developers somehow?

Depending on media used XFS might apply different defaults, and/or  
observed behaviour might be different due to timing reasons.  
Quick search suggests XFS currently uses dynamic allocsize by  
default, see here:

> **[xfs: dynamic speculative EOF preallocation - kernel/git/torvalds/linux.git -...](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=055388a3188f56676c21e92962fc366ac8b5cb72)**

Try forcing allocsize to something like 4k to see if it helps.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![feanorknd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ec9cab/32.png) [@feanorknd](https://www.ruby-forum.com/u/feanorknd)\
**Post date:** [July 18, 2013, 2:32pm UTC](https://www.ruby-forum.com/t/proxy-cache-calculating-size-error-under-ssd-drive-but-not-sata-drive/245841/5 "2013-07-18T14:32:59Z")

</div>

Hello:

Each 10 seconds, the core force expires files until http cache size  
below  
640000 (limits are defined at 2500Mb at config)

grep “cache size” /STORAGE/log.txt  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640339  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640317  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640297  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640262  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640248  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640236  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640226  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640217  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640207  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640197  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640167  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640157  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640141  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640124  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640115  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640057  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 640040  
2013/07/18 13:15:22 [debug] 17641#0: http file cache size: 639904  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640192  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640188  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640154  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640115  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640106  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640097  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640083  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640074  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640050  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640042  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640026  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 640011  
2013/07/18 13:15:32 [debug] 17641#0: http file cache size: 639997  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640397  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640380  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640368  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640343  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640330  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640306  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640158  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640149  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640139  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640130  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640119  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640110  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640101  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640092  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640072  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640062  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640049  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 640025  
2013/07/18 13:15:42 [debug] 17641#0: http file cache size: 639944

Hope it helps…

For the proccesor, the max http file cache size is 640000 (but only  
for  
this proxy\_cache… i have more!!!)

Thanks.

Posted at Nginx Forum:

> **[Re: proxy\_cache calculating size error under SSD drive but not SATA drive](https://forum.nginx.org/read.php?2,240993,240995#msg-240995)**
>
> Hello: I think I am on the right way, but not sure... The scenario: - Have 2 drives: -\> SSD drive - XFS - default options (with noatime, discard) - almost empty -\> SATA drive - XFS
