Long live(d) PHP - Question on ReactPHP and WebSockets

ankush981 profile image Ankush Thakur ・1 min read

PHP is a short-lived process, but it's often common to daemonize it for long-running tasks. A good example would be running a ReactPHP server on Supervisord for handling WebSocket connections (because, you know, you hate Node even though it would be a perfectly valid solution in this case 😜).

So here's my question: PHP and memory leaks are synonymous, which makes me wonder how solutions like ReactPHP perform in production. Here's my nightmare: The ReactPHP server is handling 10,000 WebSocket connections when Supervisor (or something else) realizes that the daemon is leaking memory big time and well, decides to restart it.

If so, what happens to all the active WebSocket connections? 😱😱


markdown guide

I’ve messed with ReactPHP only a small bit. But if a daemon crashes because it ran out of memory, then all 10k connections would drop.


then all 10k connections would drop

Yes, they would, which is what scares me. Which is why I'm wondering how it pans out in production. If no one shares their experience on this post for a long time, I'm forced to conclude that people are scared of this scenario and aren't using ReactPHP. 😋🤣