views:

28

answers:

2

we are running a very connection-heavy, insert-heavy postgres database (to the point that we should've done some connection pooling, but there's no time now).

when doing some troubleshooting, i was using netstat to show me how many connections there were to postgres. i would commonly see more than what i had specified in the postgres.conf file (via max_connections).

i would see 1400-1600 connections via netstat even though i had max_connections set to 1000.

anyone have any clue what is going on? how exactly can this happen?

any insight on this would be great.

+2  A: 

Is it possible that those connections were already closed? Windows for example doesn't immediately close the connection, but it changes it state to "TIME_WAITING.

So the connections show up in netsat but are actually closed.

Only those that show up as "ESTABLISHED" are "live" connections.

Btw: you can simply put a connection pooler in front of your PostgreSQL server without changing your application. pgPool (or pgBouncer) will pretend they are a real PostgreSQL server to the application and will do the pooling "behind its back"

a_horse_with_no_name
A: 

Use a connectionpool. More than a 1000 connections will slow down the database significantly and even for a 1000 connections you need some $$$$$ hardware with a lot of cores and RAM. Using a connectionpool is much more efficient.

Frank Heikens
okie.floyd
As I have already written: with pgPool or pgBouncer you don't need to change anything in your code to use the connection pool
a_horse_with_no_name