Devang Mistry
Devang Mistry

Reputation: 402

inodes continuously increasing on linux server with Nginx and node.js application

I have a linux server on AWS EC2 running a node.js application (serving WebSockets and REST API requests) behind Nginx. The issue is that the system is continuously running out of inodes.

Because of that I have had to increase the EBS volume a couple of times in the pas, but I can't keep doing it since it's not the ideal solution.

On running this command (sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n;) in each and every directory starting from the root, I found out that the /var/lib/nginx/body directory of nginx has the highest inodes consumption.

The above mentioned command outputs something like this:

      ...
      1 0065420628
      1 0065420629
      1 0065420630
      1 0065420631
      1 0065420632
      1 0065420633
      1 0065420634
      1 0065420635
      1 0065420636
      1 0065420637
      1 0065420638
      1 0065420639
      1 0065420640
      1 0065420641
      1 0065420642
      ...

How can I limit the creation of these files? Is there a configuration in nginx that controls that?

Also, is this a folder that can be safely deleted?

Upvotes: 1

Views: 283

Answers (1)

Devang Mistry
Devang Mistry

Reputation: 402

I had client_body_in_file_only on; in one of my nginx configuration that prevented the files from being cleared. I changed the config to client_body_in_file_only clean; and cleared some inodes manually.

Here's a quick command to manually clear files older than a specific date:

$ cd /your/large/directory
$ find . -type f ! -newermt "2023-04-01" -exec rm -rf {} \;

The inodes usage has been the same since I cleaned it up and is not increasing anymore.

Thanks to @SamMason for pointing it out to this question (https://serverfault.com/q/511789/195166) in the comments 🙌

Upvotes: 1

Related Questions