You are here

Max files open

Posted at 01:04 on Wed, 9th May 2007 in linux.

Came across the ulimit setting in Linux for the first time, and thought it was worth noting!

Recently, the EGN PvPGN server has become flooded with users, due to the Bored Aussies pvpgn server going down (apparently the guy is moving location).

Anyway, in coping with the flood of players (some 1000+), we ran into a few problems.

One of these was that there is actually a limit to the number of files simultaneously open in Linux (usually 1024). This is both for security (i.e. DOS with memory) and safety reasons (infinite loops, etc). Keep in mind that when a program opens sockets, it opens them to devices, which are also treated as files. So each user theoretically will have its own socket/file, so if you have >1000 players on a server with a filelimit of 1024, you're going to hit a wall.

The way around this is of course is to increase the limit. I looked around for a while on how to do this, but couldn't find an exact solution. The final fix was two config adjustments from two different sites.

This page: "Changing the maximum allowed file size (ulimit)" explains how you can add "ulimit -n 4096" to the "/etc/profile" file to increase the ulimit each time someone logins to a new shell.

And this page: Fun with user limits explains how to set privileges in your "/etc/security/limits.conf" file, so users can actually change their ulimit.

Once these changes are made, the user and any previously run processes need to be re-logged in/restarted.

Thanks to d1zzy (core pvpgn developer) who educated me on the whole ulimit thing.