Skip to main content

What is Octane?

Laravel Octane is a package that dramatically improves the performance of your Laravel application by running it on a high-performance application server. With traditional PHP-FPM, the application boots and shuts down on every request. Octane boots the application once, keeps it in memory, and processes subsequent requests at blazing speed. The key difference from PHP-FPM is that the application boot process — registering service providers, resolving bindings, etc. — runs only once. After that, every request is handled at maximum speed.

Supported servers

Octane supports three application servers.
Laravel Cloud recommends running Octane with FrankenPHP and provides full managed support out of the box.

Installation and configuration

Install the package

Run the Octane installer

You will be prompted to choose a server. After selecting one, config/octane.php will be generated.

FrankenPHP

When you choose FrankenPHP, Octane automatically downloads the binary. No additional steps are required.

RoadRunner

When you choose RoadRunner, Octane automatically downloads the binary.

Swoole

Swoole is a PHP extension that must be installed via PECL.
To use Open Swoole instead, run:

Running Octane

Start the server

By default the server listens on port 8000. Open http://localhost:8000 in your browser.

Specify the server

Set the number of workers

When using Swoole, you can also specify task workers:

Watch for file changes

During development, the server must be restarted to pick up code changes. The --watch flag restarts it automatically whenever a file changes.
--watch requires Node.js and chokidar.

Other management commands

Dependency injection caveats

Because Octane keeps the application in memory, service provider register and boot methods run only once when the server starts. The same application instance is reused across requests, so injecting the container or request into a singleton constructor requires extra care.

Injecting the container

Injecting the container directly into a singleton constructor can leave you with a stale container.
The app() global helper and Container::getInstance() always return the current container, so they are safe to use.

Injecting the request

Type-hinting Illuminate\Http\Request in a controller method or route closure is always safe. The request() global helper also returns the current request.

Injecting the configuration repository

The config() global helper always returns the current configuration repository, so it is safe to use.

Memory leak prevention

Because Octane keeps the application in memory, data accumulated in static properties will grow without bound and eventually exhaust memory.

Recycle workers with max-requests

You can mitigate memory leaks by automatically restarting a worker after it handles a certain number of requests. The default is 500 requests.

Set a maximum execution time

config/octane.php lets you set the maximum execution time per request. The default is 30 seconds.
Restart the Octane server after changing max_execution_time.

Concurrent tasks (Swoole only)

When using Swoole, you can run multiple operations in parallel with Octane::concurrently().
Concurrent tasks run in separate Swoole “task workers”. Set the task worker count with --task-workers.
A maximum of 1,024 tasks can be passed to concurrently() (Swoole limitation).

Ticks and intervals (Swoole only)

Swoole lets you schedule a callback to run at a fixed interval. Register it in your service provider’s boot method.

Octane cache (Swoole only)

The Octane cache is an ultra-fast in-memory cache backed by Swoole tables, capable of up to 2 million read/write operations per second.

Interval cache

An interval cache entry refreshes its value automatically at a fixed interval.
All Octane cache data is cleared when the server restarts.

Swoole tables (Swoole only)

You can define arbitrary in-memory tables that are accessible from every worker process. Configure them in config/octane.php under the tables key.
Access a table with the Octane::table() method.
Swoole tables support only string, int, and float column types. Data is lost when the server restarts.

Production deployment

Nginx + Octane

In production, Octane typically runs behind Nginx. Nginx handles static file serving and SSL termination, then proxies dynamic requests to Octane.

Keep Octane running with Supervisor

Use Supervisor in production to ensure Octane stays running continuously.

Enable HTTPS

To generate HTTPS URLs through Octane, add the following to your .env file.

Laravel Cloud integration

Laravel Cloud provides fully managed Octane support using FrankenPHP. No Nginx or Supervisor configuration is needed — just two steps to enable Octane.
1

Install the package

Install Octane. Running octane:install is optional but harmless.
2

Enable Octane in Laravel Cloud

Open your environment’s App compute cluster settings, turn on “Use Octane as runtime”, then save and deploy. Laravel Cloud automatically builds and starts your application with FrankenPHP + Octane.
See the Laravel Cloud documentation for details.

Reload workers after deployment

After deploying new code, reload the workers so the updated code is loaded into memory.
Last modified on April 15, 2026