Site icon Leonid Mamchenkov

Using php-fpm as a simple built-in async queue

Here’s an interesting solution for a poor man’s asynchronous queue using PHP-FPM:

PHP-FPM already acts as a queue for Nginx/Apache FastCGI clients. While your web-request is running you can just send another FastCGI request to the same PHP-FPM socket asynchronously and non-blocking. This request is immediately executed in another php-fpm process in parallel and you could wait for it to complete or just fire and forget.

Given the experimental nature of this approach, you probably won’t be running this in production.  And with many developers switching to the built-in PHP web server for the local development, this doesn’t work for those environments other.

But it makes me think what else can be used as a queuing mechanism.  After all, there are plenty of systems that rely on this already – email servers, printer spoolers, web and proxy servers, and probably more.

Exit mobile version