Laravel Octane Nginx Supervisor Configuration

2.7k Views Asked by At

I've been investigating Laravel Octane as a possibility for performance improvements in an existing Laravel application and have found every 4000-5000 requests up to 15 requests are returning as failed.

I currently have the laravel application deployed and running octane through supervisor with the following configuration in /etc/supervisor/conf.d/laravel-octane-worker.conf :

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

With an nginx configuration like this:

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;
    }
}

It looks like there is some kind of supervisor process contention on octane refresh but I cant identify the issue. Below shows the log after successful requests:


  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

List of failed requests from chrome dev tools

1

There are 1 best solutions below

0
On

try set max requests in octane start comman --max-requests=1000