Rapira: Rust-Powered PHP Server Hits 111k RPS, 10x Faster Than PHP-FPM

Rapira, a new PHP application server written in Rust, achieves 111,499 RPS with 1.07ms latency in Yii3 benchmarks by embedding the PHP interpreter directly into Rust, eliminating IPC overhead and outperforming PHP-FPM by over 10x while supporting HTTP and gRPC with isolated worker pools.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
Rapira: Rust-Powered PHP Server Hits 111k RPS, 10x Faster Than PHP-FPM

Introduction

In the latest Yii3 official benchmarks, a new PHP application server called Rapira — written in Rust by the maintainers of RoadRunner — stunned the open-source community by delivering 111,499 RPS (requests per second) with an average latency of 1.07 ms on a 16-core physical machine, more than 10× the throughput of traditional PHP-FPM .

Traditional PHP-FPM Bottlenecks

In the classic LNMP stack, Nginx forwards requests via FastCGI to a PHP-FPM process pool. Each request triggers a full framework bootstrap (configuration loading, service registration, class autoloading) and teardown. Even with OPcache eliminating bytecode compilation, the bootstrap phase still consumes 50–80% of total request time as modern frameworks grow more complex.

Client → Nginx → FastCGI → PHP-FPM Process → Bootstrap (load config, register services, autoload) → Execute Business Logic → Cleanup → Response

Resident Memory Worker Revolution

Modern solutions like RoadRunner and FrankenPHP keep the framework and application resident in memory: configuration loads once, the service container builds once, and a loop continuously accepts requests. This removes bootstrap overhead entirely, lifting throughput from thousands to tens of thousands of RPS.

Rapira Architecture

1. Protocol Isolation: Dedicated Listeners and Worker Pools

Rapira natively supports HTTP and gRPC . Unlike traditional servers that multiplex protocols, Rapira assigns each protocol its own Listener and independent PHP worker pool :

HTTP business logic and gRPC microservice RPC calls are fully decoupled at the process-resource level.

No contention for worker resources; one protocol cannot drag down the other under high load.

Operations can configure separate worker counts and timeout policies for HTTP and gRPC.

2. Core Innovation: Embedded PHP Interpreter, Zero IPC Serialization

Traditional RoadRunner approach: Communicates between the main process and PHP workers via STDIN/STDOUT, Unix domain sockets, or TCP sockets, incurring repeated serialization → IPC → deserialization overhead.

Rapira's radical design: Uses Rust to directly embed the PHP interpreter (Zend Engine) inside the server process. Rust calls PHP internal functions directly, eliminating FastCGI, socket communication, and serialization costs, pushing single-machine throughput and call latency to the physical limit.

3. Three Running Modes

Classic Mode (Drop-in Compatibility): Behaves exactly like php-fpm — each request independently initializes and cleans up state. No code changes required for resident-memory adaptation, yet still benefits from Rust's high-performance network layer.

Worker Mode (Mainstream Resident Memory): Each worker process initializes the application once at startup. An internal loop listens for requests; Rapira efficiently repopulates PHP superglobals ( $_SERVER, $_GET, $_POST, etc.) on each request, removing bootstrap overhead while maintaining compatibility with classic global variables.

Dispatcher Mode (Ultimate Performance): Application initializes once. Worker scripts no longer rely on traditional PHP SAPI superglobals; instead they pull task units (HTTP interactions, gRPC tasks) via Rapira's native extension API (e.g., Rapira\get_dispatcher()). This bypasses all legacy baggage to fully exploit hardware potential.

Benchmark Results

Tests ran on an AMD Ryzen 9 7950X (16 cores / 32 threads), 93 GiB RAM, Ubuntu 26.04.1 LTS, Linux 7.0 kernel, PHP 8.5.11, PostgreSQL ( max_connections=2000), with opcache.enable_file_override=1. Load generated by wrkx in 13-step ramp from 2,500 to 200,000 RPS. Contenders: Rapira (three modes), FrankenPHP (two modes), OxPHP (two modes), RoadRunner, FreeUnit, PHP-FPM + Nginx.

Pure Compute Scenario (No DB)

Endpoint / measures network stack parsing, request dispatch, and routing execution limits.

🥇 Rapira Dispatcher: 111,499 RPS, 1.07 ms avg latency, 1.81 ms p95 (Rust + embedded native dispatch)

🥈 Rapira Worker: 102,703 RPS, 1.17 ms avg, 1.96 ms p95 (Rust + embedded resident memory)

🥉 OxPHP Worker: 79,785 RPS, 3.44 ms avg, 14.68 ms p95

4. FrankenPHP Worker: 66,624 RPS, 1.48 ms avg, 2.51 ms p95 (Go + Caddy)

5. RoadRunner: 45,258 RPS, 1.81 ms avg, 3.15 ms p95 (Go coroutine server)

