使用 Yii在高并发时,发生连接mysql数据库失败,求解释,该如何解决

WBOY
Release: 2016-06-13 13:53:36
Original
1105 people have browsed it

使用 Yii在高并发时,发生连接mysql数据库失败,求解释
PHP Fatal error: Uncaught exception 'CDbException' with message 'CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '***.***.***.**' (4)' in /**/**/framework/ db/CDbConnection.php:348 

错误信息如上。开发完成测试一切正常,功能但上线后,并发高峰时就会出现个别500。很是诡异。求助啊 。

------解决方案--------------------
Yii框架 CDbConnection 默认将设置 'emulatePrepare' => true , 这样PDO-mysql连接 以长连接方式连接数据库。再高并发时有时会发生连接数 维持过多。新连接失效的问题。我猜是这样!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!