Skip to content
Laravel Rust vs PHP: is PHP the bottleneck?Laravel Rust vs PHP: is PHP the bottleneck?

Laravel Rust vs PHP: is PHP the bottleneck? ​

Laravel released Laravel for Rust with a Chirper benchmark on a 1 vCPU instance. In that benchmark, Laravel Rust reached 1,774 RPS, while Laravel PHP with Octane and FrankenPHP reached 97 RPS. Those numbers look like an 18x language gap between Rust and PHP.

Then ihxnnxs/laravel-symfony-benchmarking (article) added Symfony 8.2 with Doctrine scalar hydration on Swoole and matched Laravel Rust at the 2,000 RPS script limit. We wanted to check whether PHP itself is the bottleneck and see how Rapira behaves on the same workload. We ran all six setups on one host and raised the ramp ceiling to 5,000 RPS to find where each stack saturates.

Setup ​

All six setups ran against the same MySQL 8.4 schema with 10 authors and 200 chirps. The k6 script kept the traffic mix from laravel/laravel-framework-benchmarking-2026. Requests split across 50% latest feed (GET /api/v1/chirps), 20% next page, 10% previous page, and 20% detail (GET /api/v1/chirps/{id}). Every response had to pass JSON schema checks, Content-Encoding: gzip, and Vary: Accept-Encoding.

Laravel's official benchmark ran chirper-laravel-rust serve on Laravel Cloud, where Cloudflare handled gzip outside the 1 vCPU container. To keep the unmodified k6 gzip check locally in Docker, ihxnnxs/laravel-symfony-benchmarking added Caddy in front of laravel-rust (caddy-laravel-rust). We kept caddy-laravel-rust to match that repo and added axum-laravel-rust on laravel-rust 0.1.0 with in-process tower-http gzip and no Caddy.

  • Host: AMD Ryzen 9 9950X3D, Linux x86_64, Podman 6.2.0, k6 2.4.0 pinned to host cores 16 to 23.
  • Containers: One target at a time with --cpus=1 --memory=4g on an isolated bridge network, talking to mysql:8.4 with --cpus=1 --memory=4g.
  • Profiles: steady60 (50 RPS for 60 s), ramp2k (1 to 2,000 RPS over 180 s), and ramp5k (1 to 5,000 RPS over 180 s for targets reaching 1,800 RPS in ramp2k).
  • Scoring: Upstream score.py selects the highest failure-free 10-second window for ramps and the best 10-second window for steady load.

Rapira test build

Both Rapira targets used a development build from feat/app-vfs (217b0dd6) linked to PHP 8.5.14-dev ZTS (pdo_mysql, mbstring, OPcache). rapira pack bundled each app into a standalone in-memory /app VFS binary, and the runtime image contained no /app directory. Both Rapira targets ran in dispatcher mode with built-in Rust gzip compression (min_size = 1, gzip_level = 6).

TargetStack and settingsImage size
rapira-symfonySymfony 8.2.0, Doctrine 3.8 (scalar), PHP 8.5.14-dev ZTS, JIT 64M, 2 workers, max_requests = 10000, VFS binary (14.94 MiB)192 MB
swoole-symfonySymfony 8.2.0, Doctrine 3.8 (scalar), PHP 8.5 NTS, JIT 64M, Swoole 6.2.6 (base), 2 workers, 1 reactor, max_requests = 10000622 MB
rapira-laravelLaravel 13.42.0, Octane 2.24.0, rapira/laravel 0.1.1, PHP 8.5.14-dev ZTS, no JIT, 4 workers, max_requests = 500, VFS binary (18.09 MiB)196 MB
frankenphp-laravelLaravel 13.42.0, Octane 2.24.0, FrankenPHP, PHP 8.5, no JIT, 4 workers, max_requests = 500, Caddy gzip691 MB
axum-laravel-rustlaravel-rust 0.1.0, MySQL (DB_MAX_CONNECTIONS=20), thin LTO, in-process tower-http gzip (SizeAbove(1)), no Caddy118 MB
caddy-laravel-rustlaravel-rust 0.1.0, MySQL (DB_MAX_CONNECTIONS=20), thin LTO, Caddy gzip proxy (upstream ihxnnxs setup)169 MB

We matched worker counts, max_requests, compression settings, and JIT settings between each Rapira target and its upstream counterpart. rapira-symfony matched swoole-symfony, and rapira-laravel matched frankenphp-laravel.

Results ​

Steady load (50 RPS, 60 s) ​

All six targets completed 100% of requests with zero errors at 50 RPS.

Targetp50 (ms)p95 (ms)p99 (ms)Peak RAM (MiB)
rapira-symfony1.2301.7801.97866.75
swoole-symfony1.1711.8312.32257.54
axum-laravel-rust1.1531.8012.23119.13
caddy-laravel-rust1.3532.0432.21139.68
rapira-laravel6.7078.4059.733117.78
frankenphp-laravel6.8468.94511.024125.41

Ramp to 2,000 RPS (180 s) ​

Four targets cleared 100% of requests with zero failures and zero dropped iterations. Both Laravel PHP targets saturated near 190 RPS.

