Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ThunderBirdsX3's avatar

Octane very slow than Nginx

I try to benchmark my project with wrk and results is run with Octane very slow than Nginx.

Test with route

Route::get('/test', function () {
    return 'test';
});

And php artisan optimize

Nginx (Valet)

$ wrk -t12 -c400 -d30s http://vas-backend.test/test
Running 30s test @ http://vas-backend.test/test
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    10.47ms   69.60ms   2.00s    99.27%
    Req/Sec     1.95k     1.85k   11.60k    82.89%
  698555 requests in 30.03s, 232.36MB read
  Socket errors: connect 156, read 69, write 0, timeout 1463
  Non-2xx or 3xx responses: 697016
Requests/sec:  23259.00
Transfer/sec:      7.74MB

Octane (Roadrunner)

$ wrk -t12 -c400 -d30s http://127.0.0.1:8000/test  
Running 30s test @ http://127.0.0.1:8000/test
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   653.05ms  271.14ms   1.56s    84.29%
    Req/Sec    37.53     35.91   290.00     89.40%
  10966 requests in 30.10s, 10.98MB read
  Socket errors: connect 155, read 79, write 14, timeout 0
Requests/sec:    364.33
Transfer/sec:    373.58KB

Octane (Swoole)

$ wrk -t12 -c400 -d30s http://127.0.0.1:8000/test
Running 30s test @ http://127.0.0.1:8000/test
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   748.43ms  133.24ms   2.00s    87.14%
    Req/Sec    18.54     14.94   121.00     79.67%
  4540 requests in 30.06s, 4.74MB read
  Socket errors: connect 155, read 93, write 0, timeout 1312
Requests/sec:    151.02
Transfer/sec:    161.53KB

I not understand why. Or it about Dependency Injection or not?

I quite not understand about this https://laravel.com/docs/9.x/octane#dependency-injection-and-octane

0 likes
2 replies
LaryAI's avatar
Level 58

There could be several reasons why Octane is slower than Nginx. One possible reason is that Octane is still a relatively new technology and may not be optimized for all use cases. Another reason could be that the server configuration is not optimized for Octane.

To troubleshoot the issue, you can try the following:

  1. Check the Octane logs for any errors or warnings that may indicate a problem.

  2. Check the server configuration to ensure that it is optimized for Octane. For example, you may need to adjust the number of worker processes or the amount of memory allocated to Octane.

  3. Try running Octane with a different web server, such as Caddy or Apache, to see if the performance improves.

  4. Check the application code to ensure that it is optimized for Octane. For example, you may need to adjust the number of database queries or optimize the code for concurrency.

  5. Try disabling any middleware or other features that may be slowing down Octane.

Here is an example of how to optimize the server configuration for Octane:

# Increase the number of worker processes
workers=8

# Increase the amount of memory allocated to Octane
memory_limit=512M

# Increase the number of requests that can be processed in a single worker process
max_requests=10000

# Enable the OpCache extension to improve performance
extension=opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000

You can also try using a different web server, such as Caddy or Apache, to see if the performance improves. To do this, you will need to configure Octane to use the new web server. Here is an example of how to configure Octane to use Caddy:

# Install Caddy
sudo apt-get install caddy

# Configure Octane to use Caddy
php artisan octane:install --server=caddy

# Start Octane with Caddy
php artisan octane:start

If none of these solutions work, you may need to contact the Laravel support team for further assistance.

Please or to participate in this conversation.