workerman/gateway-worker
GatewayWorker is a PHP distributed framework built on Workerman for long-lived TCP, UDP, and WebSocket connections. It separates gateway, business worker, and register processes to scale real-time apps across servers, with process management and messaging for chat, IoT, push, and game backends.
Verdict: GatewayWorker is a credible, actively maintained (release 2025-06-27, MIT) distributed socket framework, but it is a process-level infrastructure component, not a Laravel package. For a Laravel-centric roadmap it is a build decision that creates a permanently separate runtime, not an install decision. The 21.6 score and zero Composer dependents reflect this: the ecosystem consumes GatewayWorker by cloning the distribution, not by composer require, so we inherit unfashionable supply-chain and versioning characteristics.
Architecture fit
pcntl/posix and ideally ext-event. Laravel's request lifecycle (FPM/Octane-per-request, container-per-request, Request facade, session, CSRF, middleware stack) does not exist in that model. Anything stateful in Laravel must be re-derived manually.Integration feasibility
ShouldBroadcast events will not reach it without a bespoke bridge.Technical risk
Key questions for the technical discovery
Stack fit
realtime queue connection for Laravel→BusinessWorker work. Avoid direct HTTP between Laravel and BusinessWorker on the hot path.user_id/tenant_id in Redis with a TTL heartbeat. Never trust a client-supplied identity after handshake.Migration path
wscat/k6/Artillery).Compatibility
pcntl + posix, ext-event strongly preferred over the default select loop for >1k connections. This may not match our app servers' PHP build — plan a separate runtime image.master.Sequencing (TPM view)
| Phase | Deliverable | Exit criteria |
|---|---|---|
| 0 | ADR comparing GatewayWorker vs. Reverb vs. Centrifugo | Written decision with connection-cost model |
| 1 | Runtime image + Supervisor config + CI smoke test | Deploys via existing pipeline, not SSH |
| 2 | Auth handshake + presence + Redis bridge | Pen-test pass, token expiry verified |
| 3 | Shadow traffic + 72h soak | Memory flat, p99 handshake < 300ms |
| 4 | Feature cutover behind flag | Rollback rehearsed and timed |
| 5 | Runbooks, dashboards, on-call handover | SLOs defined and alerting live |
Budget explicitly for the bridge and auth layer — in our experience this is 60–70% of the total effort, and none of it ships with the package.
Maintenance
.env/Laravel config. Duplicate source-of-truth for ports, hosts, and Redis DSNs is a recurring drift source — centralize via a generated config artifact at deploy time.Support
/metrics or status endpoint on the Gateway (connection counts, per-worker memory), and error forwarding into our existing Sentry/log stack.Scaling
Failure modes to instrument and rehearse
| Failure | User-visible symptom | Mitigation |
|---|---|---|
| BusinessWorker blocking on DB/HTTP | All connections on that worker stall silently | Async-only code review gate; per-worker memory + event-loop-lag alerts |
| Memory leak / gradual OOM | Random disconnects after days of uptime | Weekly graceful reload; memory ceiling alarm; soak test in CI |
| Register unreachable | New Gateways can't find workers; partial outages | Redundant Register; health check that exercises discovery, not just TCP |
| Redis outage | Auth failures, no cross-node fan-out, presence lost | Redis HA; fail-closed for auth, fail-open for non-critical presence |
| Deploy without drain | Mass disconnect storm, client reconnect stampede | LB connection draining + graceful worker stop; jittered client backoff |
| No delivery guarantee | Silent message loss under load | Product-level decision: accept, or build Redis Streams replay |
| Token/auth bypass | Security incident | Signed short-TTL tokens, origin checks, per-connection rate limits |
Ramp-up
How can I help you explore Laravel packages today?