{"id":16,"date":"2016-01-29T19:25:36","date_gmt":"2016-01-29T15:25:36","guid":{"rendered":"http:\/\/www.dobryakov.net\/blog\/?p=16"},"modified":"2016-01-29T19:25:36","modified_gmt":"2016-01-29T15:25:36","slug":"queues-web-cluster-without-upstreams-orchesration","status":"publish","type":"post","link":"https:\/\/www.dobryakov.net\/blog\/16\/","title":{"rendered":"Queues: web cluster without upstreams orchesration"},"content":{"rendered":"<p>The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and the response should be sent synchronously &#8211; as plain HTTP response (not as secondary callback).<\/p>\n<p>I do not pretend to be original, but will tell you how we did it:<!--more--><\/p>\n<p>Put a \u201ctypical\u201d web server at the entrance point, written on any programming language, even PHP script (will be call it as \u201cinput script\u201d). It accepts HTTP-request and assigns them an unique UID. Then, it creates a temporary queue in the AMQP-server, signing it with the key to the exchange (by routing key based on the UID). Then he puts the contents of the request in a general \u201cingoing\u201d queue, accompanying it with the same UID, and begins to listen to his temporary queue.<\/p>\n<p>The message is pulled from \u201cingoing\u201d queue by first free backend server (worker). The request is processed, passed through the jungle of business logic, and in the end the result will be published out (as a new AMQP message) with the routing key based on original UID.<\/p>\n<p>Our input script instance (remember &#8211; it \u201chalts\u201d on his personal temporary queue) catches this message with the result and publish it as a typical HTTP response &#8211; as response to the original request. Then, the script simply finishes his execution, and temporary queue will be destroyed automatically.<\/p>\n<p>That&#8217;s all. No need to go to the back-end server, no need to orchestrate their addresses (at this point), no need to asking their status, no need to be aware of their fall \/ restoration and etc. The lack of this scheme, of course, is the overhead to work with queues.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and &hellip; <a href=\"https:\/\/www.dobryakov.net\/blog\/16\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Queues: web cluster without upstreams orchesration&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4,7,16],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-amqp","tag-cluster","tag-queues"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"dobryakov\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.dobryakov.net\/blog\/16\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Grigoriy Dobryakov - IT+AI Blog - Grigoriy Dobryakov&#039;s blog: management, development and testing\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.dobryakov.net\/blog\/16\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2016-01-29T15:25:36+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2016-01-29T15:25:36+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#blogposting\",\"name\":\"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog\",\"headline\":\"Queues: web cluster without upstreams orchesration\",\"author\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/author\\\/dobryakov\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/#organization\"},\"datePublished\":\"2016-01-29T19:25:36+00:00\",\"dateModified\":\"2016-01-29T19:25:36+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#webpage\"},\"articleSection\":\"Uncategorized, amqp, cluster, queues\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/category\\\/uncategorized\\\/#listItem\",\"position\":2,\"name\":\"Uncategorized\",\"item\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/category\\\/uncategorized\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#listItem\",\"name\":\"Queues: web cluster without upstreams orchesration\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#listItem\",\"position\":3,\"name\":\"Queues: web cluster without upstreams orchesration\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/#organization\",\"name\":\"Grigoriy Dobryakov - IT+AI Blog\",\"description\":\"Grigoriy Dobryakov's blog: management, development and testing\",\"url\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/author\\\/dobryakov\\\/#author\",\"url\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/author\\\/dobryakov\\\/\",\"name\":\"dobryakov\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40e48c39391f07d18b3013504096fdb82384a9aecb150c9df6497886ed2803fb?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"dobryakov\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#webpage\",\"url\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/\",\"name\":\"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog\",\"description\":\"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\\u201cupstreams\\u201d), without any knowledge about their exact IP address, or their quantity, or \\u201chealth\\u201d state. In addition, each request must be processed by the least loaded server in the moment, and\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/16\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/author\\\/dobryakov\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/author\\\/dobryakov\\\/#author\"},\"datePublished\":\"2016-01-29T19:25:36+00:00\",\"dateModified\":\"2016-01-29T19:25:36+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/\",\"name\":\"Grigoriy Dobryakov - IT+AI Blog\",\"description\":\"Grigoriy Dobryakov's blog: management, development and testing\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dobryakov.net\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog","description":"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and","canonical_url":"https:\/\/www.dobryakov.net\/blog\/16\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/www.dobryakov.net\/blog\/16\/#blogposting","name":"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog","headline":"Queues: web cluster without upstreams orchesration","author":{"@id":"https:\/\/www.dobryakov.net\/blog\/author\/dobryakov\/#author"},"publisher":{"@id":"https:\/\/www.dobryakov.net\/blog\/#organization"},"datePublished":"2016-01-29T19:25:36+00:00","dateModified":"2016-01-29T19:25:36+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.dobryakov.net\/blog\/16\/#webpage"},"isPartOf":{"@id":"https:\/\/www.dobryakov.net\/blog\/16\/#webpage"},"articleSection":"Uncategorized, amqp, cluster, queues"},{"@type":"BreadcrumbList","@id":"https:\/\/www.dobryakov.net\/blog\/16\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.dobryakov.net\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.dobryakov.net\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.dobryakov.net\/blog\/category\/uncategorized\/#listItem","name":"Uncategorized"}},{"@type":"ListItem","@id":"https:\/\/www.dobryakov.net\/blog\/category\/uncategorized\/#listItem","position":2,"name":"Uncategorized","item":"https:\/\/www.dobryakov.net\/blog\/category\/uncategorized\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.dobryakov.net\/blog\/16\/#listItem","name":"Queues: web cluster without upstreams orchesration"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.dobryakov.net\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.dobryakov.net\/blog\/16\/#listItem","position":3,"name":"Queues: web cluster without upstreams orchesration","previousItem":{"@type":"ListItem","@id":"https:\/\/www.dobryakov.net\/blog\/category\/uncategorized\/#listItem","name":"Uncategorized"}}]},{"@type":"Organization","@id":"https:\/\/www.dobryakov.net\/blog\/#organization","name":"Grigoriy Dobryakov - IT+AI Blog","description":"Grigoriy Dobryakov's blog: management, development and testing","url":"https:\/\/www.dobryakov.net\/blog\/"},{"@type":"Person","@id":"https:\/\/www.dobryakov.net\/blog\/author\/dobryakov\/#author","url":"https:\/\/www.dobryakov.net\/blog\/author\/dobryakov\/","name":"dobryakov","image":{"@type":"ImageObject","@id":"https:\/\/www.dobryakov.net\/blog\/16\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/40e48c39391f07d18b3013504096fdb82384a9aecb150c9df6497886ed2803fb?s=96&d=mm&r=g","width":96,"height":96,"caption":"dobryakov"}},{"@type":"WebPage","@id":"https:\/\/www.dobryakov.net\/blog\/16\/#webpage","url":"https:\/\/www.dobryakov.net\/blog\/16\/","name":"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog","description":"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.dobryakov.net\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.dobryakov.net\/blog\/16\/#breadcrumblist"},"author":{"@id":"https:\/\/www.dobryakov.net\/blog\/author\/dobryakov\/#author"},"creator":{"@id":"https:\/\/www.dobryakov.net\/blog\/author\/dobryakov\/#author"},"datePublished":"2016-01-29T19:25:36+00:00","dateModified":"2016-01-29T19:25:36+00:00"},{"@type":"WebSite","@id":"https:\/\/www.dobryakov.net\/blog\/#website","url":"https:\/\/www.dobryakov.net\/blog\/","name":"Grigoriy Dobryakov - IT+AI Blog","description":"Grigoriy Dobryakov's blog: management, development and testing","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.dobryakov.net\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Grigoriy Dobryakov - IT+AI Blog - Grigoriy Dobryakov's blog: management, development and testing","og:type":"article","og:title":"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog","og:description":"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and","og:url":"https:\/\/www.dobryakov.net\/blog\/16\/","article:published_time":"2016-01-29T15:25:36+00:00","article:modified_time":"2016-01-29T15:25:36+00:00","twitter:card":"summary_large_image","twitter:title":"Queues: web cluster without upstreams orchesration - Grigoriy Dobryakov - IT+AI Blog","twitter:description":"The story began where I was once asked how to build such HTTP-gate (api endpoint), which proxies requests to a group of lower-level servers (\u201cupstreams\u201d), without any knowledge about their exact IP address, or their quantity, or \u201chealth\u201d state. In addition, each request must be processed by the least loaded server in the moment, and"},"aioseo_meta_data":{"post_id":"16","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-07-26 15:21:42","updated":"2026-07-26 15:21:42"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.dobryakov.net\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.dobryakov.net\/blog\/category\/uncategorized\/\" title=\"Uncategorized\">Uncategorized<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tQueues: web cluster without upstreams orchesration\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.dobryakov.net\/blog"},{"label":"Uncategorized","link":"https:\/\/www.dobryakov.net\/blog\/category\/uncategorized\/"},{"label":"Queues: web cluster without upstreams orchesration","link":"https:\/\/www.dobryakov.net\/blog\/16\/"}],"_links":{"self":[{"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":0,"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dobryakov.net\/blog\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}