tillythecoder.com
tillythecoder.com
Turbocharge Your Laravel Apps with Octane
Tilly The Coder

Turbocharge Your Laravel Apps with Octane

Tilly The Coder · ·
5 mins
This is the estimated time it takes to read the article.
PHP
Laravel

Laravel is already famous for its expressive syntax and developer‑friendly tooling, but you can squeeze far more performance out of the framework by running it under Laravel Octane. Octane boots your application once, keeps it resident in memory, and then uses a high‑performance server like Swoole, RoadRunner, or (new in late 2023) FrankenPHP to handle every subsequent request at lightning speed.

1. Why Octane Matters in 2025

A traditional Laravel request goes through a full bootstrap on every hit. Octane skips that entire cycle, which means:

  • 5×–20× lower response times on simple routes. In a July 2025 benchmark of Laravel 12, FrankenPHP handled nearly more requests per second than PHP‑FPM and still outpaced RoadRunner or the Swoole variants.

  • Dramatically higher throughput under concurrent load because workers are already warm.

  • Built‑in primitives (concurrent tasks, in‑memory cache, ticks) that remove the need for many “micro‑optimization” packages.

If you build APIs, real‑time dashboards, or queue‑heavy back ends, the gains are immediate and measurable.

2. How Octane Works Under the Hood

When you start Octane, it:

  1. Boots a pool of PHP workers equal to the CPU core count (or a custom --workers value).

  2. Sends each HTTP request directly to an idle worker.

  3. Keeps the bootstrapped service container, routes, and configuration in RAM for the entire worker lifespan.

  4. Optionally spins up separate task workers (Swoole only) so long‑running jobs don’t block the main request workers.

Because the framework stays alive between requests, cold‑start overhead disappears and your CPU can focus on actual business logic.

3. Picking Your Engine

Engine

Strengths

Trade‑offs

FrankenPHP

Fastest raw throughput, single static binary, first‑class TLS & Early Hints support

Younger ecosystem

OpenSwoole / Swoole

Mature async features, Octane‑only goodies (ticks, Octane cache, tables)

Requires PECL extension and careful memory hygiene

RoadRunner

Written in Go, rich feature set (queues, workflows), excellent stability

Slightly less raw speed than FrankenPHP or OpenSwoole in 2025 tests

Pick the server that matches your operational comfort: if you want raw speed with zero extensions, FrankenPHP is compelling; if you need async sockets or in‑memory tables, OpenSwoole shines; for enterprise‑grade process management, RoadRunner is battle‑tested.

4. Installing Octane in a Fresh Laravel 11/12 Project

composer require laravel/octane --dev
php artisan octane:install        # Choose your preferred server when prompted
php artisan octane:start --server=frankenphp --workers=auto

Octane ships a config/octane.php file where you can switch servers later or fine‑tune worker counts.

5. Configuration Quick‑Start

Setting

Purpose

Example

--workers=

Number of request workers

php artisan octane:start --workers=8

--task-workers=

Separate pool for async tasks (Swoole)

--task-workers=6

--max-requests=

Auto‑recycle workers to avoid memory leaks

--max-requests=500

Keeping a sane --max-requests is the simplest defence against slow, creeping leaks.

6. Real‑World Benchmarks

Test (100 concurrency, 30 s)

PHP‑FPM

RoadRunner

OpenSwoole

FrankenPHP

/api/health‑check

18 k RPS

45 k RPS

52 k RPS

81 k RPS

/api/static

15 k RPS

39 k RPS

45 k RPS

70 k RPS

These numbers are from Stephen Roque’s July 2025 face‑off on identical hardware. Even heavyweight endpoints that perform external HTTP calls saw a 2×–4× lift.

7. Advanced Features You Should Actually Use

Concurrent Tasks

use Laravel\Octane\Facades\Octane;
use Illuminate\Support\Facades\Http;

$result = Octane::concurrently([
    fn () => Http::get('https://api.github.com/repos/laravel/octane')->json(),
    fn () => Http::get('https://api.github.com/repos/laravel/framework')->json(),
]);

Both requests run in parallel, trimming external I/O latency.

Octane Cache & Tables

Need a super‑fast, ephemeral cache?

Cache::store('octane')->put('framework', 'Laravel', 30);

Powered by Swoole tables, it can push ≈ 2 M ops/sec but resets if the server restarts.

Ticks (Intervals)

Octane::tick('clear-temp', fn () => Storage::disk('temp')->deleteOldFiles())
    ->seconds(30);

Great for lightweight polling or housekeeping without firing a full Cron job.

8. Best Practices to Keep the Wheels On

  • Avoid static state and improper singletons. Data persists for the life of the worker, so accidental sharing can leak private information.

  • Watch memory. Use octane:status, a low --max-requests, and Laravel Pulse or Grafana to catch leaks early.

  • Check package compatibility. Some libraries assume a fresh boot per request. Test thoroughly and use Octane’s “flush” callbacks where needed.

  • Offload heavy jobs. Long‑running image conversions or reports still belong in queues or dedicated workers, not in an Octane request.

9. When Octane Isn’t the Right Fit

  • Tiny brochure sites that rarely exceed a few RPS. The complexity isn’t worth the marginal gain.

  • CPU‑bound bulk data exports where the work happens in queues or CLI anyway.

  • Environments where you can’t install extensions or custom binaries (shared hosting, some PaaS tiers).

Stick with classic PHP‑FPM in those cases.

10. Final Thoughts

Laravel Octane turns PHP’s traditional request‑per‑process model on its head. By keeping your app hot in memory and leveraging modern servers such as FrankenPHP, you unlock performance previously reserved for Go or Node stacks. The key is to respect the new rules of a persistent runtime: guard against shared state, recycle workers, and profile memory. Do that, and you’ll enjoy API responses that feel instant, happier users, and infrastructure that can handle Black Friday traffic without breaking a sweat.

Ready to give your app afterburners? Install Octane today, run your first benchmark, and watch the numbers speak for themselves.