繁体   English   中英

Php-fpm & Nginx 在 docker 容器性能

[英]Php-fpm & Nginx in docker conatainer performance

我们正在开发一个同时具有高流量的在线考试系统,该系统使用 laravel 和 MySQL 作为数据库开发。 我们的服务器有 40 核和 64 GB RAM memory。 I installed Nginx in a docker container PHP in another container Mysql in another container, also we tested the system with the classic way, where all services working in the same server directly without docker. 但问题是系统不能同时处理超过 600 个用户。 我们尝试了 Nginx 性能调整和没有任何工作,以及 php-fpm。 我不知道为什么会发生这种情况,我们尝试了所有可以提供帮助但无济于事的架构,每个 PHP-fpm 进程使用 27% 的 CPU。 当我使用

ApacheBench

为了向服务器发送请求,然后尝试从我的浏览器加载主页,需要很长时间才能响应页面并且多次返回超时。 我正在使用Nginx:stable-alpine作为 Nginx docker 图像。

php:7.4-fpm-alpine

作为 PHP 图像。 我没有更改 PHP 或 Nginx 的任何默认配置。 那么为了获得最佳性能,我必须应用 PHP 和 Nginx 的最佳配置是什么?

发送请求前的 htop 结果在此处输入图像描述

使用发送请求后的 htop

sudo ab -n 5000 -c 600 https://demo.qsinav.com/

在此处输入图像描述

每秒速率 = RPS

为您的 my.cnf [mysqld] 部分考虑的建议

thread_cache_size=100  # from 9 to reduce threads_created RPhr of 78 
net_buffer_length=32K  # from 16K to reduce # packets per hour 
query_cache_size=0  # from 1M to conserve RAM because the QCtype of OFF
slow_query_log=ON  # from OFF to allow awareness and proactively correct
long_query_time=1  # from 10 seconds - if overwhelmed with entries, raise the seconds by 1 
innodb_write_io_threads=64  # from 4 to expedite writing to tables on storage devices

还有更多改进配置的机会。 查看配置文件,网络配置文件可免费下载实用程序脚本以帮助进行性能调整,特别是 findfragtables。sql 有助于提醒您定期优化使用频繁的表。

暂无
暂无

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

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