6. FreeUnit: 11,445 RPS, 4.80 ms avg, 9.57 ms p95

7. FrankenPHP Classic: 10,562 RPS, 5.52 ms avg, 17.24 ms p95

8. PHP-FPM + Nginx: 10,264 RPS, 7.18 ms avg, 12.03 ms p95 (industry baseline)

9. Rapira Classic: 9,138 RPS, 4.67 ms avg, 10.10 ms p95

10. OxPHP Classic: 8,749 RPS, 5.41 ms avg, 10.79 ms p95

Key Observations:

Discontinuous Lead: Rapira's two resident modes both exceed 100k RPS; Dispatcher mode hits 111,499 RPS at 1.07 ms latency, dominating the field.

Resident vs. Classic Chasm: All Classic/short-lived modes (including PHP-FPM) plateau around 10k RPS due to repeated framework initialization. Resident worker modes show >10× absolute dominance.

FrankenPHP & RoadRunner Remain Strong: FrankenPHP Worker sustains 66k RPS (p95 2.5 ms); RoadRunner delivers 45k RPS — both production-grade and stable.

Real Business Scenario (With PostgreSQL)

Endpoint /postgres/orders queries an order list, shifting the bottleneck.

🥇 Rapira Dispatcher DB (Worker): 12,907 RPS, 4.11 ms avg, 9.34 ms p95

🥈 FrankenPHP Worker DB: 12,709 RPS, 4.05 ms avg, 7.64 ms p95

🥉 OxPHP Worker DB: 12,705 RPS, 4.09 ms avg, 7.24 ms p95

4. Rapira Worker DB: 12,569 RPS, 4.04 ms avg, 8.84 ms p95

5. RoadRunner DB: 10,619 RPS, 5.03 ms avg, 10.50 ms p95

6. FreeUnit DB (Classic): 6,217 RPS, 6.20 ms avg, 9.25 ms p95

7. FrankenPHP Classic DB: 6,029 RPS, 9.07 ms avg, 17.98 ms p95

8. PHP-FPM + Nginx DB (Classic): 5,806 RPS, 9.74 ms avg, 18.49 ms p95

9. OxPHP Classic DB: 5,044 RPS, 12.92 ms avg, 21.26 ms p95

10. Rapira Classic DB: 4,713 RPS, 9.59 ms avg, 21.71 ms p95

Key Observations:

Bottleneck Shifts from CPU to I/O: With real database interaction, network I/O, SQL parsing, and connection limits become the primary constraints. All resident runtimes converge to a 12k–13k RPS band.

Worker Still Wins 2.2×: Compared to PHP-FPM's 5,806 RPS, the worker camp maintains over double the throughput. More importantly, latency experience leaps forward : Classic modes average ~10 ms with p95 spiking to 18.5 ms, while FrankenPHP/Rapira/OxPHP hold average latency around 4 ms and p95 stable at 7–8 ms , significantly improving tail-latency resilience under concurrency.

Production Considerations

1. Extreme Performance vs. Production Stability

During the high-load ramp, Rapira recorded socket-read errors at the most extreme overload stages, indicating its edge-case handling under severe network congestion is still evolving. In contrast, FrankenPHP Worker and RoadRunner completed the full stress test with zero errors , delivering a stable, production-ready scorecard.

2. Selection Decision Tree

Industrial Maturity & Cloud-Native Ecosystem → Choose FrankenPHP: Built on Caddy, includes production-grade reverse proxy, automatic Let's Encrypt HTTPS management, native HTTP/2 and HTTP/3 support, elegant configuration. Currently the official recommendation for Laravel Octane and modern PHP community.

Complex Microservice Orchestration & Multi-Protocol Scheduling → Choose RoadRunner: Supports HTTP, gRPC, Temporal workflows, RPC calls, and queue consumers. Mature ecosystem with extensive industrial deployments.

Maximize Single-Node Performance & Explore Next-Gen Systems Programming → Watch Rapira Closely: Crafted by the RoadRunner team, its "embed PHP directly in Rust" architecture represents the cutting edge of PHP application server evolution. As versions iterate and stability hardens, its potential is unbounded.

Legacy Systems with Heavy Technical Debt → Stick with PHP-FPM: If codebase heavily abuses uncleaned singletons and global static variables, resident memory may introduce leaks and dirty data. Traditional PHP-FPM remains the safest shield.

Conclusion

As of 2026, PHP is no longer merely a scripting language running under Apache modules. Empowered by Rust's performance, Go's high-concurrency coroutine scheduling, and resident-memory worker architectures, modern PHP retains its exceptional development velocity while achieving microsecond-level response performance on par with — or exceeding — Go and Java.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PerformanceRustPHPBenchmarkFrankenPHPApplication ServerRoadRunnerRapira
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.