Too many open files errors

Hello all ,
nice to see a nginx topic on here :slight_smile: also greetings to mail-listers!

I have problem with nginx+fast-cgi. Sometimes CPU useage getting higher
then %100. I checked error.log and found something.

On startup (nginx) , there is showing an error more then 5 like that;

2008/01/03 01:07:54 [alert] 12755#0: sendmsg() failed (9: Bad file
descriptor)

After a few minutes later (10 or 15 minutes) , i am having Too many open
files error too. Then cpu usage getting over %100 for a few minutes…
also HTTP 500 error…

I am using Centos5 + 64bit with nginx-0.5.34 + fastcgi. Also this is a
BitTorrent tracker.

I have reinstalled my box and i still having same problem.

Willing to get answered.
Happy new year all!
Regards!

You’re probably hitting your OS’s file descriptor limit:

To check and modify system limits.
% cat /proc/sys/fs/file-max

[To temporarily increase this to 65535 (as root)]

echo “65535” > /proc/sys/fs/file-max

If you want this new value to survive across reboots you can at it to
/etc/sysctl.conf

Maximum number of open files permited

fs.file-max = 65535

I found that on nginx mail lists but cant understand what to do :\


Subject: Re: too many open files Re: too many open files

On 01.03.2006, at 11:31, L0rda wrote: On 01.03.2006, at 11:31, L0rda
wrote:

Good day,

narisovalas a problem nginx can not open more than 500 log files, the signal-HUP not overloading configuration, 24: Too many open files. 24 gives a mistake: Too many open files.

nginx.conf: worker_rlimit_nofile 15000; nginx.conf: worker_rlimit_nofile 15000;

df -i df-i
Filesystem Inodes IUsed IFree IUse% Mounted on Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 15794176 840958 14953218 6% / / dev/sda1 15794176 840958 14953218 6% /
/dev/shm 219846 1 219845 1% /dev/shm / dev / shm 219846 1 219845 1% / dev / shm
/dev/sda2 1048576 15442 1033134 2% /var / dev/sda2 1048576 15442 1033134 2% / var

sysctl -a|grep file sysctl-a | grep file
fs.file-max = 500000 fs.file-max = 500000
fs.file-nr = 11820 0 500000 fs.file-nr = 11820 0 500000

ulimit -n 15000 ulimit-n 15000
To reload the configuration had to disable several log files.

Perhaps someone met with a similar problem?

On Thu, 2008-01-03 at 00:32 +0100, Mustafa T. wrote:

I found that on nginx mail lists but cant understand what to do :\

Perhaps read Arash’s very, very clear and simple response one more
time.

If you can’t follow those instructions, then you should probably seek a
consultant or hire an administrator.

Cliff

Well the solution ,

add this line on nginx.conf!

worker_rlimit_nofile 10240;

Greetings!