logoalt Hacker News

LtWorftoday at 2:13 PM2 repliesview on HN

Me too. I even opened the page and I'm not sure of what's the problem being solved.


Replies

aobdevtoday at 2:47 PM

Every single connection to Postgres is a new process, which requires a fork and new memory allocation (at least 10MB plus whatever you need for your query).

PgBouncer opens a pool of connections and then reuses them each time a client asks for a connection. This reduces latency (no more fork) and overhead (reuse memory).

show 1 reply
Brotkrumentoday at 3:16 PM

If you handle database requests naively, every request to the database may open its own connection. This is a super simple approach but will exceed the amount of connections the database can or wants to handle concurrently.

One solution is to increase your app complexity and introduce a layer that manages connection pooling or queuing.

Or you can just keep your app naive and simple and put pgbouncer transparently in front of your DB. Even for multiple apps, so instead of every app increasing in complexity, reimplementing connection handling, you just have pgbouncer.