[imp] DB Connection Handle Consumption
Sexton, George
gsexton@mhsoftware.com
Mon, 22 Apr 2002 09:53:32 -0600
I went back to the archives. The most serious objection seemed to be closing
the connections. I admittedly know little of PHP. Most of my web development
is in Java Servlets. In Java servlets, to create a scalable implementation I
would do something like this:
Create a class called ImapConnectionPool that would have a method
getConnection(SessionID, Server,User ID, Password) that returns an IMAP
Connection object.
On the first run through, it would create the connection.
Once the client is through with the IMAP connection, it would call
ImapConnectionPool.freeConnection(). ImapConnectionPool would place the
connection back in it's list.
On second and subsequent attempts, the IMAP connection for the user would be
found in the pool, and returned to the client.
ImapConnectionPool would have a background thread that runs every so often.
The background thread would free any connections in the list that have not
been used in more than a specified period.
I wrote a JDBC Connection pooling class that uses this technique, and it
works extremely well. The pool auto-sizes to meet spikes in demand, but over
time, the pool shrinks back down and frees the connections.
An alternate approach would be to save the Connection object on the session,
and have the destructor disconnect. This would be cleaner, but probably
would not scale as well as the other, more complicated approach since
sessions can be arbitrarily long.
I guess the question is, could something like this be implemented in PHP?
-----Original Message-----
From: Chuck Hagenbuch [mailto:chuck@horde.org]
Sent: 22 April, 2002 8:19 AM
To: Sexton, George
Cc: imp@lists.horde.org
Subject: RE: [imp] DB Connection Handle Consumption
Quoting "Sexton, George" <gsexton@mhsoftware.com>:
> What I don't understand is why IMP sets up and tears down the IMAP
> connection on every page view. Surely this is a big performance problem
> spawning a new imapd every time the user clicks on something. Is there a
> way to turn this on?
No, because we have no mechanism for persistant IMAP connections in PHP.
There's extensive discussion of this in the list archives.
-chuck
--
Charles Hagenbuch, <chuck@horde.org>
"A dream which helps you to live your reality with dignity
and justice is a good dream." - Tariq Ramadan