As we have seen in the previous chapters of this book, I/O calls will always offer the worst performance due to the underlying latency of establishing, using and closing streams and sockets. Since PHP is basically a synchronous language that waits for a called function to return before resuming code execution, I/O calls are especially problematic if the called function has to wait for a stream to close before returning to the calling code. This becomes even worse when a PHP application has thousands of I/O calls to do every few minutes for example.
Since PHP 5.3, it has become possible to interrupt PHP's normal flow of execution by using generators and thus, to execute code asynchronously. As we have seen previously, even if dynamic structures can be less performant in general, they can still be useful in speeding up blocking code. This...