Alan Castro home

Increase the number of opened files on Debian Linux

September 07, 2010 – Belo Horizonte, Brazil

Introduction

Lately I’ve been working on deploying and stress testing web applications. I came across a known problem: too many opened files. This post is a simple guide on how to change the maximum opened files (file descriptor) on your Debian like distribution.

See the current configuration

There are two different limits. One is the maximum opened files the kernel can use and the other one is per-process.

Change the current values

Now configure a new value for the maximum of opened files.

1. Add the following line to /etc/sysctl.conf to change the kernel maximum opened files. (I’m not going to change the value)

fs.file-max = 379126

2. Edit /etc/security/limits.conf and add the following lines:

*	soft	nofile	65000
*	hard	nofile	65000

3. Edit /etc/pam.d/common-session and add the following line:

session required pam_limits.so

4. Edit /etc/ssh/sshd_config and add the following line:

UseLogin yes

5. Reboot.

blog comments powered by Disqus