错误“连接太多".在CodeIgniter网站上 [英] Error "too many connections" on CodeIgniter website

查看:73
本文介绍了错误“连接太多".在CodeIgniter网站上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在堆栈溢出的情况下,我已经阅读了有关此主题的所有问题/答案,但是很遗憾,没有一个问题可以解决我的问题.

I've already read all the questions / answers about this subject here on stack overflow but unfortunately none have resolved my problem.

最近几天,mysql错误连接过多"一直显示在网站日志中,并且为每个客户端挂起了整个网站.实际上,它会将服务器上的所有网站挂起.

In the last few days the mysql error "too many connections" keeps showing up on the website logs and it hangs the entire website for every client. In fact it hangs all the websites on the server.

这是我的问题/评论:

  • 大约有50个不同的客户数据库,除了2个对所有客户而言都是公用的
  • pconnect已经=所有连接都为FALSE
  • 在文件"php.ini"上,变量"allowpersistent"为ON.即使我写pconnect = FALSE,这也会使mysql连接永久化吗? (我无法更改"allowpersistent"变量,必须询问托管公司)
  • 有3个文件加载数据库,一个文件加载客户端的数据库,另外两个文件加载所有客户端的公共数据库,它们在每种模型的构造方法上均被调用,但是CI应该在完成mysql连接后关闭它们并忽略任何已加载的"load->数据库"
  • "db-> close"显然没有任何作用,因为在我关闭数据库之后,this-> db-> database保留了其值:P
  • 在我撰写本文时,Threads_connected的数量最多为1000,而网站已关闭:(
  • mysql配置的max_connections = 1000,可以进一步增加吗?我发现可用内存没有变化,那会发生什么?
  • 我应该改为PDO吗?我正在使用dbdriver"mysqli"
  • 我是否应该请托管公司降低mysql变量"wait_timeout",以便快速关闭数据库连接?
  • 我应该更新CodeIgniter吗?我有版本3.1.4,现在是3.1.9
  • there are about 50 different client databases, besides 2 which are common to all clients
  • pconnect is already = FALSE for all connections
  • On the file "php.ini" the variable "allowpersistent" is ON. Does this make the mysql connections permanent even if I write pconnect = FALSE? (I can't change the "allowpersistent" variable, would have to ask the hosting company)
  • There are 3 files that load databases, one loads the client's DB and the other two load common databases for all clients, they are called on the construct method of every model, but CI supposedly should close the mysql connections after its done with them AND ignore any "load->database" already loaded
  • "db->close" apparently does nothing, because this->db->database keeps its value after I close it :P
  • Threads_connected are up to 1000 as I write this and the website is down :(
  • mysql configuration has max_connections = 1000, can it be further increased? I see no change in free memory, so what can happen?
  • Should I change to PDO? I'm using dbdriver "mysqli"
  • Should I ask the hosting company to lower the mysql variable 'wait_timeout', so as to rapidly close the DB connection?
  • Should I update CodeIgniter? I have version 3.1.4 and it's now at 3.1.9

非常感谢您的帮助!

推荐答案

在我们的例子中,解决方案是将mysql变量"wait_timeout"从8小时(默认为wtf !?)降低到180秒.并且如果需要,它仍然可以降低得更多.这必须由托管公司完成,因为我们没有对服务器的root访问权.

In our case the solution was lowering the mysql variable "wait_timeout" from 8 hours (the default, wtf!?) to 180 seconds. And it can still be lowered more if needed. This had to be done by the hosting company, as we do not have root access to our server.

我在问题中提到的所有其他解决方案均无效,例如"pconnect = false"和"db-> close".

All the other solutions I mentioned in the question were not working, like "pconnect = false" and "db->close".

"Threads_connected"现在始终低于100或200,而不是此修复之前的将近1000.

"Threads_connected" are now always under 100 or 200, instead of the almost 1000 from before this fix.

我的团队为这个问题苦苦挣扎了两天,网络上有很多人在寻求解决方案,但没有任何(有效的)答案.

My team wrestled with this problem for two days, and there's lots of people on the Web asking for solutions but without any (working) answers.

干杯:)

这篇关于错误“连接太多".在CodeIgniter网站上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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