A comparison of Swoole and ReactPHP

I am a newcomer to PHP. I never used it in my career but recently we developed some very successful projects using WordPress and it was WordPress that provided an entry point into the PHP world for me. I found WordPress to be great for low to medium traffic web applications. Its secret power is the rich ecosystem of plugins that come with it. All plugins come with the source code and as long as you are not going to distribute your product, you can hack and modify the plugins no matter what the license associated with them. As I increased my knowledge of WordPress, I came to know about its shortcomings related to being a PHP application and how all PHP apps work. All calls to MySQL and all HTTP requests are synchronous. The whole execution context is recreated on every single incoming request and torn down in the end.

There is a lot of exciting stuff the PHP community has done to make it more performant. Gradually I came to know about Swoole and ReactPHP. I summarize them side-by-side in below table:

Swoole ReactPHP
Aims to be like Go (multiple workers, coroutines)Aims to be like Node.js (single threaded, non-blocking event loop)
Documentation is not very goodMuch better documentation and videos on YouTube
Not compatible with XdebugCompatible with Xdebug
Yasd debugger has issuesN/A
Can use nodemon for “hot code reloading”
More performantGood enough (node.js like performance)
Excellent architecture. Uses all the learnings and features from Node.js – streams, promises etc.
Very comfortable for a Node.js developer
Comparing Swoole with ReactPHP

Both libraries run in CLI mode and you don’t need any webserver like Apache or NGINX. In the end if I were to pick, ReactPHP is my choice. One thing I have noticed is that there are hardly any questions related to Swoole or ReactPHP on StackOverflow. What does that tell us?

References:

This entry was posted in Software. Bookmark the permalink.

Leave a comment