spiral/roadrunner
High-performance PHP application server and process manager written in Go. RoadRunner replaces Nginx+FPM with long-running workers and a plugin system, offering HTTP(S)/2/3, FastCGI, PSR-7/17 support, and per-project extensibility.
RoadRunner is a high-performance PHP application server that replaces traditional Nginx+FPM setups, offering lower latency, better resource utilization, and plugin-based extensibility. It aligns well with modern Laravel architectures by:
Illuminate\Http\Middleware).Key Laravel Synergies:
spiral/roadrunner-jobs plugin).| Component | Feasibility | Notes |
|---|---|---|
| HTTP Server | ✅ High | Replaces php artisan serve or FPM; supports middleware, routing, and PSR-15. |
| Queue Workers | ✅ High | Plugins for RabbitMQ, Kafka, SQS, etc., replace Laravel’s queue:work. |
| gRPC | ✅ Medium | Requires protobuf extension; useful for internal services but not core Laravel features. |
| Temporal Workflows | ⚠️ Low | Overkill for most Laravel apps; niche use case for long-running workflows. |
| WebSockets | ✅ Medium | Via Centrifugo plugin; requires additional setup but enables real-time features. |
| Database Connections | ⚠️ Low | RoadRunner is stateless; Laravel’s connection pooling (e.g., pdo_mysql) must be managed externally. |
Laravel-Specific Considerations:
bind()/singleton() may need adjustments for shared state.App\Http\Middleware\Authenticate) works natively.spiral/roadrunner-events plugin).| Risk Area | Severity | Mitigation |
|---|---|---|
| State Management | High | Laravel’s session/state (e.g., session:store) may break if not externalized (e.g., Redis). |
| Plugin Compatibility | Medium | Some plugins (e.g., Temporal) require deep Laravel architecture changes. |
| Performance Tuning | Medium | Go-based; requires tuning of worker pools, timeouts, and memory limits in .rr.yaml. |
| Debugging Complexity | High | Go/PHP hybrid stack; debugging requires familiarity with both ecosystems. |
| Migration Downtime | Medium | Zero-downtime migration possible but requires dual-run testing. |
| Vendor Lock-in | Low | MIT license; open-source; but Go-based plugins may introduce dependencies. |
Critical Questions for TPM:
file, database) work in a stateless RoadRunner environment?Illuminate\Queue\Jobs\Job) work out-of-the-box with RoadRunner’s plugins?web, api) map to RoadRunner’s middleware stack?schedule:run) without blocking HTTP workers?RoadRunner is optimized for Laravel when paired with:
nyholm/psr7, psr/http-message) is fully compatible.spiral/roadrunner-http for non-blocking I/O (e.g., database calls).SIGUSR2 graceful restarts).Anti-Patterns:
array cache) unless externalized (Redis).file_get_contents) will degrade performance.| Phase | Steps | Tools/Plugins |
|---|---|---|
| Proof of Concept | Replace php artisan serve with RoadRunner for a single route (e.g., /api/health). |
spiral/roadrunner-cli, .rr.yaml |
| HTTP Server | Migrate all HTTP routes to RoadRunner; test middleware, auth, and sessions. | spiral/roadrunner-http, PSR-15 |
| Queue Workers | Replace queue:work with RoadRunner’s queue plugins (e.g., RabbitMQ). |
spiral/roadrunner-jobs |
| gRPC/Microservices | Expose internal services via gRPC if needed. | spiral/roadrunner-grpc |
| Observability | Integrate OpenTelemetry for tracing; expose Prometheus metrics. | spiral/roadrunner-otel |
| CI/CD Pipeline | Add RoadRunner to Docker/Kubernetes manifests; test rollouts. | Helm charts, Dockerfiles |
| Rollback Plan | Maintain FPM as a fallback; use feature flags to toggle between stacks. | N/A |
Example .rr.yaml for Laravel:
version: '3'
server:
command: "php artisan roadrunner:work"
http:
address: "0.0.0.0:8080"
middleware: ["static", "otel", "gzip"]
pool:
num_workers: auto
max_jobs: 100
allocate_timeout: 60s
destroy_timeout: 60s
jobs:
queue: "redis"
pool:
num_workers: 4
max_jobs: 100
otel:
service_name: "laravel-app"
exporter: "otlp"
otlp:
endpoint: "http://jaeger:4317"
| Laravel Feature | RoadRunner Compatibility | Workarounds |
|---|---|---|
| Routing | ✅ Full | Uses PSR-15 middleware; Laravel’s Route service works unchanged. |
| Middleware | ✅ Full | PSR-15 compliant; groups (web, api) map directly. |
| Authentication | ✅ Full | Laravel’s Auth middleware (e.g., Authenticate) works as-is. |
| Validation | ✅ Full | Uses Laravel’s Illuminate\Validation via PSR-15. |
| Database (Eloquent) | ✅ Full | Stateless; connections must be managed externally (e.g., connection pooling). |
| Queues | ✅ Partial | Requires spiral/roadrunner-jobs plugin; may need job class adjustments. |
| Events | ⚠️ Partial | No native support; requires |
How can I help you explore Laravel packages today?