Laravel applications are commonly deployed with PHP-FPM behind Nginx or Apache. It is a proven approach, but PHP typically follows a request-based lifecycle: the framework is bootstrapped for each request. As traffic grows, that repeated startup work can become part of the time your application spends responding.
Laravel Octane uses long-lived application workers. It boots your Laravel application once and keeps it in memory while workers handle multiple requests. This can reduce repeated bootstrapping overhead, but it also changes how you must manage application state, memory, deployments, and worker restarts.
This guide explains how Octane works, compares FrankenPHP, RoadRunner, and Swoole, walks through installation and deployment, and covers the production issues you should understand before switching.
What Is Laravel Octane?
Laravel Octane is an application-server integration that serves Laravel through high-performance servers, including FrankenPHP, Open Swoole, Swoole, and RoadRunner. Octane boots the application and keeps it in memory, then reuses its workers to handle subsequent requests.
That does not automatically make every database query, external API call, or business operation faster. Octane is most useful when repeated application bootstrapping is a meaningful part of your request cost and your application is safe to run in a long-lived worker environment.
PHP-FPM vs Laravel Octane
| Area | Traditional PHP-FPM | Laravel Octane |
|---|---|---|
| Application lifecycle | Traditional PHP request lifecycle | Long-lived application workers |
| Bootstrapping | Normally repeated for each request | Application remains loaded between requests |
| In-process state | Usually discarded at request end | Can survive between requests if retained |
| Operations | Widely supported hosting model | Requires worker and application-server management |
| Best fit | General-purpose PHP deployments | Workloads that benefit from a long-running application process |
FrankenPHP vs RoadRunner vs Swoole
Octane relies on an application server to manage incoming requests and long-running workers. The server you choose affects installation, runtime dependencies, deployment, and operational practices.
FrankenPHP
FrankenPHP is a PHP application server built on top of Caddy. It provides an integrated web-server and PHP runtime approach and supports worker mode.
- A useful option if you want an integrated web server and PHP application runtime.
- Can simplify some container-based deployments.
- Octane's installer can download and install the FrankenPHP binary.
- Check the PHP version bundled with the binary; updating system PHP does not necessarily update FrankenPHP's bundled PHP runtime.
RoadRunner
RoadRunner is a Go-based application server that manages PHP worker processes. It communicates with those workers and controls their lifecycle.
- Useful when you want a separate process manager for PHP workers.
- Requires the RoadRunner binary and the relevant PHP packages.
- Its binary and configuration should be versioned and tested as part of your deployment.
Swoole and Open Swoole
Swoole is a PHP extension that provides server, networking, coroutine, and asynchronous capabilities. Open Swoole is a community-maintained fork in the same ecosystem. Octane supports Swoole-based deployments, but you must install a compatible extension in your PHP runtime.
- Useful for teams already familiar with the Swoole ecosystem.
- Can provide coroutine and asynchronous capabilities when application code is designed to use them.
- Requires extension installation and compatibility testing.
- Blocking code does not become asynchronous automatically.
Which one should you choose?
| Option | Consider it when |
|---|---|
| FrankenPHP | You want an integrated PHP application server and a container-friendly deployment model. |
| RoadRunner | You prefer a separate Go-based process manager for PHP workers. |
| Swoole / Open Swoole | Your team needs or already operates the Swoole extension ecosystem. |
There is no universally fastest choice. Performance depends on PHP and package versions, extensions, application code, infrastructure, concurrency, and the workload being tested. Compare the options on the same hardware with the same application and traffic profile.
Requirements Before Installing Octane
- A Laravel application and PHP version supported by the Octane release you plan to install.
- Composer and permission to install the package.
- The runtime binary or PHP extension required by your chosen server.
- A process manager or container orchestrator for production worker lifecycle.
Check the current Octane documentation and Composer constraints before selecting versions. Do not assume a command or PHP version from an older tutorial is still correct.
Step 1: Install Laravel Octane
From your Laravel project directory, install the package:
composer require laravel/octane
Publish the Octane configuration and complete the installation:
php artisan octane:install
Follow the installer prompts to select your application server. For a predictable automated setup, specify the server explicitly where supported by your installed Octane version. For example:
php artisan octane:install --server=frankenphp
RoadRunner requires its related packages and binary. Swoole requires a compatible PHP extension. Follow the server-specific section of the official documentation for the exact prerequisites.
Step 2: Start the Octane Server
The standard Artisan command for starting Octane is:
php artisan octane:start --server=frankenphp --host=127.0.0.1 --port=8000
For a RoadRunner deployment, select RoadRunner instead:
php artisan octane:start --server=roadrunner --host=127.0.0.1 --port=8000
The server option must match the server you installed and configured. Octane normally uses port 8000 unless you configure another port. For local testing, visit http://127.0.0.1:8000.
Check the options available in your installed version with:
php artisan help octane:start
Step 3: Run Octane in Docker
Octane can run inside Docker. The following is an illustrative container command pattern for an image that already contains the correct PHP runtime, required extensions, Composer dependencies, and FrankenPHP setup:
CMD ["php", "artisan", "octane:start",
"--server=frankenphp",
"--host=0.0.0.0",
"--port=8000"]
For a complete image, start with a pinned, tested FrankenPHP image tag or digest, install the PHP extensions your application needs, install Composer dependencies during the image build, and copy only the required application files. The correct base image and extension installation steps depend on your Laravel and PHP versions.
Do not copy development secrets into the image. Inject credentials at runtime through your deployment platform. Use correct file ownership, avoid running as root where your image and deployment support a non-root user, and configure a health check.
In Docker Compose, the Octane service should listen on an interface reachable by the reverse-proxy service. You generally do not need to publish the Octane port publicly; keep it on the private application network.
Step 4: Put Nginx in Front of Octane
For many production deployments, Nginx or Apache remains in front of Octane. The web server can terminate TLS, serve static assets, apply request limits, and proxy dynamic requests to Octane.
A simplified Nginx proxy location looks like this:
server {
listen 80;
server_name example.com;
location / {
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8000;
}
}
This is a minimal illustration, not a complete production Nginx configuration. Follow Laravel's current Octane Nginx example when configuring static-file handling, WebSocket upgrades, URI forwarding, and other details. Configure TLS at the proxy or load balancer, and ensure Laravel trusts forwarded headers only from known proxy addresses.
Understand the Long-Lived Worker Problem
The most important difference between a traditional PHP request lifecycle and Octane is that memory can survive between requests.
Avoid retaining request-specific data
Be careful with static properties, global variables, and singleton services that store the current user, request, tenant, or other request-specific information. If that state is not reset correctly, it can affect a later request handled by the same worker.
Resolve request-specific values when they are needed. Use Laravel's supported scoped bindings and lifecycle patterns, and test that data from one user's request cannot appear in another user's response.
Do not assume file or configuration changes are immediately loaded
Octane keeps the application in memory. Changes to routes, configuration, or application code generally require the running server or workers to be reloaded. Treat worker reloads as part of your deployment process.
Monitor memory and recycle workers
Long-running workers can accumulate memory because of retained objects, large datasets, or third-party libraries. Octane provides a maximum request count option to gracefully recycle workers. The documented default is 500 requests, and you can adjust it with --max-requests.
php artisan octane:start --server=frankenphp --max-requests=250
Choose a value based on observed memory behavior rather than copying a number from another environment.
Configure Worker Counts
Octane starts application request workers based on the available CPU cores by default. You can specify a worker count:
php artisan octane:start --server=frankenphp --workers=4
Do not increase workers blindly. Each worker consumes memory, and additional workers can increase pressure on your database, cache, and external services. Measure memory per worker under realistic traffic and leave capacity for the operating system, proxy, and supporting services.
Reload Workers After Deployment
When you deploy new code, existing Octane workers may still have the previous application loaded. Include a reload step after the new release and required cache operations are ready:
php artisan octane:reload
For containerized deployments, a rolling replacement of containers may be a better fit. Ensure readiness checks pass before routing traffic to new instances, and allow old instances to drain gracefully. Test the deployment and rollback process before relying on it in production.
Benchmark Before and After
Do not choose Octane based on a benchmark from a different machine or a simple hello-world route. Measure representative endpoints from your own application.
Keep the PHP version, hardware, database, cache, data volume, and request mix consistent. Warm up the application and repeat each test. Track:
- Requests per second
- Median and 95th/99th percentile response time
- CPU and memory usage
- Error and timeout rates
- Database query count and duration
- External API latency
Tools such as k6 and ApacheBench can generate load. A faster static endpoint does not prove that a database-heavy workflow will improve by the same amount.
Common Production Problems
Old code is still running after deployment
Likely cause: Existing workers still have the previous release loaded.
What to check: Add Octane reload or controlled container replacement to the deployment pipeline. Verify that the new release is actually serving requests.
Worker memory keeps increasing
Likely cause: Retained objects, static state, large in-memory collections, or a library that does not release resources.
What to check: Profile memory, inspect long-lived services, review static and singleton state, and tune worker recycling using measurements.
One user's data appears in another request
Likely cause: Request-specific state has been stored in a long-lived object or static property.
What to check: Remove shared mutable request state. Add tests that send requests from different users through the same worker and verify data isolation.
Docker requests fail or time out
Likely cause: Missing PHP extensions, wrong runtime binary, incorrect permissions, wrong bind address, or a proxy networking issue.
What to check: Review container logs, verify the server listens on the expected interface and port, and test connectivity from the proxy container to the Octane service.
Laravel Octane Production Checklist
- Confirm Laravel, PHP, Octane, and application-server compatibility.
- Pin and test runtime and container image versions.
- Keep secrets outside the image and source repository.
- Run with appropriate filesystem permissions.
- Place the application server behind a trusted proxy or load balancer.
- Configure TLS, forwarded headers, request limits, and timeouts.
- Review singleton, static, and global state for request-data leaks.
- Set worker counts and recycling based on measured memory.
- Configure health checks, logs, metrics, and alerts.
- Include worker reload or controlled replacement in deployments.
- Load-test realistic endpoints and verify user-data isolation.
- Maintain and test a rollback plan.
Frequently Asked Questions
Is Laravel Octane faster than PHP-FPM?
Octane can reduce repeated application bootstrapping and improve performance for suitable workloads. Actual results depend on your application, infrastructure, and traffic. Benchmark before switching.
Which is better: FrankenPHP, RoadRunner, or Swoole?
There is no universal winner. FrankenPHP offers an integrated PHP application server, RoadRunner manages PHP workers through a Go-based server, and Swoole provides extension-based server and coroutine capabilities. Choose based on your requirements and team's experience.
Can I use Laravel Octane with Docker?
Yes. Run the Octane server as the container's foreground process, keep it on a private application network, and plan for health checks, secrets, worker lifecycle, and graceful replacement.
Does Laravel Octane replace Nginx?
Not necessarily. FrankenPHP includes web-server capabilities, but many production architectures still use Nginx or Apache in front of Octane for TLS termination, static assets, and reverse proxying.
Do I need to change my Laravel code?
Many applications need only limited changes, but you must review code that stores mutable state in singletons, static properties, or global variables. Long-lived workers make request-state leaks more important.
Is Octane suitable for every Laravel project?
No. A small application with low traffic may not gain enough to justify the additional operational complexity. Evaluate Octane when profiling shows that its execution model could improve your actual workload.
Final Thoughts
Laravel Octane gives Laravel applications a long-running worker model that can reduce repeated framework bootstrapping and improve performance for suitable workloads. FrankenPHP, RoadRunner, and Swoole provide different ways to run those workers, each with its own installation and operational trade-offs.
The important part is not simply installing Octane and expecting an instant performance boost. Review application state, measure memory, plan worker restarts, secure the reverse-proxy boundary, and benchmark realistic user journeys.
If your Laravel application is reaching performance limits, Octane is worth testing—but let profiling and repeatable measurements guide the decision.
Official Resources
- Laravel 13 Octane documentation
- Laravel deployment documentation
- FrankenPHP official website
- RoadRunner official website
- OpenSwoole official website
Originally published on DEV Talk.
Top comments (0)