持久与非持久-应该使用哪个? [英] Persistent vs non-Persistent - Which should I use?

查看:116
本文介绍了持久与非持久-应该使用哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站一直使用持久连接,根据我对持久连接的理解,没有理由不这样做.可重用的连接为何关闭?我有一个网站,该网站总共可以访问约7个数据库.它不是一个巨大的流量站点,但是足够大.您对持久性有何看法,我应该使用它们吗?

My site has always used persistent connections, based on my understanding of them there's no reason not to. Why close the connection when it can be reused? I have a site that in total accesses about 7 databases. It's not a huge traffic site, but it's big enough. What's your take on persistent, should I use them?

推荐答案

具有持久连接:

  • 您不能有效地构建事务处理
  • 同一连接上不可能的用户会话
  • 应用不可扩展.随着时间的流逝,您可能需要扩展它,这将需要对持久性连接进行管理/跟踪
  • 如果该脚本由于某种原因无法释放表上的锁,则随后的任何脚本将无限期地阻塞,因此应重新启动db服务器.使用事务,如果脚本在事务块完成之前结束执行,事务块也将传递到下一个脚本(使用相同的连接).

持久连接不会带来非持久连接可以做的任何事情.
那么,为什么要使用它们呢?
唯一可能的原因是性能,当创建指向SQL Server的链接的开销很高时,请使用它们.这取决于许多因素,例如:

Persistent connections do not bring anything you can do with non-persistent connections.
Then, why to use them, at all?
The only possible reason is performance, to use them when overhead of creating a link to your SQL Server is high. And this depends on many factors like:

  • 数据库类型
  • MySQl服务器是否在同一台计算机上,如果不在同一台计算机上,则距离多远?可能不在您的本地网络/域之外?
  • MySQL所在的计算机在其他进程中有多少重载

一个总是可以用非持久连接替换持久连接.它可能会更改脚本的性能,但不会更改其行为!

One always can replace persistent connections with non-persistent connections. It might change the performance of the script, but not its behavior!

商业RDMS可能会根据并发打开的连接数获得许可,而在此持久性连接可能会误用

Commercial RDMS might be licensed by the number of concurrent opened connections and here the persistent connections can misserve

这篇关于持久与非持久-应该使用哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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