Connect() failed for backend test6432: no free ports

I'm trying to test connections on Postgres, I'm using Haproxy to redirect connections to master or slave. Testing with pgbench.

this command working well with 5000 clients:

/usr/bin/pgbench -h 127.0.0.1 -p 6432 -U testuser -c 5000  -j 20 -T 60 -S pgbenchdb

but when I put -C (Establish a new connection for each transaction) parameter, even 500 clients getting error:

/usr/bin/pgbench -h 127.0.0.1 -p 6432 -U testuser -c 500 -C  -j 20 -T 60 -S pgbenchdb

errors:

what pgbench sees:

pgbench: error: client 230 aborted while establishing connection
pgbench: error: connection to server at "127.0.0.1", port 6432 failed: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

what haproxy throws:

Connect() failed for backend test6432: no free ports.
message repeated 499 times: [ Connect() failed for backend test6432: no free ports.]

Haproxy: HAProxy version 2.4.22-0ubuntu0.22.04.2 2023/08/14

Enviroments: Linux HAPROXY06S03 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Haproxy Config:

global
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
        stats timeout 30s
        user haproxy
        group haproxy
        daemon

defaults
        timeout connect  60s
        timeout client   720m
        timeout server   720m

listen stats
    mode http
    bind *:6433
    stats enable
    stats uri /stats
    stats refresh 120s
    stats auth admin:***

listen test6432
    log 127.0.0.1:514 local0 notice
    bind *:6432
    mode tcp
    option tcp-check
    tcp-check expect string MASTER
    default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
    server testdb01 172.10.20.51:5432 maxconn 10000 check port 5400
    server testdb02 172.10.20.52:5432 maxconn 10000 check port 5400 

I'm trying connections stress test via pgbench over Haproxy to Postgresql Server. I'm expecting all connections passing through.

Upvotes: 0

Views: 402

Answers (0)

Related Questions