<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bulat Gabdrakhmanov</title>
    <description>The latest articles on DEV Community by Bulat Gabdrakhmanov (@bulatgab).</description>
    <link>https://dev.to/bulatgab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F234830%2F4de561cd-066d-4bd7-9423-11961974bdb7.jpeg</url>
      <title>DEV Community: Bulat Gabdrakhmanov</title>
      <link>https://dev.to/bulatgab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bulatgab"/>
    <language>en</language>
    <item>
      <title>Microservices 101: Communication between services</title>
      <dc:creator>Bulat Gabdrakhmanov</dc:creator>
      <pubDate>Thu, 30 Jan 2025 07:47:14 +0000</pubDate>
      <link>https://dev.to/bulatgab/microservices-101-communication-between-services-4ea</link>
      <guid>https://dev.to/bulatgab/microservices-101-communication-between-services-4ea</guid>
      <description>&lt;p&gt;Microservice architecture consists of multiple independent services that often need to communicate with each other. &lt;/p&gt;

&lt;p&gt;This communication can be achieved in two primary ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Synchronous&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Asyncronous&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Synchronous communication
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmo29her749ekznxfxxo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmo29her749ekznxfxxo.png" alt="Image description" width="800" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Synchronous communication follows a client-server model, where one service sends a request to another and waits for a response before proceeding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common protocols
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;REST APIs – resource-based communication using HTTP methods (GET, POST, PUT, DELETE)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;RPC - &lt;strong&gt;R&lt;/strong&gt;emote &lt;strong&gt;P&lt;/strong&gt;rocedure &lt;strong&gt;C&lt;/strong&gt;all. Allows invoking methods on remote services as if they were local. Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SOAP - XML-based&lt;/li&gt;
&lt;li&gt;gRPC - uses binary format for payloads, high performance,&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pros &amp;amp; Cons
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple to use and implement&lt;/li&gt;
&lt;li&gt;Immediate data retrieval&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tightly coupled&lt;/strong&gt; - if one service depends on another that is down, the entire operation fails&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability issues&lt;/strong&gt; - high traffic can overload serivces&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency&lt;/strong&gt; - slow response times can create bottlenecks&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use cases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;External API calls&lt;/li&gt;
&lt;li&gt;Need immediate response (e.g. authentication)&lt;/li&gt;
&lt;li&gt;Data consistency is critical (e.g. order processing)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Asynchronous communication
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71j5u0dbogil2b8a0ml4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F71j5u0dbogil2b8a0ml4.png" alt="Image description" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Asynchronous communication uses message brokers as an intermediate service for communication between services. Instead of waiting for an immediate response, a service sends a message to a broker, which another service later processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros &amp;amp; Cons
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Loosely coupled&lt;/strong&gt; - services operate independently, improving scalability&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High availability and resilience&lt;/strong&gt; - a service can continue operating even if other services are temporarily down&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Increased complexity and maintenance&lt;/strong&gt; - requires additional infrastructure and message handling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Messages ordering &amp;amp; duplication&lt;/strong&gt; - messages may arrive out of order or be duplicated, requiring deduplication strategies&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use cases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Event-driven architecture&lt;/li&gt;
&lt;li&gt;Background processing - immediate response is not required&lt;/li&gt;
&lt;li&gt;High-load systems - where scalability is a priority&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>microservices</category>
      <category>microservices101</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
