Thread: Strange connection limit problem

Strange connection limit problem

From
Ict Security
Date:
Dear guys,

i have two identical Postgresql 9.6.1 and i need, to test an
application, to reach connection above 1024.

I setup 2400 as max_connections
I raised file-max kernel limit to 65535
I increased shared_buffers
I also increased the value in semaphores in both
And i added this in limits.conf:
* - nofile 999999

But - and it is really strange - in machine nr. 1 i can start
thousands of connections while in machine nr. 2 after 1024 connections
Postgres does not accept anything else.

Configuration are the same on the two machines:

ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 63462
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 999999
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 999999
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

ipcs -l
------ Messages Limits --------
max queues system wide = 8192
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 18014398509465599
max total shared memory (kbytes) = 18014398442373116
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 8192
max semaphores per array = 4096
max semaphores system wide = 25600000
max ops per semop call = 64
semaphore max value = 32767


ONLY here i can notice a different:
- machine nr. 1
cat /proc/14994/limit (where 14994 is Postgres' PID):
Max open files            1024                 4096                 files

- machine nr. 2
cat /proc/8459/limits (where 8459 is Postgres' PID)
Max open files            999999               999999               files

Maybe '999999' is an out of range value and it is not considered?
In this case, how can i solve?

Thank you!
Frank



Re: Strange connection limit problem

From
Laurenz Albe
Date:
Ict Security wrote:
> i have two identical Postgresql 9.6.1 and i need, to test an
> application, to reach connection above 1024.
> 
> I setup 2400 as max_connections

Ugh.  Don't.  Use a connection pool.

> I raised file-max kernel limit to 65535
> I increased shared_buffers
> I also increased the value in semaphores in both
> And i added this in limits.conf:
> * - nofile 999999
> 
> But - and it is really strange - in machine nr. 1 i can start
> thousands of connections while in machine nr. 2 after 1024 connections
> Postgres does not accept anything else.

What is the error message in the log?

What do you see in /proc/12345/limits and /proc/12345/cgroup
(assuming that your postmaster PID is 12345)?

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




Re: Strange connection limit problem

From
Giuseppe Sacco
Date:
Hi Frank,

Il giorno ven, 07/06/2019 alle 13.58 +0200, Ict Security ha scritto:
> Dear guys,
> 
> i have two identical Postgresql 9.6.1 and i need, to test an
> application, to reach connection above 1024.
> 
> I setup 2400 as max_connections
> I raised file-max kernel limit to 65535
> I increased shared_buffers
> I also increased the value in semaphores in both
> And i added this in limits.conf:
> * - nofile 999999
[...]

Is postgresql ran via systemd? If this is the case, limits.conf is
ignored and you should put the limits in the systemd unit file.

Bye,
Giuseppe