php - Laravel Octane Nginx 主管配置
问题描述
我一直在研究 Laravel Octane 作为现有 Laravel 应用程序性能改进的可能性,并发现每 4000-5000 个请求最多有 15 个请求返回失败。
我目前在 /etc/supervisor/conf.d/laravel-octane-worker.conf 中使用以下配置通过主管部署了 laravel 应用程序并运行 octane:
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan octane:start --server=swoole --workers=8 --task-workers=4 --port=8089
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/var/www/html/octane-worker.log
stopwaitsecs=3600
numprocs=1
使用这样的 nginx 配置:
server {
listen 80;
return 301 https://my_test_domain.com$request_uri;
}
server {
listen 443 ssl default_server;
#listen [::]:443 ssl default_server;
ssl on;
ssl_certificate /etc/ssl/certs/validchain.pem;
ssl_certificate_key /etc/ssl/private/prvatekey.pem;
root /var/www/html/public;
server_name my_test_domain.com;
access_log off;
error_log /var/log/log_path_here.log error;
error_page 404 /index.php;
index index.html index.htm index.php;
error_page 404 /index.php;
location / {
proxy_pass http://127.0.0.1:8089;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
看起来在辛烷值刷新时存在某种主管进程争用,但我无法确定问题所在。下面显示了成功请求后的日志:
Local: http://127.0.0.1:8089
Press Ctrl+C to stop the server
Swoole\Exception failed to listen server port[127.0.0.1:8089], Error: Address already in use[98]
0 /var/www/html/vendor/laravel/octane/bin/createSwooleServer.php:12
1 /var/www/html/vendor/laravel/octane/bin/createSwooleServer.php:12
2 /var/www/html/vendor/laravel/octane/bin/swoole-server:35
解决方案
尝试在 octane start comman 中设置最大请求数--max-requests=1000
推荐阅读
- typescript - 是否已弃用类型以支持接口?
- ios - iOS Firebase 在应用内本地重置密码,而不是在重定向 url 页面上
- javascript - 如何在具有许多点(纬度和经度)的反应原生地图上绘制折线?
- phpspreadsheet - Laravel Excel 尝试使用图表导出但没有图表输出
- python - 如何将 pandas DataFrame 索引从日期时间转换为简单的时间索引
- jquery - 无法使用 jquery 更改引导切换状态
- html - 在 CSS 中添加自定义字体
- swift - 在没有参数的情况下将函数传递给函数(如映射/过滤器等)不会调用函数,而是包装为没有参数的块
- bots - discord.js bot 连接丢失:服务器关闭了连接
- pdf - 将段落从 PDF 复制粘贴到带有重音符号的 LaTeX