Page 1 of 1

DbManager Connection pool

Posted: 15 Sep 2010, 12:20
by udikantz
Hey, There are few things i need to ask about the dbManger,

I have noticed on the MySql client with the command:

SHOW FULL PROCESSLIST

That we have more open connections to the db than expected,
after a few tests, i have noticed that when i start the server, i would start with lets say 3 open connections to the database, after i connect some npcs to the server the connections grow to be 6. and after some time they may grow a bit more.

i assumed that the dbManager opens new connection on certain situations, i was wondering when exactly?

2nd thing i have noticed , that the open connections never closes, many connections just stay idle for long time after they've been opened...
is that normal? did i miss anything?

thank you

Posted: 16 Sep 2010, 07:08
by BigFIsh
How do you initialize your mysql database?

Do you fetch the database manager in your init method of your zone extension, assigning it to a local variable - and use that variable for any database tasks within the zone?

Is there anything else that may also connect to your mysql database outside the server? i.e. via php

Posted: 16 Sep 2010, 09:22
by udikantz
yes i fetch the database manager in your init method of your zone extension, assigning it to a local variable - and use that variable for any database tasks within the zone.

nothing else connected to the db.

Posted: 17 Sep 2010, 05:13
by Lapo
Hi,
yes this is normal. Starting up and destroying DB connections is an expensive and slow operation. The connection pooling is a technique to avoid these costs by reusing these connections over and over instead of creating and destroying new ones.

You can configure the max amount of live connections in the DbManager to make sure it doesn't exceed a certain value. More details are found in the docs under chapter 6.3
http://smartfoxserver.com/docs/