Start free trial
Start free trial Log in

14-day free trial. No credit card.

How to monitor Laravel Octane in production

Octane workers persist across requests, which changes what you monitor and how.

  • Guide
  • 3 min read

How do I monitor Laravel Octane?

Monitor three things PHP-FPM doesn't force you to: (1) per-worker memory growth across requests (look for upward drift that indicates a leak), (2) worker crash rate (frequent crashes signal Octane-incompatible code), (3) request latency distribution to confirm the worker boot savings are materializing. Laravel's nightwatch package is Octane-compatible; NightOwl records each request's peak memory, duration, queries, and exceptions.

Updated

Octane makes your app faster by breaking the one assumption almost every Laravel package was written under: that the process starts fresh for each request and throws everything away at the end. Keep a worker alive across thousands of requests and you get a big latency win, and a new class of bug. State that used to evaporate now lingers; memory that used to be reclaimed now accumulates; a fatal error now takes down a worker that has already booted, and its replacement pays the boot cost again. Monitoring Octane is mostly about watching for the failure modes that only exist because the process stopped dying between requests.

What makes Octane monitoring different

In PHP-FPM, Laravel boots for every request and PHP frees everything when the request ends. In Octane, a worker boots once and handles thousands of requests. Three implications:

  1. Memory accumulates. Leaks that were invisible in PHP-FPM (PHP freed the memory after each request) now grow until max_requests recycles the worker or it crashes.
  2. Singletons resolved at boot carry state. A singleton resolved while the application boots (in a service provider, for example) keeps its properties across every request the worker handles. Singletons first resolved during a request are discarded when it ends. Good for perf, dangerous if you stash per-request data in the boot-time ones.
  3. Fatal errors restart the worker. An uncaught exception is rendered as an error response and the worker keeps serving. A PHP fatal error, such as exhausting memory_limit, kills the worker process. Octane starts a new one, which boots the framework again.

Detecting memory leaks

Record memory at request start AND end, tagged by worker PID:

app/Http/Middleware/OctaneMemoryProbe.php

php
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class OctaneMemoryProbe
{
    public function handle(Request $request, Closure $next)
    {
        $startMb = memory_get_usage(true) / 1024 / 1024;
        $response = $next($request);
        $endMb = memory_get_usage(true) / 1024 / 1024;

        Log::info('Request memory', [
            'pid' => getmypid(),
            'route' => $request->route()?->uri(),
            'start_mb' => round($startMb, 2),
            'end_mb' => round($endMb, 2),
            'delta_mb' => round($endMb - $startMb, 2),
        ]);

        return $response;
    }
}

Filter by PID. A healthy worker's delta hovers around zero; a leaky worker's end-of-request memory creeps upward over time. When you spot a leaking worker, the most recent requests before the growth spike usually hold the culprit.

Octane-safe patterns

Don't stash per-request data in singletons

php
// Bad if resolved at boot: the first user sticks for the worker's lifetime
$this->app->singleton(UserContext::class, function ($app) {
    return new UserContext($app['auth']->user());
});

// Good: bind fresh per request
$this->app->bind(UserContext::class, function ($app) {
    return new UserContext($app['auth']->user());
});

Use listeners for per-request reset

php
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Event;
use Laravel\Octane\Events\RequestTerminated;

public function boot(): void
{
    Event::listen(function (RequestTerminated $event) {
        // Clear anything that shouldn't carry between requests
        app(MyStatefulThing::class)->reset();
    });
}

Driver-specific notes

FrankenPHP

Single binary. Built-in HTTPS. The simplest operational story. Worker mode shares most Octane semantics. Supports HTTP/3 which matters for latency-sensitive APIs.

Swoole

Adds Octane features the other drivers lack, such as concurrent tasks: Octane::concurrently([...]) fans out I/O-bound work to Swoole task workers. Requires the swoole PHP extension; more complex operational story than FrankenPHP.

RoadRunner

Go-based worker manager, mature and stable. It runs as a separate rr binary that Octane downloads for you, with the spiral/roadrunner-cli and spiral/roadrunner-http Composer packages alongside.

What to alert on

  • Worker crashes: alert on crash rate > 0 sustained. Crashes usually mean a fatal error, such as a request exhausting memory_limit.
  • Memory growth: per-worker delta trending upward over 100+ requests.
  • Request latency regression: if p95 on Octane looks like PHP-FPM, something's wrong with your deploy.
  • max_requests restart rate spike: if workers recycle far more often than max_requests suggests, something is OOM-killing them.

