Also on Medium: Laravel Beyond One Runtime

Lab source: github.com/myminethealmighty/lab-notes

What changes when the same Customer API runs on Laravel PHP, Laravel Go, and Laravel Rust — and what a local laptop lab shows

This article is a short research note for Laravel developers. Classic shipping path is still Laravel PHP. New betas also offer Laravel Go and Laravel Rust. Routes, models, env, and Redis stay familiar. How each Laravel stack runs underneath does not.

The goal is not to pick a winner from a screenshot. The goal is to name the trade-offs that show up when you keep a Laravel-shaped Customer API and change the stack: memory, concurrency, FPM vs binary, and deploy shape. A small local lab sits near the end. Those numbers are preliminary. They are not a production ranking.

Three Laravel stacks in plain terms

Laravel PHP optimizes for shipping web apps and team speed on the classic php-fpm path.

Laravel Go optimizes for simple concurrency and a long-lived single binary while keeping Laravel-shaped handlers.

Laravel Rust optimizes for control and memory safety without a tracing garbage collector (GC), again with Laravel-shaped routes and models.

The practical question is shared: can one Laravel app vocabulary sit on three stacks? The betas for Laravel Go and Laravel Rust are young. The process and memory differences are old and real.

Memory under each Laravel stack

Topic Laravel PHP Laravel Go Laravel Rust
Main model Request work, then tear down in the worker Long-lived process + concurrent GC Ownership, moves, RAII (no tracing GC)
Safety focus Runtime checks Runtime + GC Compile-time borrow checker
Typical server shape php-fpm worker pool One serve process, many goroutines One serve process, threads / async

Laravel PHP often frees memory as a request ends. That fits php-fpm and the usual Laravel deploy.

Laravel Go keeps a concurrent GC in one long-lived process that still speaks routes and models.

Laravel Rust does not ship a tracing GC for normal app memory. Ownership catches many use-after-free bugs at compile time while you still write Laravel-shaped handlers.

Tiny contrast: who owns the buffer?

Laravel PHP

function buffer(): string { $buf = str_repeat('x', 1024); return $buf; } 

Laravel Go

func buffer() []byte { buf := make([]byte, 1024) return buf } 

Laravel Rust

fn buffer() -> Vec<u8> { let buf = vec![b'x'; 1024]; buf } 

Concurrency in each Laravel deploy

Topic Laravel PHP (common deploy) Laravel Go Laravel Rust
Overlap model Many FPM workers; one request per worker Goroutines + scheduler inside one process Threads and/or async (Tokio and friends)
Scale lever pm.max_children and pool size Tasks inside one binary Tasks inside one binary + type rules
Learning cost Familiar for Laravel teams Moderate Higher (ownership + async)

Laravel PHP in production is still mostly php-fpm. Overlap comes from more workers, not thousands of tasks in one process.

Laravel Go can overlap work inside the same process:

func overlap() int { ch := make(chan int, 1) go func() { ch <- 1 }() return <-ch } 

Laravel Rust can look similar with async, but the type system tracks shared mutation:

async fn overlap() -> i32 { let handle = tokio::spawn(async { 1 }); handle.await.unwrap() } 

Same Customer API on three Laravel stacks

The lab keeps one route list across Laravel PHP, Laravel Go, and Laravel Rust. Here is the same /health idea in each stack.

Laravel PHP

public function __invoke(): JsonResponse { $database = 'ok'; try { DB::select('select 1'); } catch (Throwable $e) { $database = 'error: '.$e->getMessage(); } return response()->json([ 'status' => $database === 'ok' ? 'ok' : 'degraded', 'runtime' => 'php', 'database' => $database, ]); } 

Laravel Go

func Show(r *web.Request) *web.Response { database := "ok" if _, err := db.Select[int](r, "select 1"); err != nil { database = "error: " + err.Error() } status := "ok" if database != "ok" { status = "degraded" } return web.JSON(map[string]string{ "status": status, "runtime": "go", "database": database, }) } 

Laravel Rust

pub async fn show() -> Json<serde_json::Value> { let database = match db::query!("SELECT 1").scalar::<i64>().await { Ok(_) => "ok".to_string(), Err(err) => format!("error: {err}"), }; let status = if database == "ok" { "ok" } else { "degraded" }; Json(json!({ "status": status, "runtime": "rust", "database": database, })) } 

Routes stay aligned too: /health, /customers, /customers/search, /benchmark/cpu|json|cache. Models, env, and Redis stay in the same mental model.

Process model and ops surprises

A Laravel PHP FPM pool of N workers is roughly N copies of warm framework state. Laravel Go and Laravel Rust are usually one long-lived process with a connection pool.

In the local lab, many Laravel PHP FPM workers opened many short TCP connections to MySQL. Ephemeral ports ran out. Laravel Go and Laravel Rust on the same machine, pooling inside one process, did not hit that failure. The Laravel PHP fix was a MySQL unix socket.

Most Laravel APIs are I/O-bound. The query plan often beats the stack debate. CPU-bound work is where a Laravel Go or Laravel Rust sidecar often earns its keep.

Deploy shape for each Laravel stack

Topic Laravel PHP Laravel Go Laravel Rust
What you ship Source + Composer vendor + FPM + web server Native binary (go build) Native binary (cargo build --release)
App process php-fpm + nginx / Apache (common) One serve process One serve process
Caveat More moving parts at the app tier Still need DB, Redis, config Debug builds are not fair; use --release

