Search code examples
connection-poolingnpgsqlpgbouncer

Npgsql and PgBouncer polling


We are currently using Pgbouncer(installed on database server) for database connection pooling. At the same time we use Npgsql Library which has its own connection pool. I have read recommendations that we should disable pooling in Npgsql and use only Pgbouncer.

There is a performance problem when we disable connection pooling in Npgsql. According to my test, it takes 100 ms to connect to pgbouncer. Latency to server with PgBouncer is <1ms.

Executing 5 queries with 5 connections will take more than 500ms, which is too much.

Are we using it correct? That connection latency is killing my performance.


Solution

  • I tried to connect to pgbouncer from different server in network and it took from 8 to 22 ms. I am assuming, it is some network issue.