简体   繁体   English

MySQL的threads_connected数减缓了我的网站

[英]MySQL number of threads_connected slow down my website

I have an store running on Prestashop 1.5.4. 我有一个在Prestashop 1.5.4上运行的商店。 I keep having a problem with the site behaviour. 我一直有网站行为的问题。

Everytime i check this number 每次我检查这个号码

user@server:~$ mysql -se "show status like '%threads_connected%'"

If the number gets above 25, my site becomes really slow. 如果数字超过25,我的网站变得非常慢。 Opening a page takes forever and page load can get as high as 1 - 2 minutes. 打开页面需要永远,页面加载可以高达1 - 2分钟。

The only solution (temporary) is for me to restart the apache services. 唯一的解决方案(临时)是我重启apache服务。

I am pretty sure 25 is a pretty low number. 我很确定25是一个非常低的数字。

In case you need to know, i don't have direct access to my.ini nor to any access to MySQL Server Configuration. 如果您需要知道,我无法直接访问my.ini,也无法访问任何MySQL服务器配置。 My database is stored in a shared (DBaSS). 我的数据库存储在共享(DBaSS)中。

I do however have full access to my webserver (apache2.conf, php.ini, www.example.com.conf) 但我可以完全访问我的网络服务器(apache2.conf,php.ini,www.example.com.conf)

A little info that might help: 一些可能有用的信息:

-se "show variables like '%max%'"

Outputs: 输出:

图片1图2

I guess my question is how can i improve performance ? 我想我的问题是如何提高性能? Can i improve this by limiting the number of "threads_connected" ? 我可以通过限制“threads_connected”的数量来改善这一点吗?

footnote: 脚注:

I am aware that there is probably a bad query somewhere in the code, however, at the moment i need a quick solution for this. 我知道代码中的某个地方可能存在错误的查询,但是,目前我需要快速解决此问题。 As reviewing all queries can take some time. 审核所有查询可能需要一些时间。

EDIT #1 编辑#1

Perhaps this information might give some ideas 也许这些信息可能会提供一些想法

php.ini中php.ini中

EDIT #2 编辑#2 apache2.conf

Can i improve this by limiting the number of "threads_connected"? 我可以通过限制“threads_connected”的数量来改善这一点吗?

Absolutely not. 绝对不。

All you could do by limiting the number of connections would be to cause errors for users of your site, because their particular Apache process wouldn't be able to connect to the database. 通过限制连接数量可以做的就是为站点用户造成错误,因为他们的特定Apache进程无法连接到数据库。

The problem is not the number of threads connected. 问题在于连接的线程数。 That is a symptom of the real problem, which is that you have one or more queries that perform poorly, or that you do not have enough memory for Apache to scale up when traffic gets heavy, forcing your machine into heavily swapping, and thereby slowing down Apache to the point that it keeps connections open longer. 这是真正问题的一个症状 ,即您有一个或多个执行效果不佳的查询,或者您没有足够的内存使Apache在流量变大时扩展 ,从而迫使您的计算机进行大量交换,从而减慢速度将Apache连接到更长时间的连接点。

I need a quick solution for this 我需要一个快速解决方案

Sorry... but there isn't another solution other than to find the actual problem and fix it. 抱歉...但除了找到实际问题并修复它之外,没有其他解决方案。

More useful than the number of connections is what are these connections doing right now? 比连接数更有用的是这些连接现在正在做什么?

SHOW FULL PROCESSLIST; in MySQL will answer that question. 在MySQL中将回答这个问题。 If they are just sleeping, they aren't hurting anything on the MySQL side, and you may want to limit the number of Apache processes, but if that is a side effect of the level of site traffic, then your server may actually be too small, or you may need to disable HTTP keepalive, or tweak the timeout, if browser connections are holding open Apache children that are idle, consuming memory. 如果他们只是在睡觉,他们不会伤害MySQL方面的任何东西,你可能想限制Apache进程的数量,但如果这是网站流量水平的副作用,那么你的服务器实际上可能也是如此如果浏览器连接保持空闲的Apache子节点消耗内存,则可能需要禁用HTTP keepalive或调整超时。

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

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