Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The connection handling section was surprising to me, reading that Postgres uses a process per connection! This is pretty shocking to me, in a bad way.


One could use connection pooling. Quoting from the tuning guide [0]:

  max_connections sets exactly that: the maximum number of client
  connections allowed. This is very important to some of the
  below parameters (particularly work_mem) because there are some
  memory resources that are or can be allocated on a per-client
  basis, so the maximum number of clients suggests the maximum
  possible memory use. Generally, PostgreSQL on good hardware can
  support a few hundred connections. If you want to have
  thousands instead, you should consider using connection pooling
  software to reduce the connection overhead.
Replication, Clustering, and Connection Pooling [1]

[0] https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Serv...

[1] https://wiki.postgresql.org/wiki/Replication,_Clustering,_an...


pgbouncer works pretty well for that. I kinda wish it was part of the default Postgres install.


How does pgbouncer work with Amazon RDS (where you can't install separate software)?


you install it on the clients of the servers themselves and "connect locally" to the bouncer or have a bouncer step (server pair) in front of the database connections themselves.


pgbouncer does not need to run on the same machine as the DB. It can run on an EC2 instance in front of your RDS instance.


Different design goals, Mysql lot of connections with shared memory model and fast running small queries, ex: PHP one connection per page view. Postgres dedicated memory model long running complex queries.


So PG has a process pool instead of a thread pool. (I doubt either database is spawning procs/thds anew willy nilly for each request).

This means the PG has explicit IPC overhead, vs the quick and seductive path (to the dark side?) of simply sharing memory between threads. Safety vs speed.


It actually forks a new process per connection.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: