Swoole vs RoadRunner in 2024: real-world comparison
We are migrating our monolith to async PHP. Currently evaluating Swoole and RoadRunner. Main concern is third-party libraries that rely on global state or static properties. Anyone switched between them and can share what broke?
We are on PHP 8.2, Symfony components, no framework-level DI yet.
Switched from RoadRunner to Swoole about 8 months ago. The main pain with RR is that every package that stores state in static properties (think registry patterns, doctrine entity managers) needs explicit cleanup between requests. Swoole with Hyperf uses coroutine context for that, so the leak surface is smaller if you are disciplined.
We run RoadRunner in production for two years now, stability is solid. gRPC transport is a real plus if you have internal services. For pure HTTP load I do not think you will see a meaningful difference between them.
RoadRunner does not require PHP extensions, which matters in some CI environments. Swoole needs the extension installed. For pure compatibility that is the deciding factor for us.
The coroutine model in Swoole is deeper. If you plan to do parallel DB queries or HTTP fan-out in a single request, Swoole coroutines are cleaner than fibers in RR. But for typical CRUD, you will not notice.
Memory leaks are the real enemy with both. Long-running processes expose leaks that FPM hides by killing the process after each request. Run a load test for 10k requests before going to production and watch RSS growth.
what about sessions tho? we still use $_SESSION in like 3 places and i cant rewrite them rn
Sessions with native PHP session_ functions are broken in async context, both Swoole and RR. You need to use Redis sessions through the framework adapter. With Swoole there is also the problem that session_start is a blocking syscall.
For Symfony components specifically: http-foundation sessions work if you swap the storage to a non-file driver. Most components are stateless and work fine.