Laravel Octane with RoadRunner

2 min read Updated 4 months ago

Laravel Octane with RoadRunner

RoadRunner is a high-performance PHP application server written in Go. When combined with Laravel Octane, it provides excellent performance by keeping your application in memory between requests.

What is RoadRunner?

RoadRunner is an alternative to FrankenPHP that offers:

  • A mature, battle-tested PHP application server
  • Written in Go for optimal performance
  • Built-in support for workers, queues, and more
  • Excellent memory management

Setting up Octane with RoadRunner

Follow these steps to deploy your Laravel application with Octane and RoadRunner:

  1. Navigate to your application's Settings tab
  2. Find the PHP runtime section
  3. Select FrankenPHP (Octane) as the runtime
  4. Save your settings

Install Laravel Octane and RoadRunner

Before deploying, install Laravel Octane and the RoadRunner packages in your application and commit the changes to your repository:

composer require laravel/octane spiral/roadrunner-cli spiral/roadrunner-http
php artisan octane:install --server=roadrunner

Configure build commands

Add the RoadRunner binary download to your build commands:

  1. Go to your application's Build configuration section
  2. Add the following command to your build commands:
./vendor/bin/rr get-binary

This downloads the RoadRunner binary during the build process.

Set the start command

Configure the start command in your application settings:

  1. Navigate to your application's Settings tab
  2. Find the Start command field
  3. Enter the following command:
php artisan octane:start --server=roadrunner --host=0.0.0.0 --port=8080

Deploy your application

After configuring the runtime, build commands, and start command, deploy your application. The deployment will:

  1. Install the Octane and RoadRunner packages
  2. Download the RoadRunner binary
  3. Start your application using the RoadRunner server

Frequently asked questions

What is the RoadRunner command for Laravel Octane?

Run `php artisan octane:start --server=roadrunner --host=0.0.0.0 --port=8080`. Set this as the start command in your application settings.

How do I install Laravel Octane with RoadRunner?

Run `composer require laravel/octane spiral/roadrunner-cli`, then `php artisan octane:install --server=roadrunner`. Commit and redeploy.

How many workers should I configure for RoadRunner?

Start with 4 workers per CPU core for typical Laravel workloads. Use the `--workers=N` flag to override the default. Tune based on memory headroom and request profile.

When should I choose RoadRunner over Swoole or FrankenPHP?

RoadRunner is a strong middle ground when you want stable, battle-tested Go-based performance without Swoole's extension dependency. Pick FrankenPHP for the simplest setup with HTTP/2; pick Swoole for maximum raw throughput.