#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    155
    Rep Power
    12

    Persistent Connections vs. normal connections with PHP


    Hi all.

    As far as I understand it, the advantage to persistent connections is that if a request is made to connect to a PostgreSQL database via a persistent connection, then if there already exists in the pool a connection with the same database, username, and password, this connection will be reused instead of opening up a new one.

    However, I've also read some information which suggests that using persistent connections increases the load on the server.

    Since I'm running four applications which use PostgreSQL, and since two of these often have multiple users connected at once that will be using the same username and password to connect to a database, am I not better off using persistent connections to reduce the number of active connections for the same username and password?

    From what I've read it seems that persistent connections are in this case the way to go, but I've read some other posts/articles which suggest the opposite, so while I would tend to lean towards the side of persistent connections I'm not certain.

    On the two applications I have which are currently accessed the most, I think I could use persistent or non-persistent connections and it might not make that much of a difference. But the application I'm currently developing (a db-driven content management system) will have MANY users connected at the same time, so efficiency in pooling connections is of utmost importance.

    Any advice is greatly appreciated.

    Thanks much in advance,
    Pablo
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    These threads discuss persistent connections. There are mainly about MySQL but PHP persistent connections work the same for all database systems that allow them.

    What is "a connection" in mySQL

    why so many open threads (connections)?

    Also do a search here for "persistent connections" and my username.

IMN logo majestic logo threadwatch logo seochat tools logo