NightOwl won't raise these alerts itself: it alerts when a new exception appears or a request crosses its route's duration threshold, so the rate and trend checks above need your process supervisor or metrics stack.

See each Octane request's memory and queries

NightOwl runs on the laravel/nightwatch package, which works with FrankenPHP, Swoole and RoadRunner workers. Open any request to see its peak memory in the Info panel, on the same page as its duration, query timeline and exceptions.

No credit card needed.

Terminal
composer require nightowl/agent
php artisan nightowl:install
php artisan nightowl:agent

Frequently asked questions

Anything else, write to support@usenightowl.com

What's different about monitoring Laravel Octane vs PHP-FPM?

Octane keeps workers alive across requests. Instead of bootstrapping Laravel per request, a worker boots once and handles thousands. That changes three things: memory accumulates across requests (watch for leaks), singletons resolved at boot carry state between requests (watch for stale data), and a fatal error restarts the worker (watch for crashes). Uncaught exceptions don't kill the worker: Octane renders the error response and the worker carries on.

Which Octane driver should I use: Swoole, RoadRunner, or FrankenPHP?

FrankenPHP is the newest (shipped 2023) and simplest: single binary, no separate app server. Swoole has the largest Octane-specific feature set (concurrent tasks, ticks and intervals, the Octane cache and tables) but needs a PHP extension. RoadRunner is mature and stable, with Go-based worker management. For new projects in 2026, FrankenPHP is often the pragmatic pick; choose Swoole when you need its Octane-only features. Laravel Vapor doesn't use any of the three.

How do I detect memory leaks in Octane?

Compare memory_get_usage() at request start vs end within a single worker. A persistent upward drift over many requests indicates a leak. Log worker PID alongside memory and filter by PID to see per-worker growth. Common leak sources: static caches in service classes, event listeners not cleaning up, Eloquent models retained in a container-bound service.

What's the max_requests setting in Octane?

Octane recycles workers after processing a configurable number of requests (--max-requests, 500 by default for every driver). The intent is a safety net: even if you have a slow leak, periodic restarts bound its impact. Set it low enough that a leak doesn't crash before recycle, high enough that the bootstrap overhead doesn't dominate.

Should I use Octane in production?

Octane can noticeably reduce per-request latency, because the framework boots once per worker instead of once per request, and it is stable in production. The tradeoffs are: (1) code must be Octane-safe (singletons can't hold per-request state, and globals must not leak between requests), (2) deploy workflow must restart workers (octane:reload), (3) monitoring needs to account for persistent workers. Worth it for latency-sensitive apps; overkill for low-traffic admin panels.

How do I monitor Octane worker health?

Three signals: (1) worker crashes: Octane restarts crashed workers automatically, but frequent crashes signal an Octane-incompatible bug, (2) memory per worker over time, which should be stable-ish, (3) request latency distribution: Octane workers should be substantially faster than PHP-FPM; if they're not, something's misconfigured. Latency and each request's peak memory are visible in APMs that record per-request data. Per-worker memory needs the worker PID, which you log yourself (see the middleware in the memory leaks section).

Does Octane break Laravel monitoring tools?

Some. Tools that assume fresh-per-request bootstrap can break. The Nightwatch package (used by NightOwl and Nightwatch Cloud) is Octane-compatible. Generic APMs using request-start hooks may miss some spans if the hook doesn't fire on persistent workers. Check your tool's Octane docs before deploying.

What's the difference between Octane's concurrent tasks and regular queued jobs?

Octane::concurrently() (Swoole only) runs closures in parallel on Octane's task workers within a single request, useful for parallelizing I/O-bound work inside one HTTP response. Queued jobs are for work that should happen outside the request entirely. Concurrent tasks are faster for in-request fan-out; queued jobs are for anything the user shouldn't wait on.

Flat pricing, whatever your traffic does

Every plan starts with a 14-day free trial. No credit card needed.

Hobby
$5 a month

One app for a side project. Issues and alerts, with a 14-day dashboard window.

Start my 14-day trial
TeamRecommended
$15 a month

Up to 3 apps and 5 people per team. Full history, the MCP server, data clearing and agent health.

Start my 14-day trial
Agency
$69 a month

Unlimited client apps and people, one overview of every app, and apps you can hand over.

Start my 14-day trial

Related

Watch your Octane requests on your own app

Install the agent, keep serving through Octane, and open any request to see its peak memory and queries. No credit card needed.