简体   繁体   English

Php-fpm & Nginx 在 docker 容器性能

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

we are working on an online Exam system which will have high traffic at the same time, the system developed using laravel and MySQL as database.我们正在开发一个同时具有高流量的在线考试系统,该系统使用 laravel 和 MySQL 作为数据库开发。 our server has 40 core and 64 GB RAM memory.我们的服务器有 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. 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. but the problem is the system can not handle more than 600 Users at the same time.但问题是系统不能同时处理超过 600 个用户。 we tried with Nginx performance tunes and nothings works, and also with php-fpm.我们尝试了 Nginx 性能调整和没有任何工作,以及 php-fpm。 I don't know why is that happening, we tried with all architecture that can help but nothings work, every PHP-fpm process using 27% of CPU.我不知道为什么会发生这种情况,我们尝试了所有可以提供帮助但无济于事的架构,每个 PHP-fpm 进程使用 27% 的 CPU。 and when I am using当我使用

ApacheBench ApacheBench

in order to send requests to the server and then trying to load the home page from my browser it taking a long time to respond to the page and many times return time-out.为了向服务器发送请求,然后尝试从我的浏览器加载主页,需要很长时间才能响应页面并且多次返回超时。 I am using Nginx:stable-alpine as Nginx docker image.我正在使用Nginx:stable-alpine作为 Nginx docker 图像。

php:7.4-fpm-alpine

as PHP image.作为 PHP 图像。 I did not change any of the default configs for PHP or Nginx.我没有更改 PHP 或 Nginx 的任何默认配置。 so what is the best configuration for PHP and Nginx which I have to apply in order to have the best performance?那么为了获得最佳性能,我必须应用 PHP 和 Nginx 的最佳配置是什么?

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

htop after send request using使用发送请求后的 htop

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

在此处输入图像描述

Rate Per Second = RPS每秒速率 = RPS

Suggestions to consider for your my.cnf [mysqld] section为您的 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

There are many more opportunities to improve configuration.还有更多改进配置的机会。 View profile, Network profile for free downloadable Utility Scripts to assist with performance tuning, specifically findfragtables.sql is helpful with reminding you to OPTIMIZE heavily used tables periodically.查看配置文件,网络配置文件可免费下载实用程序脚本以帮助进行性能调整,特别是 findfragtables。sql 有助于提醒您定期优化使用频繁的表。

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

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