简体   繁体   English

如何计算数据库连接数?

[英]How DB Connections Numbers Are Calculated?

I have database connection number increased this morning, which never happen before. 今天早上我的数据库连接数增加了,这是以前从未发生过的。 as shown below : 如下所示 :

在此处输入图片说明

and I don't know why. 我不知道为什么。 because there's no user accessing this database. 因为没有用户访问此数据库。 just cronjob which runs since last month and no changes. 从上个月开始运行的cronjob,没有任何更改。

so I was wondering, how this database connection number is calculated? 所以我想知道,该数据库连接数是如何计算的?

does each SELECT , UPDATE and INSERT count as 1. 将每个SELECTUPDATEINSERT计为1。

or each $conn = new mysqli($servername, $username, $password); 或每个$conn = new mysqli($servername, $username, $password); count as 1? 算为1?

Amazon RDS Db connections count is persistent connection made by connecting library. Amazon RDS Db连接计数是通过连接库建立的持久连接。 so 所以

$conn = new mysqli($servername, $username, $password); will be counted as 1 single connections. 将计为1个单一连接。

Reason behind increased connections may be bug in your script or library file. 连接增加的原因可能是脚本或库文件中的错误。 After every successfully select/insert/update/delete actions or performing entire function (at end of cron in your case) you have to close the mysqli connection . 在每次成功选择/插入/更新/删除动作或执行整个功能(在您的情况下为cron)后, 您必须关闭mysqli连接 RDS will not automatically close your connection and hence when your cron runs next time a new connection will be established and counts goes on increasing. RDS不会自动关闭您的连接,因此,当您的cron下次运行时,将建立一个新的连接,并且计数还将继续增加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM