views:

150

answers:

1

What is the advantage and disadvantage of connection timeout=0?

And what is the use of Connection Lifetime=0?

e.g (Database=TestDB;port=3306;Uid=usernameID;Pwd=myPassword;Server=192.168.10.1;Pooling=false;Connection Lifetime=0;Connection Timeout=0)

and what is the use of Connection Pooling?

A: 

Timeout is how long you wait for a response from a request before you give up. TimeOut=0 means you will keep waiting for the connection to occur forever. Good I guess if you are connecting to a really slow server that it is normal if it takes 12 hours to respond :-). Generally a bad thing. You want to put some kind of reasonable timeout on a request, so that you can realize your target is down and move on with your life.

Connection Lifetime = how long a connection lives before it is killed and recreated. A lifetime of 0 means never kill and recreate. Normally not a bad thing, because killing and recreating a connection is slow. Through various bugs your connections may get stuck in an unstable state (like when dealing with weird 3 way transactions).. but 99% of the time it is good to keep connection lifetime as infinite.

Connection pooling is a way to deal with the fact that creating a connection is very slow. So rather than make a new connection for every request, instead have a pool of say, 10, premade connections. When you need one, you borrow one, use it, and return in. You can adjust the size of the pool to change how your app behaves. Bigger pool = more connections = more threads doing stuff at a time, but this could also overwhelm whatever you are doing.

In summary:
ConnectionTimeout=0 is bad, make it something reasonable like 30 seconds.
ConnectionLifetime=0 is okay
ConnectionPooling=disabled is bad, you will likely want to use it.

bwawok
May I know if you have any idea on how this error came-up?'Unable to connect to any of the specified MySQL hosts.'
Mark
Your server isn't responding. Could be down, could not be open on the right port, could be a firewall, etc. Need more details
bwawok