nginx mysql 在并发的一个错误原因探究

来源:互联网 发布:淘宝手机壳店 编辑:程序博客网 时间:2024/06/03 18:08

下面是一个最直接的案例

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.

这里是怎么回事呢

脚本里做了一件事那就是做一次查询数据 ab -c 180 -n 1000 http:XXXXXX.com  做了一次的压测 

top 明显看到nginx的cpu 和内存的使用情况极低 配置 1核 1G内存 此时 mysql服务占用的cpu 和内存如下图

这里很明显的看到一个问题就是 mysql的cpu占用很高,  而php-fpm进程却占用的很少。 问题主要是在mysql上。导致连接超时 我们向服务器发送请求 由于服务器当前链接太多,导致服务器方面无法给于正常的响应,产生此类报错。

第二种

为php 焦脚本添加set_time_limit(0)  代码中 sleep(100) 脚本运行一会报错 504

504 Gateway Time-out
0 0
原创粉丝点击