简体   繁体   English

Zend Framework多个数据库停止使用慢查询

[英]Zend Framework Multiple Database Stop Working with slow query

I'm running a big Zend Framework web application with 5 database, independent of each other, distributed on 2 database servers running on Mysql 5.6.36 - CentOS7 with 16gb ram 8 core processor each. 我正在运行一个具有5个彼此独立的数据库的大型Zend Framework Web应用程序,这些应用程序分布在运行于Mysql 5.6.36的2个数据库服务器上-每个CentOS7具有16GB ram 8核心处理器。 However, if one of the 2 database servers stops responding because of slows query, the users on the other server cannot access the web application. 但是,如果两台数据库服务器之一由于查询变慢而停止响应,则另一台服务器上的用户将无法访问Web应用程序。 The only way to turn on the application is to restart mysql on that server. 打开应用程序的唯一方法是在该服务器上重新启动mysql。 I try different things without success. 我尝试不同的事情没有成功。 The strange thing is that if I turn off one of the servers the system continues to work correctly. 奇怪的是,如果我关闭其中一台服务器,系统将继续正常运行。

It's hard to offer a meaningful answer, because you've given us no information about your tables or your queries (in fact, you haven't asked a question at all, you've just told us a story! :-). 很难提供有意义的答案,因为您没有向我们提供有关表或查询的任何信息(实际上,您根本没有问过任何问题,只是告诉了我们一个故事!:-)。

I will offer a guess that you are using MyISAM for one or more of your tables. 我会猜测您正在为一个或多个表使用MyISAM。 This means a query from one client locks the table(s) it queries, and blocks concurrent updates from other clients. 这意味着来自一个客户端的查询将锁定其查询的表,并阻止来自其他客户端的并发更新。

To confirm you have this problem, use SHOW PROCESSLIST on each of your two database servers at the time you experience the contention between web apps. 要确认您有此问题,请在遇到Web应用程序之间的争用时在两个数据库服务器的每一个上使用SHOW PROCESSLIST You might see a bunch of queries stuck waiting for a lock (it may appear in the processlist with the state of "Updating"). 您可能会看到一堆等待锁定的查询(它可能以“正在更新”状态出现在进程列表中)。

If so, you might have better luck if you alter your tables' storage engine to InnoDB. 如果是这样,如果将表的存储引擎更改为InnoDB,则可能会更好。 See https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html 参见https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html

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

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