TargetBest 10s RPSp50 (ms)p95 (ms)p99 (ms)Overall HTTP failPeak RAM (MiB)
rapira-symfony1,944.00.8071.2211.7140.00%65.80
swoole-symfony1,944.00.7821.5772.1390.00%58.10
axum-laravel-rust1,944.01.0741.7853.1200.00%18.66
caddy-laravel-rust1,944.11.0681.6412.7540.00%42.24
rapira-laravel191.21,164.9682,049.9312,144.12759.69%126.93
frankenphp-laravel189.21,132.5852,121.6282,206.19769.78%249.10

Ceiling ramp to 5,000 RPS (180 s) ​

We ran the four fast targets up to 5,000 RPS to measure where each one saturates on 1 vCPU.

TargetBest 10s RPSZero-drop peakp50 / p95 / p99 at best window (ms)Overall HTTP failPeak RAM (MiB)
swoole-symfony3,430.03,193.7 RPS (p99 4.46 ms)392.81 / 550.45 / 2,009.490.05% (189 / 406,098)145.82
rapira-symfony2,912.52,638.2 RPS (p99 2.20 ms)224.78 / 449.33 / 494.280.00% (0 / 371,582)93.85
axum-laravel-rust2,638.42,638.4 RPS (p99 12.10 ms)1.25 / 4.38 / 12.100.00% (0 / 332,160)162.98
caddy-laravel-rust2,082.62,082.6 RPS (p99 14.15 ms)1.07 / 5.10 / 14.150.00% (0 / 280,649)523.28

Learnings ​

  • ORM cost dominates Laravel PHP: Both rapira-laravel (191.2 RPS) and frankenphp-laravel (189.2 RPS) hit the same CPU limit. Eloquent model hydration, toArray() conversion, and three queries per feed page spend most of the CPU time. Switching from FrankenPHP to Rapira VFS cut peak RAM by 49% (126.93 vs 249.10 MiB) and reduced ramp failures (59.69% vs 69.78%). It also reduced the container image from 691 MB to 196 MB. Moving from the rapira-laravel stack to the rapira-symfony stack (Symfony, Doctrine scalar hydration, JIT, 2 workers) increased throughput by 15.2x (191.2 to 2,912.5 RPS).
  • The Caddy proxy cost inside 1 vCPU: Removing Caddy and compressing in-process with tower-http raised laravel-rust peak throughput by 27% (2,082.6 to 2,638.4 RPS). It cut steady RAM by 52% (39.68 to 19.13 MiB) and ramp5k peak RAM by 69% (523.28 to 162.98 MiB). It also reduced the container image from 169 MB to 118 MB. Placing a second proxy process inside a 1 vCPU container adds loopback I/O and CPU contention that skews saturation benchmarks.
  • Both Symfony PHP servers still passed axum-laravel-rust above 2,000 RPS: Even without Caddy, swoole-symfony peaked at 3,430.0 RPS (1.30x axum-laravel-rust) and rapira-symfony peaked at 2,912.5 RPS (1.10x axum-laravel-rust). At the 2,638 RPS zero-drop window, rapira-symfony held 2.20 ms p99 versus 12.10 ms p99 on axum-laravel-rust. axum-laravel-rust still runs the same three-query feed pattern and model hydration as Laravel PHP, while both Symfony setups use a two-query scalar join.
  • rapira-symfony vs swoole-symfony: swoole-symfony achieved 18% higher saturated throughput (3,430.0 vs 2,912.5 RPS) and lower steady RAM (57.54 vs 66.75 MiB). Both ran one HTTP I/O thread (SWOOLE_REACTORS=1 vs Rapira's single rapira-io-0 shard under --cpus=1), so the ceiling gap reflects PHP NTS versus ZTS overhead. At ramp2k, rapira-symfony delivered the lowest p95 (1.221 ms) and p99 (1.714 ms) latency of all six targets. Under ramp5k overload, rapira-symfony kept 0.00% HTTP failures and 494 ms best-window p99, while swoole-symfony had 189 failures and 2,009 ms best-window p99. rapira-symfony also used 36% less peak RAM (93.85 vs 145.82 MiB) and shipped a 192 MB image instead of 622 MB.
  • Where axum-laravel-rust leads: axum-laravel-rust produced the smallest image (118 MB) and the lowest RAM at steady load (19.13 MiB) and ramp2k (18.66 MiB). Its latency stays low under normal load without PHP worker pools or OPcache memory budgets.
  • Limits of this test: We used 3-minute ramps instead of the original 20-minute ramp. Rootless Podman on this host did not expose cgroup v2 cpuset, so containers used --cpus=1 CFS quotas as in upstream compose.yaml. A single local host also has much lower MySQL network latency than a managed cloud database.

Takeaways ​

  1. Profile the framework before you rewrite the language: On this 1 vCPU API, PHP was not the bottleneck. Moving from the rapira-laravel stack to the rapira-symfony stack inside PHP produced a 15.2x gain. Changing the application server on the same Eloquent code cut memory and failure rates rather than raw RPS.
  2. Match query count and hydration to the endpoint: Read-heavy list endpoints pay heavily for hydrating full ORM entity graphs on every request. Explicit projections and joins reduce both database work and object allocation.
  3. Compare runtimes on full operational behavior: Throughput at one ceiling is only one number. Tail latency under load, overload error behavior, peak memory, and image size all matter when you run a service in production.

See the Laravel and Symfony guides to run your own applications on Rapira.

Last updated: