# Nginx fastcgi\_cache not freeing deleted items causing excessive disk usage

**URL:** <https://www.ruby-forum.com/t/nginx-fastcgi-cache-not-freeing-deleted-items-causing-excessive-disk-usage/244733>\
**Category:** NGINX\
**Created:** [June 5, 2016, 5:32pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-cache-not-freeing-deleted-items-causing-excessive-disk-usage/244733 "2016-06-05T17:32:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [June 5, 2016, 5:32pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-cache-not-freeing-deleted-items-causing-excessive-disk-usage/244733/1 "2016-06-05T17:32:49Z")

</div>

Hello,

I’m using nginx 1.10.0 and the nginx\_fastcgi\_cache option. I’ve noticed  
that  
with a high amount of requests per second (I’m not sure when it occurs  
exactly, but we have ~2500RPS with about 2Gbit/s of outgoing traffic  
responses) there is an issue with the fastcgi\_cache files not being  
freed.  
lsof shows a huge amount of files as (deleted) but the space it not  
being  
freed. Eventually the entire partition fills up like this.

The keys\_zone and max\_size are both set to 500m  
The fastcgi\_cache\_valid is set to 1m

Even when the server is idle for a while (30+ minutes) the space is not  
being freed. Obviously restarting nginx manually immediately frees the  
space.

Is this a bug or is there a setting I can use to perform some sort of  
garbage collection?

Cheers,  
Niels

Posted at Nginx Forum:

> **[nginx fastcgi\_cache not freeing deleted items causing excessive disk usage](https://forum.nginx.org/read.php?2,267401,267401#msg-267401)**
>
> Hello, I'm using nginx 1.10.0 and the nginx\_fastcgi\_cache option. I've noticed that with a high amount of requests per second (I'm not sure when it occurs exactly, but we have ~2500RPS with about 2Gbit/s of outgoing traffic responses) there is an...

---

<div class="post-metadata">

**Author:** ![b4a456fb-1402](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@b4a456fb-1402](https://www.ruby-forum.com/u/b4a456fb-1402)\
**Post date:** [June 6, 2016, 12:45pm UTC](https://www.ruby-forum.com/t/nginx-fastcgi-cache-not-freeing-deleted-items-causing-excessive-disk-usage/244733/2 "2016-06-06T12:45:57Z")

</div>

Hello!

On Sun, Jun 05, 2016 at 11:32:35AM -0400, b4a456fb-1402 wrote:

> The fastcgi\_cache\_valid is set to 1m
> 
> Even when the server is idle for a while (30+ minutes) the space is not  
> being freed. Obviously restarting nginx manually immediately frees the  
> space.
> 
> Is this a bug or is there a setting I can use to perform some sort of  
> garbage collection?

The fact that a file is shown as “deleted” indicates that it was  
deleted but is still open. This may happen due to legitimate  
reasons - e.g., the file was deleted, but is current being served  
to a client and hence it is still open. But if you see no changes  
with 30+ minutes without load, there is likely a problem  
somewhere. You may try debugging it further.

Some basic things to consider:

- Make sure you are not using open\_file\_cache with some insane  
parameters. If you use open\_file\_cache, comment it out and check  
if you are still able to reproduce the problem.

- Check if “nginx -V” shows any 3rd party modules. If it does,  
try reproducing the problem without them.

- When leaving the server idle, wait to make sure all client  
connections are actually closed on socket level by clients -  
that is, no connections in the ESTABLISHED state. Check lsof  
when this happens.

–  
Maxim D.

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