php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20237 pg_pconnect, too many connections
Submitted: 2002-11-04 02:56 UTC Modified: 2002-11-04 08:18 UTC
From: anders at gatefive dot fi Assigned:
Status: Not a bug Package: PostgreSQL related
PHP Version: 4.2.3 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anders at gatefive dot fi
New email:
PHP Version: OS:

 

 [2002-11-04 02:56 UTC] anders at gatefive dot fi
I am not sure if this is a pgsql-extension bug or merely an documentation bug. I have had problems with a webserver, getting php-error saying too many connections, when using persistent connections.

It seems mysql behaves like:
(apache) MaxClients * persistant-connections
whereas this is in postgres more like:
MaxClients * DBs * users * persistant connections (not mentioned anywhere in docs).

OR php have troubles finding allready opened connections in its hashtable. (PHP 4.2.3, postgres 7.1.3)

It seems strange to have different pconnects to same postgres  backend if different databases (seems the source selects DB on the open connection anyhow).

background: apache maxclients = 150, 1 user a few DBs and postgress max_connections limit set to 600 ! and it wasn't enough. (fix: changed everything from pg_pconnect to pg_connect).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-04 07:49 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

When using persistant connections each Apache child eventually will have an open connection. Now, if have many users, then this translates to connection per user per apache child. So, with 20 different users connecting to PostgreSQL and 100 Apache children, you could see as many as 2000 open connections.
 [2002-11-04 08:01 UTC] anders at gatefive dot fi
That i did know, but as I mentioned, the connections are being made by only 1 user, so it therefore seems as if there would be something funny going on..

That would lead us to a max of 150 connections - even 600 wasn't enough..
 [2002-11-04 08:05 UTC] anders at gatefive dot fi
Addition:
1 user, 
3 dbs in 1 posgres backend
apache has maxclients at 150

max_connections in postgres set to 600 - still not enough.
anyway I calculate it, it still doesn't sum up
Is it:
users * db * maxclients
or
users * maxclients
(first would equal 450, second 150)
 [2002-11-04 08:10 UTC] iliaa@php.net
It is possible that db also comes into play, however another possibility is that you have non-apache related connections being made, which raises your overall connection count.
 [2002-11-04 08:18 UTC] anders at gatefive dot fi
Well, it is in an controlled environment and connections other than apache was at most 2.

Would you know it postgres has some spawning-limits
(apache has each second: 1, 2, 4, 8, 16, 32, ... 32)

I was seeing for example 50-60 apaches, 170 posgresses (does not make sense), doing a "killall -HUP httpd" solved the issue for a short while at a time. 
Also, 99% of the pgsql usage was to 2 dbs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 12 07:01:28 2024 UTC