{"id":84809,"date":"2021-08-27T16:50:35","date_gmt":"2021-08-27T11:20:35","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=84809"},"modified":"2021-08-27T16:50:35","modified_gmt":"2021-08-27T11:20:35","slug":"microservices-communication-the-main-types","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/","title":{"rendered":"Microservices Communication: The Main Types"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Application architecture has grown in complexity, with services communicating consistently between each other. Microservice communication is integral for applications, but each call adds a slight bit of latency.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Developers must learn about the main types of microservices communication, starting with communication types.<\/span><\/p>\n<h3>2 Basic Communication Types: Synchronous vs. Asynchronous<\/h3>\n<p><span style=\"font-weight: 400\">Microservices communications have two basic forms that every developer must know:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400\">Synchronous<\/span><\/li>\n<li><span style=\"font-weight: 400\">Asynchronous<\/span><\/li>\n<\/ol>\n<h4>1. Synchronous Communication<\/h4>\n<p><span style=\"font-weight: 400\">When considering synchronous communications, you can think of HTTP. The protocol powers the Internet, and it is invoked when a client sends in a request. For example, a request is sent to the HTTP protocol, and the client waits for a response from the HTTP server.<\/span><\/p>\n<h4>2. Asynchronous Communication<\/h4>\n<p><span style=\"font-weight: 400\">Asynchronous communication is when the client doesn\u2019t wait for a response back to continue through its processes. AMQP is a prime example of asynchronous communication because a message is sent and added to a queue. Multiple messages may be added before a response is obtained.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Learning these basic communication types is essential before diving deeper into the additional axis available. Besides, the optimization of<\/span><a href=\"https:\/\/redwerk.com\/blog\/azure-service-bus-in-net-core\/\"> <span style=\"font-weight: 400\">.net core communication between microservices<\/span><\/a><span style=\"font-weight: 400\"> helps keep the applications running efficiently.<\/span><\/p>\n<p><span style=\"font-weight: 400\">If you\u2019re sending messages, there also must be a receiver. Two main types of receivers also exist:<\/span><\/p>\n<ol>\n<li><b>Single<\/b><span style=\"font-weight: 400\">: With a single axis, the receiver must process each request independently.<\/span><\/li>\n<li><b>Many<\/b><span style=\"font-weight: 400\">: Multiple receivers, or none, can process each request. A common choice is an event-bus interface where there may be updates sent back by the receiver.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">When you create a microservice application, you\u2019ll likely use a mixture of synchronous and asynchronous communication as well as single and multiple receivers. The communication style that you use is based on the application being created.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Developers often choose the best communication style for the job.<\/span><\/p>\n<h3>Microservice Communication Styles<\/h3>\n<p><span style=\"font-weight: 400\">Developers have to use the right technology to meet their product or service goals. You may need to use one style for one feature and another style for another feature. Since there are multiple protocols and options to choose from, it has led to styles being developed.<\/span><\/p>\n<p><span style=\"font-weight: 400\">A few examples of this may include:<\/span><\/p>\n<p><b>HTTP and REST Protocols<\/b><\/p>\n<p><span style=\"font-weight: 400\">Two of the most common protocols that power many online apps are HTTP and REST. Both of these protocols use asynchronous communications because a request is sent to the server and awaits a response before doing anything else.<\/span><\/p>\n<p><span style=\"font-weight: 400\">When a response is given, the client application will then take an \u201cif-this\u201d approach.<\/span><\/p>\n<p><span style=\"font-weight: 400\">For example, if the response is an error code, the application will show an error or try the request again for an adequate response, depending on the internal logic.<\/span><\/p>\n<p><b>AMQP a WCG\/TCP<\/b><\/p>\n<p><span style=\"font-weight: 400\">Internal communications may be made by TCP or WCG, which are common when using a Docker host. Microservice clusters will often use internal communications between microservices using what is considered a \u201cnon-standard\u201d binary approach.<\/span><\/p>\n<p><b>Which Communication Method is Best?<\/b><\/p>\n<p><span style=\"font-weight: 400\">Unfortunately, there\u2019s no wrong or correct answer. Some forms of communication are situational, and the answer is genuinely dependent on the rest of the application. Standard and non-standard binary approaches are often combined into one microservice application.<\/span><\/p>\n<p><span style=\"font-weight: 400\">When using the messaging inside an app, it\u2019s common to use asynchronous communication to maintain communication among the different services available.<\/span><\/p>\n<h3>Why Microservice Architecture is Chosen<\/h3>\n<p><span style=\"font-weight: 400\">Microservice-based applications are rising in popularity as developers try to meet the demands of today\u2019s intense development market. Many applications are hitting the market, and when the app\u2019s features are coupled together too tightly, it leaves little room for error.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Instead, microservices add multiple services together to meet the goal of the app.<\/span><\/p>\n<p><span style=\"font-weight: 400\">When breaking one larger app into microservices, you\u2019re doing this with the idea that each service is:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400\">Easily tested and maintained independently to find issues more quickly and deploy patches that impact one service rather than multiple services.<\/span><\/li>\n<li><span style=\"font-weight: 400\">Loosely coupled so that services can easily be added or removed as necessary. You can, in many cases, swap services and reuse them in other applications that are under development rather than \u201crecreating the wheel.\u201d<\/span><\/li>\n<li><span style=\"font-weight: 400\">Independent services can be deployed without dependencies, making it easier to single out a service for further development.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">From a developer standpoint, the microservice architecture that is becoming more popular makes it easy to build and maintain applications. Since multiple services are used, the problems that the software solves can be neatly organized into services.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Teams can focus on each of their respective microservices, allowing for less confusion when coding and back-and-forth with other development teams.<\/span><\/p>\n<p><span style=\"font-weight: 400\">A microservice architecture promotes working in independent teams, which further allows teams to be spread across the world. The idea of a microservice architecture is a solid one because it allows for development freedom without the complexities of other architectures.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The one main concern is communication among all of the services to keep the services working neatly together.<\/span><\/p>\n<p><span style=\"font-weight: 400\">While we\u2019ve mentioned multiple types of communication, they all have their pros and cons or best use cases. For example:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400\">HTTP communication is an ideal option for service-to-service communication.<\/span><\/li>\n<li><span style=\"font-weight: 400\">Message communication, which listens for messages and doesn\u2019t include direct communication between services.<\/span><\/li>\n<li><span style=\"font-weight: 400\">Event-driven communication is asynchronous, and a series of events may be triggered along the way to make sure that the communication remains consistent.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">With all applications, communication also means monitoring for slow or failed network requests. Communication issues can derail a microservice, so it\u2019s essential to consider all microservice communications when building out the service.<\/span><\/p>\n<h3>Summary<\/h3>\n<p><span style=\"font-weight: 400\">Asynchronous and synchronous communication patterns are easy to learn and hard to master. Each communication type has its pros and cons, but they\u2019re vital when working with microservice communication.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Coupling considerations always need to be considered when joining microservices together, and communication will always be complex.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Once you have the communication methods and services in place, it will be much easier to maintain and expand the application using a microservice approach. You may even want to implement a logging system to properly trace all communication to ensure proper responses are given.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Application architecture has grown in complexity, with services communicating consistently between each other. Microservice communication is integral for applications, but each call adds a slight bit of latency. Developers must learn about the main&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":84828,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1744],"tags":[4125],"class_list":["post-84809","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-microservices-communication"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Microservices Communication: The Main Types - TechVidvan<\/title>\n<meta name=\"description\" content=\"Microservices help establish communication between internal processes. Learn multiple types of microservice communication &amp; why they\u2019re used.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Microservices Communication: The Main Types - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Microservices help establish communication between internal processes. Learn multiple types of microservice communication &amp; why they\u2019re used.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-27T11:20:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Types-of-Microservices-Communication.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Microservices Communication: The Main Types - TechVidvan","description":"Microservices help establish communication between internal processes. Learn multiple types of microservice communication & why they\u2019re used.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/","og_locale":"en_US","og_type":"article","og_title":"Microservices Communication: The Main Types - TechVidvan","og_description":"Microservices help establish communication between internal processes. Learn multiple types of microservice communication & why they\u2019re used.","og_url":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-08-27T11:20:35+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Types-of-Microservices-Communication.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Microservices Communication: The Main Types","datePublished":"2021-08-27T11:20:35+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/"},"wordCount":1001,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Types-of-Microservices-Communication.jpg","keywords":["Microservices Communication"],"articleSection":["Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/","url":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/","name":"Microservices Communication: The Main Types - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Types-of-Microservices-Communication.jpg","datePublished":"2021-08-27T11:20:35+00:00","description":"Microservices help establish communication between internal processes. Learn multiple types of microservice communication & why they\u2019re used.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Types-of-Microservices-Communication.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Types-of-Microservices-Communication.jpg","width":1200,"height":628,"caption":"Types of Microservices Communication"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/microservices-communication-the-main-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Microservices Communication: The Main Types"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=84809"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84809\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/84828"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=84809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=84809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=84809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}