连接超时和连接终止时间 [英] Connection Timeout and Connection Lifetime

查看:983
本文介绍了连接超时和连接终止时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

连接超时= 0的优点和缺点是什么?



Connection Lifetime = 0的用途是什么?



例如

 (Database = TestDB; 
port = 3306;
Uid = usernamed;
Pwd = myPassword;
Server = 192.168.10.1;
Pooling = false;
Connection Lifetime = 0;
Connection Timeout = 0)



解决方案

超时是指您在放弃之前等待来自请求的响应的时间。 TimeOut = 0表示您将继续等待连接永久发生。好我想如果你连接到一个真正慢的服务器,这是正常的,如果它需要12个小时来回应:-)。一般来说是一件坏事。



连接生命周期

/ strong> =连接在被杀死和重新创建之前的生存时间。寿命为0意味着永远不会杀死和重建。通常不是一件坏事,因为杀死和重新创建连接是缓慢的。通过各种错误,你的连接可能会陷入一个不稳定的状态(像处理奇怪的3路交易)..但99%的时间是很好的保持连接的生命为无限。



连接池是一种处理创建连接非常慢的事实的方法。因此,不是为每个请求创建一个新的连接,而是有一个说,10,预制连接池。当你需要一个,你借一个,使用它,并返回。你可以调整池的大小,以改变你的应用程序的行为。更大的池=更多的连接=更多的线程一次做东西,但这也可能压倒你正在做什么。



总结:0047
ConnectionTimeout = 0 很糟糕,使其变得像30秒这样合理。

ConnectionLifetime = 0 是否确定
ConnectionPooling =已停用,您可能会希望使用它。


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?

解决方案

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.

这篇关于连接超时和连接终止时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