468,161 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,161 developers. It's quick & easy.

Connection pool

Ike
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike
Jun 7 '06 #1
8 7585
Ike wrote:
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike


Yes

Thanks, C
Jun 7 '06 #2
Carved in mystic runes upon the very living rock, the last words of Colin
McKinnon of comp.lang.php make plain:
Ike wrote:
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike


Yes


Well, aren't you just the clever boy this evening? You must be so pleased
with yourself.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jun 7 '06 #3
Ike wrote:
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike


Making a new connection at database server using much resources like
memory and cpu.

Connection pool is a cache of database connection. Instead of making
new connection, database server reused the old connection. This method
can increase performance and use few memory.

regards,

Lorento
--
http://blogs.deshot.com
http://www.mastervb.net
http://www.groupvita.com

Jun 8 '06 #4
lorento wrote:
Ike wrote:
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike
Making a new connection at database server using much resources like
memory and cpu.

Connection pool is a cache of database connection. Instead of making
new connection, database server reused the old connection. This method
can increase performance and use few memory.

regards,

Lorento


I think the OP knows what a connectionpool is and what it is for.
Ike wants to know how/if to implement one with PHP for eg mySQL.
:-)

And I do not know the answer.
I never ran into performancetrouble that could be solved by
connectionpooling under PHP.

Maybe PEAR has some support for this?

Regards,
Erwin Moller

--
http://blogs.deshot.com
http://www.mastervb.net
http://www.groupvita.com


Jun 8 '06 #5
lorento wrote:
Ike wrote:
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike

Making a new connection at database server using much resources like
memory and cpu.

Connection pool is a cache of database connection. Instead of making
new connection, database server reused the old connection. This method
can increase performance and use few memory.

regards,

Lorento
--
http://blogs.deshot.com
http://www.mastervb.net
http://www.groupvita.com


Making a new connection takes some cpu, that's true. But it's not a lot. Sure,
you don't have the connection overhead with a pool - but then you have the
overhead of finding a free connection in the pool.

And yes, making a new connection takes some memory. The difference is that when
you're through with the non-pooled connection the memory is released. With
pooled connections it isn't.

Pooled connections require you to keep open the maximum number of connections
you might ever need, and the system resources associated with. So if you have a
bump at lunchtime and need 50 connections, you have to have at least 50
connections around, even at 3AM when almost no one is on. With non-pooled
connections you only use the resources you need right now.

Pooling is fine if your site needs dozens of database connections per second.
Not too many websites come even close to that, though, and connection pooling
can actually hurt system performance.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 8 '06 #6
Jerry Stuckle wrote:
lorento wrote:
Ike wrote:
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike

Making a new connection at database server using much resources like
memory and cpu.

Connection pool is a cache of database connection. Instead of making
new connection, database server reused the old connection. This method
can increase performance and use few memory.

regards,

Lorento
--
http://blogs.deshot.com
http://www.mastervb.net
http://www.groupvita.com


Making a new connection takes some cpu, that's true. But it's not a
lot. Sure, you don't have the connection overhead with a pool - but
then you have the overhead of finding a free connection in the pool.

And yes, making a new connection takes some memory. The difference is
that when you're through with the non-pooled connection the memory is
released. With pooled connections it isn't.

Pooled connections require you to keep open the maximum number of
connections you might ever need, and the system resources associated
with. So if you have a bump at lunchtime and need 50 connections, you
have to have at least 50 connections around, even at 3AM when almost no
one is on. With non-pooled connections you only use the resources you
need right now.

Pooling is fine if your site needs dozens of database connections per
second. Not too many websites come even close to that, though, and
connection pooling can actually hurt system performance.


In general, I agree with you Jerry, except when you say 'So if you have
a bump at lunchtime and need 50 connections, you have to have at least
50 connections around, even at 3AM when almost no one is on.'

Most of the connection pools I have dealt with have high and low water
levels (the high to prevent demand from consuming the system and the low
to specify the minimum number of active connections). The pool then
spawns new connections on an 'as needed' basis and releases them after
some timeout period. In this respect, they act like a heap manager with
garbage collection.

Searching for a free connection can be O(1) if the connections are kept
on their own free list.

Connection pools typically require some means of persisting the shared
pool across all the programs that want access to the database which
usually rules them out if php is driven via CGI.

-david-

Jun 8 '06 #7
I think it depends on the database library used. I read somewhere (but I
don't work with the combination PHP/SQL server myself) that the SQL
server library does not even have a means of more than one connection.

For MySQL, I guess you mean a "pconnect". Be aware that a MySQL session
is just like that: a session. You can connect to the server, even define
a few variables (which can come in very handy) and they exist in that
session only. If you were reusing that session, you could mess with
variables, settings or transactions set by another process.
Transactions can be a reason to open two connections from the same
script: you log errors in a table in one connection and still roll back
in another connection without loosing the error messages.

SQL server has another interpretation of "local": a local variable in
SQL server is only defined within one batch. So with SQL server,
connection pooling is less of a problem. On the contrary, SQL server is
a system where you pay for a number of concurrent connections. Just
opening another connection can be expensive in a financial sense. So it
is even designed for connection pooling.

Best regards

Ike wrote:
Is anyone aware of a means of connection pooling (to MySQL, say) in php?
Thanks, Ike

Jun 9 '06 #8
David Haynes wrote:
Jerry Stuckle wrote:
In general, I agree with you Jerry, except when you say 'So if you have
a bump at lunchtime and need 50 connections, you have to have at least
50 connections around, even at 3AM when almost no one is on.'

Most of the connection pools I have dealt with have high and low water
levels (the high to prevent demand from consuming the system and the low
to specify the minimum number of active connections). The pool then
spawns new connections on an 'as needed' basis and releases them after
some timeout period. In this respect, they act like a heap manager with
garbage collection.

Searching for a free connection can be O(1) if the connections are kept
on their own free list.

Connection pools typically require some means of persisting the shared
pool across all the programs that want access to the database which
usually rules them out if php is driven via CGI.

-david-


David,

That's true with some pools. But not with mysql. All you have available are
persistent connections. You'd have to create your own pooling mechanism.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 12 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mahesh D. Rane | last post: by
11 posts views Thread by pradeep_TP | last post: by
7 posts views Thread by greg | last post: by
3 posts views Thread by Martin B | last post: by
10 posts views Thread by Steven Blair | last post: by
16 posts views Thread by crbd98 | last post: by
20 posts views Thread by fniles | last post: by
reply views Thread by kamranasdasdas | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.