1

我一直在研究 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

来自 chrome 开发工具的失败请求列表

4

1 回答 1

0

尝试在 octane start comman 中设置最大请求数--max-requests=1000

于 2021-10-05T00:56:07.607 回答