I'm playing with pgBouncer as a connection pooling system for PostgreSQL. My system is a 12-core with 64GB RAM and 1Gbps network interface running Debian 8.1. Now I want to raise the limit for open socket connections up to, say 10.000 concurrent clients. When doing DB benchmarks the pgbench
utility blocks at about 950 concurrent clients, which seems to reach a limit of 1024 open fds like it was in good old days. I checked the fs.file-max
kernel parameter and the pgbench
running user's resource limit:
# sysctl fs.file-max
fs.file-max = 6598264
# su - postgres
$ ulimit -Sn
65536
$ fgrep files /proc/self/limits
Max open files 65536 65536 files
$
However, the limits from proc
show that the soft-limit for max open files for pgBouncer (running as user postgres
) is only 1024 max open files:
$ ps -e | fgrep pgbouncer
9840 ? 00:00:00 pgbouncer
$ fgrep files /proc/9840/limits
Limit Soft Limit Hard Limit Units
Max open files 1024 4096 files
$
I tried to raise the limit by inserting ulimit -S -n 5000
in /etc/default/pgbouncer
(read in by the start/stop script in /etc/init.d
), but that didn't work. Then I tried nofile
setting in /etc/security/limits.conf
and made sure it is enabled in PAM, but to no avail.
So, where exactly does start-stop-daemon
lower the nofile
limit for daemon processes? I stumbled over this old bug report for Debian, but it seems that the patch never was applied.
BTW: Is fs.file-max
really the replacement of former system's nofiles
(note the plural) kernel variable as suggested in many blog articles regarding tuning? Makes me wonder that it is in the fs
parameter section. On my IRIX system it is called rlimit_no_files_max
in the resource section, which makes much more sense for me than putting it in the fs
section..
What I'm doing wrong here? Where is the right place to change this parameter for daemons in Debian 8.1?
Thanks in advance,
Stefan