---

Linux Journal: Tweaking Tux, Part 2

“What I gave you last time were all network tweaks. This time
around, I want to show you a few file system tricks. In past lives
(working with other UNIXes), the systems I administered ran complex
databases, often with hundreds of users. I’m fond of the following
tweaks because they represent parameters that require a kernel
rebuild if you find yourself starting to run low. You made your
best guess, but invariably, it would be kernel rebuild time soon
enough. With Linux, these parameters are simple /proc tweaks. If
you are running a busy database system with a large number of
users, this is one you might run into. The “file-max” parameter
defines the maximum number of open files on your system at any
given time. For most, the default “4096” is plenty. For a busier
system, you might want to push that limit up somewhat. As an
example, let’s double that number.”

    echo "8192" > /proc/sys/fs/file-max

“If you get errors stating that you are running out of file
handles, it’s definitely time to change that number, but don’t wait
for the users to start ringing. Without waiting for errors, you can
take a look under the hood and see when this limit is approaching.
(Preventative maintenance. What a concept.) If you do a cat on
/proc/sys/fs/file-nr, you will get three numbers. The third will be
your file-max. The first and second are the number of allocated
file handles and the number of actual used file handles. Why the
two numbers? When the Linux kernel allocates a file handle, it does
not release it. If you do increase the file-max value, then you
should also increase inode-max as well. Considering that each open
file requires an inode for stdin, stdout (and possibly, a network
socket) this needs to be somewhat higher than your file-max. Take
your file-max value, triple it and write it back out to
inode-max.”

    echo "24576" > /proc/sys/fs/inode-max

Busy web server? News server? Here’s another tweak for your
files, and this one has nothing to do with /proc.
One of the
options for the mount command is “noatime”. In other words, do not
(don’t you even think about it) update the access time on visited
files. Each time a file is read, the access time is updated which
can yield useful information about file usage (with the find
command, for instance). Odds are, you may not need that
information. In the case of a web server getting a few thousand
hits a day (an hour?), this little change can make a difference.
Historically, this option was a suggestion for directories on news
servers. Today, we are usually talking web servers. This is an
environment where small files are accessed over and over again (
vs. a database environment which traditionally has comparatively
few, large files).”

Complete
Story