ulimit vs file-max

1

Alguém poderia explicar o limite de arquivos abertos no linux? O problema é que uma das minhas aplicações, ao reportar "Muitos arquivos abertos".

Eu tenho

ulimit -n
1024

mas

cat /proc/sys/fs/file-max
6578523

e

cat /proc/sys/fs/file-nr
1536

Então eu já tenho 1536 > 1024. O que é ulimit -n então? Isso é muito confuso.

    
por xaxa 03.06.2018 / 10:20

1 resposta

2

ulimit mostra o máximo por processo. Os dois arquivos em /proc mostram números de todo o sistema.

De ServerFault :

file-max is the maximum File Descriptors (FD) enforced on a kernel level, which cannot be surpassed by all processes without increasing. The ulimit is enforced on a process level, which can be less than the file-max.

De link :

What is the file-max parameter and what should we tune it to? The linux documentation definition is that file-max denotes the maximum number of filehandles that the Linux kernel will allocate.

[...]

How do I know if I’m getting close to hitting this limit on my server? Run the command: cat /proc/sys/fs/file-nr. This will return three values, denote the number of allocated file handles, the number of allocated but unused file handles, and the maximum number of file handles. Note that file-nr IS NOT a tunable parameter. It is informational only. On my server, this returns: 3488 0 793759. This means that currently, my server has only allocated 3488 of the 793,759 allocation limit and is in no danger of hitting this limit at this time.

    
por 03.06.2018 / 10:40