I have postgres set to a max connection limit of 512. I have nearly 30,000
users that will be taking a training course over the next 6 weeks. I have 3
web servers load balanced serving php content for this website. Last week I
had postgres set to a connection limit of 128 and that was reached. Since
then I have set it to 512 and not had a problem. However, I am unaware of
any good monitoring tools that let me see live connections to the database.
When I run netstat-c on the db server, it lets me see active connection in
real time. Heres an example:
Tcp 0 0 server:postgres 192.168.50.x:port number
ESTABLISHED
I will have anywhere from 5 to 7 of these going at any given time. However
most say TIME_WAIT instead of established.
I am assuming these are connections to the database that php is using to
post and retrieve data. I recently read where postgres uses one semaphore
per connection in sets of 16. With that being said is one of these
connections that I see in netstat-c actually representing 16 connections?
If that is the case, when 6 or 7 are being displayed at once, then that
would mean roughly 112 or so connections, which is great because it doesn't
even come close to my limit of 512. Can anyone confirm that what I am
thinking is right?
Also, is there a way to make the TIME_WAIT status shorter. It seems to
exist for about 25 seconds, then goes away. However, those are connections
that could easily be used.
Thank you,
Darryl