{"id":27865,"date":"2017-08-21T14:19:27","date_gmt":"2017-08-21T12:19:27","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=27865"},"modified":"2017-08-21T14:19:27","modified_gmt":"2017-08-21T12:19:27","slug":"using-php-fpm-as-a-simple-built-in-async-queue","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2017\/08\/21\/using-php-fpm-as-a-simple-built-in-async-queue\/","title":{"rendered":"Using php-fpm as a simple built-in async queue"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>Here&#8217;s <a href=\"https:\/\/tideways.io\/profiler\/blog\/using-php-fpm-as-a-simple-built-in-async-queue\">an interesting solution<\/a> for a poor man&#8217;s asynchronous queue using PHP-FPM:<\/p>\n<blockquote><p>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.<\/p><\/blockquote>\n<p>Given the experimental nature of this approach, you probably won&#8217;t be running this in production. \u00a0And with many developers switching to the built-in PHP web server for the local development, this doesn&#8217;t work for those environments other.<\/p>\n<p>But it makes me think what else can be used as a queuing mechanism. \u00a0After all, there are plenty of systems that rely on this already &#8211; email servers, printer spoolers, web and proxy servers, and probably more.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Here&#8217;s an interesting solution for a poor man&#8217;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 &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2017\/08\/21\/using-php-fpm-as-a-simple-built-in-async-queue\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using php-fpm as a simple built-in async queue<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Using php-fpm as a simple built-in async queue #WebDev #PHP","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62,1334],"tags":[38,1330],"keyring_services":[],"class_list":["post-27865","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","category-web-work","tag-php","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":26306,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/08\/04\/504-gateway-timeout-error-on-nginx-fastcgi-php-fpm\/","url_meta":{"origin":27865,"position":0},"title":"504 Gateway Timeout error on Nginx + FastCGI (php-fpm)","author":"Leonid Mamchenkov","date":"August 4, 2016","format":false,"excerpt":"\"504 Gateway Timeout\" error is a very common issue when using Nginx with PHP-FPM. \u00a0Usually, that means that it took PHP-FPM longer to generate the response, than Nginx was willing to wait for. \u00a0A few possible reasons for this are: Nginx timeout configuration uses very small values (expecting the responses\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"504","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2016\/08\/504-500x385.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":49042,"url":"https:\/\/mamchenkov.net\/wordpress\/2020\/05\/25\/send-additional-http-headers-to-nginxs-fastcgi\/","url_meta":{"origin":27865,"position":1},"title":"Send additional HTTP headers to Nginx&#8217;s FastCGI","author":"Leonid Mamchenkov","date":"May 25, 2020","format":false,"excerpt":"It's not that often that I come across a useful, but undocumented feature in a major software application.\u00a0 It happened recently, so I'll document it here just for the future self. For a particular setup, I had to send additional HTTP headers (let's use X-GEOIP for this example) to the\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27681,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/06\/14\/async-php-requests-reactive-responses-with-php-fpm\/","url_meta":{"origin":27865,"position":2},"title":"Async PHP Requests &#038; Reactive Responses with PHP-FPM","author":"Leonid Mamchenkov","date":"June 14, 2017","format":false,"excerpt":"https:\/\/speakerdeck.com\/hollodotme\/async-php-requests-and-reactive-responses-with-php-fpm \"Async PHP Requests & Reactive Responses with PHP-FPM\" is talk by\u00a0Holger Woltersdorf, in which he shares the approaches he tried for implementing asynchronous requests in PHP, and how he arrived at\u00a0hollodotme\/fast-cgi-client, which is a\u00a0PHP fast CGI client for sending requests (a)synchronously to PHP-FPM.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28276,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/12\/11\/php-fpm-tuning-using-pm-static-for-max-performance\/","url_meta":{"origin":27865,"position":3},"title":"PHP-FPM tuning: Using \u2018pm static\u2019 for Max Performance","author":"Leonid Mamchenkov","date":"December 11, 2017","format":false,"excerpt":"\"PHP-FPM tuning: Using \u2018pm static\u2019 for Max Performance\" looks at different process management settings in PHP-FPM: static, dynamic, and ondemand, and the way they affect performance.\u00a0 The default - ondemand - might work well for you if you have a large server with plenty of resources and not so many\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":29034,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/11\/26\/roadrunner-high-performance-php-application-server-load-balancer-and-process-manager\/","url_meta":{"origin":27865,"position":4},"title":"RoadRunner &#8211; high-performance PHP application server, load-balancer and process manager","author":"Leonid Mamchenkov","date":"November 26, 2018","format":false,"excerpt":"RoadRunner is a high-performance PHP application server, load-balancer and process manager, written in Goland.\u00a0 It sounds like an excellent replacement for the built-in PHP server, and even more than that - it's production-ready.\u00a0 And it works on Windows too. RoadRunner is an open source (MIT licensed) high-performance PHP application server,\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27453,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/03\/26\/php-enqueue-enterprise-queue-solutions-for-php\/","url_meta":{"origin":27865,"position":5},"title":"php-enqueue &#8211; enterprise queue solutions for PHP","author":"Leonid Mamchenkov","date":"March 26, 2017","format":false,"excerpt":"php-enqueue - enterprise queue solutions for PHP. \u00a0There is a number\u00a0of GitHub repositories for the project. \u00a0PHP Enqueue supports a number of transports - ampq, stomp, filesystem - and it provides a flexible collection of classes to deal both with the queue manager, as well as a client. \u00a0If your\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=27865"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27865\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=27865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=27865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=27865"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=27865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}