Throughput vs latency

Throughput is requests per second (RPS).

Latency is how long one request takes.

You can raise RPS while p95 gets worse. For API work on any Laravel stack, MySQL and Redis often dominate both.

Local lab: same Customer API

The lab runs the same Customer API on Laravel PHP, Laravel Go, and Laravel Rust.

Shared routes. Redis on. Debug off. Small seeded dataset. Load tool: k6.

Laravel PHP used nginx + php-fpm (not artisan serve). Laravel Go and Laravel Rust used release binaries. Laravel PHP and Laravel Rust used a MySQL unix socket. Laravel Go stayed on TCP. No Octane. Local laptop only.

Lab health check

apps-health.png

Health checks on :8001 Laravel PHP, :8002 Laravel Go, :8003 Laravel Rust.

Fair load (lighter traffic)

One row — not stacked walls of text (Laravel PHP | Laravel Go | Laravel Rust):

Laravel PHP — 197.93 RPS · err 0% · p50 5.42 ms · p90 8.69 ms · p95 9.74 ms

Laravel Go — 209.88 RPS · err 0% · p50 1.82 ms · p90 4.16 ms · p95 4.87 ms

Laravel Rust — 212.31 RPS · err 0% · p50 1.37 ms · p90 3.03 ms · p95 3.73 ms

fair-load-row.png

Fair-load RPS side by side (Laravel PHP / Laravel Go / Laravel Rust).

Sample k6 exports (public repo):

Scripts: benchmarks/k6. Sample index: benchmarks/samples.

Fair stress (heavier traffic)

Same sources, heavier traffic (Laravel PHP | Laravel Go | Laravel Rust):

Laravel PHP — 1268.03 RPS · err 0% · p50 2.87 ms · p90 6.04 ms · p95 9.10 ms

Laravel Go — 1373.14 RPS · err 0% · p50 1.37 ms · p90 3.02 ms · p95 3.63 ms

Laravel Rust — 1407.80 RPS · err 0% · p50 0.89 ms · p90 1.75 ms · p95 2.10 ms

fair-stress-table.png

Fair-stress summary from k6 (0% errors).

Sample k6 exports (public repo):

Two ops notes matter more than the ranking:

  1. A Laravel Rust debug build is not fair next to a release binary. Stress p95 moved from 13.55 ms (debug) to 2.10 ms (--release).
  2. A mid-pass Laravel PHP run with about 27% errors was MySQL TCP ephemeral-port exhaustion, not a broken search query.

Host monitoring

Host charts used Prometheus, Grafana, cAdvisor, and node exporter. They watch the machine. They do not replace k6 for API RPS on any Laravel stack.

Important: a red DOWN on :8001 / :8002 / :8003 in Prometheus is about the /metrics scrape path, not about the Customer API being offline for normal HTTP. The Laravel PHP, Laravel Go, and Laravel Rust apps answer /health and the load routes. They do not expose a Prometheus exporter yet, so those scrapes return 404 and show DOWN. Infra jobs (node, cadvisor, prometheus) stay UP. That split is expected.

monitoring-explained.png

Infra scrapes UP; app /metrics 404 is missing exporters, not offline apps.

When to stay, when to switch

Stay on Laravel PHP when the product is a Laravel product: admin UI, domain workflows, the package ecosystem, and a team that already ships Laravel PHP well. About 1268 RPS at 0% errors behind nginx and php-fpm on a laptop is not a crisis. Benchmarking artisan serve is.

Reach for Laravel Go when you want Laravel-shaped handlers, goroutine concurrency, and a single binary — and you accept a younger stack (and, today, TCP MySQL in that driver).

Reach for Laravel Rust when tail latency and CPU-bound request work matter, and the team can learn ownership and async. Always measure --release builds.

The hybrid path is still common: keep Laravel PHP for the monolith surface; move a hot read or compute path to Laravel Go or Laravel Rust behind the same HTTP contract.

Conclusions

  1. Laravel PHP, Laravel Go, and Laravel Rust can share app vocabulary. The stacks still differ on GC, memory safety, concurrency, FPM vs binary, and deploy shape.
  2. Fair comparisons need fair servers: nginx + php-fpm for Laravel PHP, release binaries for Laravel Go and Laravel Rust, and honest MySQL transport notes.
  3. Fix error rate before you screenshot RPS. Ops failures can look like stack wins.
  4. For many CRUD APIs, I/O and query plans dominate. Stack choice matters more for concurrency shape, safety needs, and CPU-heavy sidecars.
  5. Treat the laptop lab as a notebook, not a production ranking.

Demo and open source

Public repo: https://github.com/myminethealmighty/lab-notes

Suggested name on the machine checkout: laravel-php-go-rust-lab (published as lab-notes).

Useful paths:

References

  1. Laravel docs — https://laravel.com/docs
  2. Laravel blog (search Laravel Go / Laravel Rust betas) — https://blog.laravel.com
  3. Laravel Go — https://go.laravel.com
  4. A Tour of Go — https://go.dev/tour/
  5. The Rust Programming Language (The Book) — https://doc.rust-lang.org/book/
  6. PHP php-fpm — https://www.php.net/manual/en/install.fpm.php
  7. k6 docs — https://grafana.com/docs/k6/
  8. Prometheus docs — https://prometheus.io/docs/
  9. Grafana docs — https://grafana.com/docs/
  10. Lab notes (open source) — https://github.com/myminethealmighty/lab-notes