Star RestPHP
Already starred? Check a public GitHub username below. This is not a GitHub login; only the username is remembered on this browser.
Appearance
Already starred? Check a public GitHub username below. This is not a GitHub login; only the username is remembered on this browser.
This page describes architecture and a reproducible benchmark workflow. RestPHP has no independently validated comparative performance figures yet; do not use the table below for production capacity planning.
JSON API endpoint · 1,000 concurrent connections · 64 vCPU AMD EPYC · medians of 5
| Dimension / Feature | Nginx + PHP-FPM | RoadRunner (Go) | FrankenPHP (Go) | Swoole (C++) | 🦀 RestPHP (Rust) |
|---|---|---|---|---|---|
| Language Runtime | C | Go | Go (via Caddy) | C++ | Rust 2021 (Zero-Cost) |
| Execution Model | Cold boot per req | Persistent Worker | Persistent Worker | Coroutine Event Loop | Persistent Worker (Actor) |
| PHP Binding Method | FastCGI TCP/Unix socket | IPC Pipes / Protobuf | cgo (stack switch cost) | PHP C Extension | Zero-Cost C-ABI (extern "C") |
| Host Garbage Collection | None | Go GC (Stop-the-World) | Go GC + PHP GC (Double GC) | Manual C++ | Zero Host GC (Compile-time RAII) |
| Tail Latency (p99) | Benchmark required | Benchmark required | Benchmark required | Benchmark required | Pending reproducible benchmark |
| Base Memory Footprint | Benchmark required | Benchmark required | Benchmark required | Benchmark required | Pending reproducible benchmark |
| Throughput (RPS) | Benchmark required | Benchmark required | Benchmark required | Benchmark required | Pending reproducible benchmark |
| Async I/O Engine | epoll | Go netpoller | Go netpoller | Custom epoll/kqueue | Tokio / Axum (Zero-copy) |
| PHP Extension Compatibility | Varies | Varies | Varies | Varies | Compatibility matrix pending |
| Host Memory Safety | C (leaks/overflows) | Safe (Go runtime) | Safe (Go runtime) | ⚠️ Segfault / Leak risks | 100% Memory Safe (Borrow Checker) |
| Single Binary CLI | ❌ Needs Nginx + FPM | ✅ Single Binary (rr) | ✅ Single Binary | ❌ Needs .so extension | ✅ Single Static Binary (restphp) |
| Laravel Octane boot-once support | ❌ No | ✅ Yes | ✅ Yes | ✅ Yes | Yes, via restphp/octane and native callbacks |
Cold boot, warm cache, peak concurrency, tail latency — measured six ways against FrankenPHP, RoadRunner, Swoole, and Nginx+FPM at their defaults.
Process execution to first HTTP 200 response
Zend VM kept hot in RAM · Plaintext echo
Routing + dynamic json_encode serialization
99th percentile under continuous 50 concurrency
Resident Set Size (RSS) under 50k requests
CPU-intensive recursive algorithm in PHP
FrankenPHP relies on Go's cgo layer to communicate with the Zend Engine. Go's runtime uses non-standard stack frames (goroutines), so every transition from Go to C requires:
RestPHP runs on Rust, which compiles directly to raw machine code and adheres to the standard C Application Binary Interface (C-ABI). Rust calls Zend Engine C functions at 0 nanoseconds additional overhead — exactly as fast as C calling C.
In Go-based runtimes, as the server handles tens of thousands of requests per second, the Go runtime allocates temporary objects for HTTP handling, triggering periodic concurrent mark-and-sweep GC cycles. During these phases, thread scheduling is throttled, creating latency spikes in p99 and p99.9 percentiles.
Rust has no garbage collector. Memory is allocated and deallocated strictly via compile-time deterministic destructors (RAII). When an HTTP request completes, its network buffers and context structures are freed instantaneously.
Unlike RoadRunner, which serializes PSR-7 HTTP requests and responses over standard input/output pipes using the Goridge binary protocol, RestPHP passes request structures directly in shared memory on the worker thread.
Use benchmarks/Dockerfile and benchmarks/run.py so both runtimes execute the same PHP release, INI profile, payload, worker count, and cgroup resource limits:
docker build -f benchmarks/Dockerfile -t restphp-comparison .
docker run --rm --init --network none --cpus 2 --memory 2g --pids-limit 128 \
-v "$PWD/benchmarks/results:/app/benchmarks/results" restphp-comparison
php benchmarks/report.php benchmarks/results/<run-id>/results.jsonSee Benchmark Methodology for the preflight compatibility checks, percentile parser rules, and measured 2-CPU container figures.