<?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: kevinrawal</title>
    <description>The latest articles on DEV Community by kevinrawal (@kevinrawal).</description>
    <link>https://dev.to/kevinrawal</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1199786%2Fa2c6d7d5-7c0e-4fd2-91e2-581748c327ad.jpg</url>
      <title>DEV Community: kevinrawal</title>
      <link>https://dev.to/kevinrawal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kevinrawal"/>
    <language>en</language>
    <item>
      <title>Retry Pattern: Handling Temporary Failures in Distributed Systems</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Mon, 23 Nov 2026 12:00:00 +0000</pubDate>
      <link>https://dev.to/kevinrawal/retry-pattern-handling-temporary-failures-in-distributed-systems-579c</link>
      <guid>https://dev.to/kevinrawal/retry-pattern-handling-temporary-failures-in-distributed-systems-579c</guid>
      <description>&lt;p&gt;Imagine placing an order in an e-commerce application.&lt;/p&gt;

&lt;p&gt;The Order Service calls the Payment Service to process your payment. But due to a temporary network issue, the request fails.&lt;/p&gt;

&lt;p&gt;Should the order fail immediately?&lt;/p&gt;

&lt;p&gt;Not necessarily.&lt;/p&gt;

&lt;p&gt;The Payment Service might be healthy, and the failure could be temporary. Giving the request another chance might be enough.&lt;/p&gt;

&lt;p&gt;This is where the &lt;strong&gt;Retry Pattern&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;In a distributed system, services communicate over networks. And networks are not always reliable.&lt;/p&gt;

&lt;p&gt;A request can fail because of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temporary network interruptions.&lt;/li&gt;
&lt;li&gt;Connection timeouts.&lt;/li&gt;
&lt;li&gt;A service being temporarily unavailable.&lt;/li&gt;
&lt;li&gt;Rate limiting.&lt;/li&gt;
&lt;li&gt;Short-lived resource contention.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some failures are temporary and may succeed if we try again.&lt;/p&gt;

&lt;p&gt;But blindly retrying every failure can make things worse.&lt;/p&gt;

&lt;p&gt;Let's understand how to retry correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution: Retry the Request
&lt;/h2&gt;

&lt;p&gt;The basic idea is simple: when an operation fails due to a transient error, attempt it again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       Order Service
             |
             v
       Payment Service
             |
             X  Temporary failure
             |
             v
           Retry
             |
             v
       Payment Service
             |
             ✓  Success
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of immediately returning an error, the Order Service gives the operation another chance.&lt;/p&gt;

&lt;p&gt;But there is an important question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How many times should we retry, and how long should we wait?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Set a Retry Limit
&lt;/h2&gt;

&lt;p&gt;Never retry indefinitely.&lt;/p&gt;

&lt;p&gt;For example, allow up to 3 attempts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attempt 1  ---&amp;gt; Failure
Attempt 2  ---&amp;gt; Failure
Attempt 3  ---&amp;gt; Failure
                  |
                  v
             Return Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A retry limit prevents one failing operation from consuming resources forever.&lt;/p&gt;

&lt;p&gt;The limit should depend on the operation, its latency requirements, and the system's overall timeout budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Use Exponential Backoff
&lt;/h2&gt;

&lt;p&gt;What if we retry immediately after every failure?&lt;/p&gt;

&lt;p&gt;When a service is overloaded, thousands of clients might retry at the same time, creating even more load.&lt;/p&gt;

&lt;p&gt;This is known as a &lt;strong&gt;Retry Storm&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead, gradually increase the delay between retries.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Retry&lt;/th&gt;
&lt;th&gt;Example delay&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1st&lt;/td&gt;
&lt;td&gt;1 second&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2nd&lt;/td&gt;
&lt;td&gt;2 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3rd&lt;/td&gt;
&lt;td&gt;4 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4th&lt;/td&gt;
&lt;td&gt;8 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The general formula is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;delay = base_delay * 2^retry_count
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called Exponential Backoff.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add Jitter
&lt;/h3&gt;

&lt;p&gt;Imagine thousands of clients all retrying after exactly 4 seconds.&lt;/p&gt;

&lt;p&gt;They could overwhelm the service again.&lt;/p&gt;

&lt;p&gt;To avoid synchronized retries, add a random delay called &lt;strong&gt;Jitter&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Retry Delay = Random(0, Exponential Backoff Delay)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This spreads retry attempts over time.&lt;/p&gt;

&lt;p&gt;In practice, use a maximum delay and a total retry/time budget as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Retry Only When It Makes Sense
&lt;/h2&gt;

&lt;p&gt;Not every failure is retriable.&lt;/p&gt;

&lt;p&gt;Consider these examples:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure&lt;/th&gt;
&lt;th&gt;Retry?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Temporary network error&lt;/td&gt;
&lt;td&gt;Usually&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Request timeout&lt;/td&gt;
&lt;td&gt;Sometimes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP 429 — Rate Limited&lt;/td&gt;
&lt;td&gt;Usually, respect Retry-After&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP 503 — Service Unavailable&lt;/td&gt;
&lt;td&gt;Often&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP 400 — Bad Request&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invalid payment details&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The exact decision depends on the API and the error semantics.&lt;/p&gt;

&lt;p&gt;Retrying an invalid request will not make it valid.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. The Hidden Danger: Duplicate Operations
&lt;/h2&gt;

&lt;p&gt;This is especially important for payment systems.&lt;/p&gt;

&lt;p&gt;Suppose the Order Service sends a payment request.&lt;/p&gt;

&lt;p&gt;The Payment Service processes the payment successfully, but the response gets lost due to a network issue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service              Payment Service
     |                           |
     |------ Charge $100 -------&amp;gt;|
     |                           |
     |                     Payment Success
     |                           |
     |&amp;lt;---- Response Lost -------X
     |
     |------ Retry $100 --------&amp;gt;|
     |                           |
     |                     Payment Again?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Order Service doesn't know whether the first request succeeded.&lt;/p&gt;

&lt;p&gt;If it retries without protection, the customer could be charged twice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution: Idempotency
&lt;/h3&gt;

&lt;p&gt;Use an idempotency key for operations that create side effects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"order_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ORD-123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"idempotency_key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"payment-ORD-123"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Payment Service stores the result associated with this key.&lt;/p&gt;

&lt;p&gt;If the same request arrives again, it returns the previous result instead of charging the customer again.&lt;/p&gt;

&lt;p&gt;This makes retries safer.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Retry Is Not a Complete Reliability Strategy
&lt;/h2&gt;

&lt;p&gt;Retry helps recover from temporary failures, but it has limitations.&lt;/p&gt;

&lt;p&gt;What if the Payment Service is completely down?&lt;/p&gt;

&lt;p&gt;Retrying 3 times might still fail. And if every request keeps retrying, the Order Service continues spending resources on an unhealthy dependency.&lt;/p&gt;

&lt;p&gt;This is where another pattern becomes useful: &lt;strong&gt;Circuit Breaker&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Retry Pattern gives a failed request another chance.&lt;/p&gt;

&lt;p&gt;The Circuit Breaker Pattern decides when to stop making calls to a failing service.&lt;/p&gt;

&lt;p&gt;You can explore it in the next article&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Retry helps recover from transient failures by attempting an operation again. Use retry limits, exponential backoff, jitter, and idempotency to avoid turning temporary failures into bigger problems.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Retry is useful when a failure might be temporary. It should never be an excuse to retry blindly.&lt;/p&gt;

</description>
      <category>distributedsystems</category>
      <category>designpatterns</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>Checkout my new article!!</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Thu, 12 Nov 2026 04:42:48 +0000</pubDate>
      <link>https://dev.to/kevinrawal/checkout-my-new-article-5b97</link>
      <guid>https://dev.to/kevinrawal/checkout-my-new-article-5b97</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/kevinrawal/p50-p95-p99-explained-a-simple-guide-to-latency-metrics-p90" class="crayons-story__hidden-navigation-link"&gt;p50, p95, p99 Explained: A Simple Guide to Latency Metrics&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/kevinrawal" class="crayons-avatar  crayons-avatar--l  "&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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1199786%2Fa2c6d7d5-7c0e-4fd2-91e2-581748c327ad.jpg" alt="kevinrawal profile" class="crayons-avatar__image" width="760" height="1645"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/kevinrawal" class="crayons-story__secondary fw-medium m:hidden"&gt;
              kevinrawal
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                kevinrawal
                
                
              
              &lt;div id="story-author-preview-content-5001582" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/kevinrawal" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1199786%2Fa2c6d7d5-7c0e-4fd2-91e2-581748c327ad.jpg" class="crayons-avatar__image" alt="" width="760" height="1645"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;kevinrawal&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/kevinrawal/p50-p95-p99-explained-a-simple-guide-to-latency-metrics-p90" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 12&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/kevinrawal/p50-p95-p99-explained-a-simple-guide-to-latency-metrics-p90" id="article-link-5001582"&gt;
          p50, p95, p99 Explained: A Simple Guide to Latency Metrics
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/performance"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;performance&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/backend"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;backend&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/infrastructure"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;infrastructure&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/kevinrawal/p50-p95-p99-explained-a-simple-guide-to-latency-metrics-p90" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt;&amp;nbsp;reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/kevinrawal/p50-p95-p99-explained-a-simple-guide-to-latency-metrics-p90#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            5 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;/div&gt;


</description>
      <category>backend</category>
      <category>performance</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>p50, p95, p99 Explained: A Simple Guide to Latency Metrics</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Thu, 12 Nov 2026 04:23:13 +0000</pubDate>
      <link>https://dev.to/kevinrawal/p50-p95-p99-explained-a-simple-guide-to-latency-metrics-p90</link>
      <guid>https://dev.to/kevinrawal/p50-p95-p99-explained-a-simple-guide-to-latency-metrics-p90</guid>
      <description>&lt;p&gt;Your dashboard says the average response time is &lt;strong&gt;200 ms&lt;/strong&gt;. Everything looks healthy. But users keep saying, "the app sometimes freezes."&lt;/p&gt;

&lt;p&gt;Both things can be true at once. The dashboard isn't broken. The problem is that the &lt;strong&gt;average hides the users who are having a bad time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this article, we'll learn how to see those users using &lt;strong&gt;p50, p95 and p99&lt;/strong&gt;. We'll start from the basics and build up step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What is latency?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Latency&lt;/strong&gt; is the time a request takes to get a response. You tap a button, the app asks the server for data, and the server replies. The waiting time in between is latency, usually measured in milliseconds (ms).&lt;/p&gt;

&lt;p&gt;Lower latency means a faster app. But how do we measure it for thousands of users at once? The obvious answer is the average. Let's see why that goes wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why the average is misleading
&lt;/h2&gt;

&lt;p&gt;Say your app handled 100 requests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;90 requests took &lt;strong&gt;100 ms&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;8 requests took &lt;strong&gt;500 ms&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;2 requests took &lt;strong&gt;5,000 ms&lt;/strong&gt; (5 seconds)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The average comes out to &lt;strong&gt;230 ms&lt;/strong&gt;, which sounds fine. But look at what really happened: 10 users had a slow experience, and 2 of them stared at a loading spinner for 5 seconds.&lt;/p&gt;

&lt;p&gt;The fast majority pulled the average down and covered up the unlucky few. We need a way to look at the slow requests directly. That's where percentiles come in.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. What is a percentile?
&lt;/h2&gt;

&lt;p&gt;Imagine all 100 requests lined up from &lt;strong&gt;fastest to slowest&lt;/strong&gt;. A percentile simply tells you how fast the request at a certain position in that line was.&lt;/p&gt;

&lt;p&gt;For example, if p90 is 300 ms, it means 90% of requests finished in 300 ms or less.&lt;/p&gt;

&lt;p&gt;Now let's look at the ones you'll see most often.&lt;/p&gt;

&lt;h3&gt;
  
  
  p50: the typical experience
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;p50&lt;/strong&gt; is also called the &lt;strong&gt;median&lt;/strong&gt;. Half of the requests are faster than this, and half are slower.&lt;/p&gt;

&lt;p&gt;In our example, p50 is &lt;strong&gt;100 ms&lt;/strong&gt;. This is what a typical user experiences.&lt;/p&gt;

&lt;h3&gt;
  
  
  p95: the slower experience
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;p95&lt;/strong&gt; means 95% of requests are faster than this value. Only 5% are slower, which is &lt;strong&gt;1 in every 20 requests&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In our example, p95 is &lt;strong&gt;500 ms&lt;/strong&gt;. So 1 in 20 users waits this long or more.&lt;/p&gt;

&lt;h3&gt;
  
  
  p99: the worst-case experience
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;p99&lt;/strong&gt; means 99% of requests are faster than this value. Only 1% are slower, which is &lt;strong&gt;1 in every 100 requests&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In our example, p99 is &lt;strong&gt;5,000 ms&lt;/strong&gt;. The unluckiest 1% of users wait 5 seconds or more.&lt;/p&gt;

&lt;h3&gt;
  
  
  p99.9 and beyond
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;p99.9&lt;/strong&gt; means 99.9% of requests are faster, so only &lt;strong&gt;1 in 1,000&lt;/strong&gt; is slower. Large companies track this too. If you serve millions of requests a day, 1 in 1,000 still means thousands of unhappy users.&lt;/p&gt;

&lt;h3&gt;
  
  
  All together
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;What it tells us&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Average&lt;/td&gt;
&lt;td&gt;230 ms&lt;/td&gt;
&lt;td&gt;Looks fine, but hides the problem&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p50&lt;/td&gt;
&lt;td&gt;100 ms&lt;/td&gt;
&lt;td&gt;The typical user is happy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p95&lt;/td&gt;
&lt;td&gt;500 ms&lt;/td&gt;
&lt;td&gt;1 in 20 users waits 5x longer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p99&lt;/td&gt;
&lt;td&gt;5,000 ms&lt;/td&gt;
&lt;td&gt;1 in 100 users waits 50x longer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now we see the real picture. The slow end of this list has a name: &lt;strong&gt;tail latency&lt;/strong&gt;. When engineers say "we need to fix our tail," they mean the p99 and p99.9 requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. "But it's only 1% of users. Why care?"
&lt;/h2&gt;

&lt;p&gt;It's a fair question. There are two good answers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Answer 1: Your slowest users are often your best users
&lt;/h3&gt;

&lt;p&gt;In the book &lt;em&gt;Designing Data-Intensive Applications&lt;/em&gt;, Martin Kleppmann shares an example from Amazon. Amazon describes the performance requirements of its internal services using the &lt;strong&gt;99.9th percentile&lt;/strong&gt;, even though that affects only 1 in 1,000 requests.&lt;/p&gt;

&lt;p&gt;Why? Because the customers with the slowest requests are usually the ones with the &lt;strong&gt;most data&lt;/strong&gt; on their accounts: the longest order history and the most purchases. In other words, they are often Amazon's &lt;strong&gt;most valuable customers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Amazon has also observed that even a 100 ms slowdown can reduce sales by around 1%. For a company that size, tiny delays cost real money.&lt;/p&gt;

&lt;h3&gt;
  
  
  Answer 2: Small problems add up
&lt;/h3&gt;

&lt;p&gt;When you open one page of a modern app, it doesn't make just one request. Behind the scenes, it may call dozens of services for your profile, prices, recommendations, stock availability, and more.&lt;/p&gt;

&lt;p&gt;Suppose each service is slow only 1% of the time. That feels harmless. But if one page needs &lt;strong&gt;100 calls&lt;/strong&gt;, the chance that &lt;em&gt;at least one&lt;/em&gt; of them is slow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 - (0.99)^100 ≈ 63%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So a "rare" 1% problem becomes a problem for &lt;strong&gt;almost two out of three page loads&lt;/strong&gt;. This is called &lt;strong&gt;tail latency amplification&lt;/strong&gt;. The more services you have, the more your p99 starts to feel like your users' &lt;em&gt;normal&lt;/em&gt; experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Why do some requests become slow?
&lt;/h2&gt;

&lt;p&gt;If your code is the same for every request, why are a few so much slower? Usually the cause is something outside your business logic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Garbage collection pauses&lt;/strong&gt; that briefly freeze a program&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache misses&lt;/strong&gt;, where data has to be fetched from a slow database&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lock contention&lt;/strong&gt;, where many requests fight over the same resource&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network hiccups&lt;/strong&gt; like packet loss and retries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Queueing&lt;/strong&gt;, where a few slow requests make faster ones wait behind them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Busy neighbors&lt;/strong&gt;, where other apps on the same server use up the resources&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key point is that these problems are random and rare. That's exactly why they show up in p99 and not in the average.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. How companies use these metrics
&lt;/h2&gt;

&lt;p&gt;Teams turn percentiles into clear goals, called &lt;strong&gt;SLOs&lt;/strong&gt; (Service Level Objectives). For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"99% of checkout requests should finish in under 300 ms."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is much more useful than "average latency should be low," because it describes what real users feel, and everyone can measure it.&lt;/p&gt;

&lt;p&gt;A simple way to remember which metric answers which question:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;p50:&lt;/strong&gt; is the app healthy in general?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;p95:&lt;/strong&gt; is a noticeable group of users struggling?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;p99 / p99.9:&lt;/strong&gt; are there hidden problems like slow queries or overloaded servers?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Companies often go one step further and write these goals into contracts with customers. These are called &lt;strong&gt;SLAs&lt;/strong&gt;, and breaking them can mean refunds or penalties.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Common mistakes when measuring
&lt;/h2&gt;

&lt;p&gt;Once you start tracking percentiles, avoid these traps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Don't average percentiles.&lt;/strong&gt; The average of the p99 from 10 servers is &lt;em&gt;not&lt;/em&gt; your real p99. Use &lt;strong&gt;histograms&lt;/strong&gt; instead, which tools like Prometheus, Datadog and OpenTelemetry support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't chase perfection.&lt;/strong&gt; Improving p99.99 gets very expensive. Amazon reportedly decided it wasn't worth the cost. Pick the percentile that fits your business.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use enough data.&lt;/strong&gt; A p99 calculated from 50 requests isn't reliable. You need enough traffic for the number to be stable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Latency&lt;/strong&gt; is how long a request takes.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;average&lt;/strong&gt; hides slow requests, so we use &lt;strong&gt;percentiles&lt;/strong&gt; instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;p50&lt;/strong&gt; is the typical experience, &lt;strong&gt;p95&lt;/strong&gt; shows slower users, and &lt;strong&gt;p99 / p99.9&lt;/strong&gt; shows the worst cases.&lt;/li&gt;
&lt;li&gt;The slow end is called &lt;strong&gt;tail latency&lt;/strong&gt;, and it often affects your most valuable users.&lt;/li&gt;
&lt;li&gt;In systems with many services, rare slowness becomes common.&lt;/li&gt;
&lt;li&gt;Companies set &lt;strong&gt;SLOs&lt;/strong&gt; on percentiles, not averages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next time someone says "our average latency is fine," ask them:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"What's our p99?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>performance</category>
      <category>systemdesign</category>
      <category>backend</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>We’re nearing the end of 2026. What does everyone think about the future of AI engineering?</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Mon, 09 Nov 2026 04:54:30 +0000</pubDate>
      <link>https://dev.to/kevinrawal/were-nearing-the-end-of-2026-what-does-everyone-think-about-the-future-of-ai-engineering-3a2j</link>
      <guid>https://dev.to/kevinrawal/were-nearing-the-end-of-2026-what-does-everyone-think-about-the-future-of-ai-engineering-3a2j</guid>
      <description></description>
      <category>agents</category>
      <category>ai</category>
      <category>llm</category>
    </item>
    <item>
      <title>How Twitter Scales Its Home Timeline: Fan-Out on Read vs Fan-Out on Write</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Mon, 09 Nov 2026 03:09:39 +0000</pubDate>
      <link>https://dev.to/kevinrawal/how-twitter-scales-its-home-timeline-fan-out-on-read-vs-fan-out-on-write-kkg</link>
      <guid>https://dev.to/kevinrawal/how-twitter-scales-its-home-timeline-fan-out-on-read-vs-fan-out-on-write-kkg</guid>
      <description>&lt;p&gt;Imagine opening Twitter (now X). Your home timeline shows tweets from hundreds or thousands of accounts you follow, sorted by time.&lt;/p&gt;

&lt;p&gt;Seems simple, right?&lt;/p&gt;

&lt;p&gt;But think about the scale:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Millions of users accessing their timelines.&lt;/li&gt;
&lt;li&gt;Millions of tweets being published.&lt;/li&gt;
&lt;li&gt;Every user follows a different set of accounts.&lt;/li&gt;
&lt;li&gt;Some accounts have millions of followers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How do you generate everyone's timeline efficiently?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Martin Kleppmann discusses this interesting problem in Chapter 1 of &lt;em&gt;Designing Data-Intensive Applications (DDIA)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let's understand the approaches.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Suppose Alice follows 1,000 accounts.&lt;/p&gt;

&lt;p&gt;Whenever Alice opens her home timeline, the system needs to fetch recent tweets from those accounts, combine them, sort them, and display them.&lt;/p&gt;

&lt;p&gt;Now imagine millions of users doing this simultaneously.&lt;/p&gt;

&lt;p&gt;How should we design this?&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution A: Fan-Out on Read (Pull Model)
&lt;/h2&gt;

&lt;p&gt;Instead of preparing timelines in advance, generate them whenever a user requests them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User opens their home timeline.&lt;/li&gt;
&lt;li&gt;Fetch the list of accounts they follow.&lt;/li&gt;
&lt;li&gt;Fetch recent tweets from those accounts.&lt;/li&gt;
&lt;li&gt;Merge and sort the tweets by timestamp.&lt;/li&gt;
&lt;li&gt;Return the timeline.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       User opens timeline
                |
                v
       Fetch following list
                |
       +--------+--------+
       |        |        |
       v        v        v
    User A   User B   User C
       |        |        |
       v        v        v
    Tweets   Tweets   Tweets
       |        |        |
       +--------+--------+
                |
                v
          Merge &amp;amp; Sort
                |
                v
          Home Timeline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Publishing a tweet is relatively cheap.&lt;/li&gt;
&lt;li&gt;No need to update millions of timelines when someone publishes a tweet.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Every timeline request requires multiple reads.&lt;/li&gt;
&lt;li&gt;Merging and sorting tweets can be expensive.&lt;/li&gt;
&lt;li&gt;High read traffic can put significant pressure on the system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We optimize writes, but reads become expensive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution B: Fan-Out on Write (Push Model)
&lt;/h2&gt;

&lt;p&gt;What if we prepare timelines when tweets are published instead?&lt;/p&gt;

&lt;p&gt;Instead of generating the timeline on every request, maintain a precomputed timeline for each user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alice publishes a tweet.&lt;/li&gt;
&lt;li&gt;Find all her followers.&lt;/li&gt;
&lt;li&gt;Push the tweet ID into each follower's home timeline cache.&lt;/li&gt;
&lt;li&gt;When a follower opens Twitter, simply fetch their precomputed timeline.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          Alice publishes tweet
                    |
                    v
             Fan-Out Worker
                    |
          Find all followers
                    |
          +---------+---------+
          |         |         |
          v         v         v
       Bob's     Carol's    David's
      Timeline  Timeline   Timeline
          |         |         |
          +---------+---------+
                    |
                    v
             Precomputed Feed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Reading timelines becomes extremely fast.&lt;/li&gt;
&lt;li&gt;Most of the computation happens during publishing.&lt;/li&gt;
&lt;li&gt;Great for read-heavy applications.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Publishing becomes expensive for accounts with millions of followers.&lt;/li&gt;
&lt;li&gt;A single tweet can trigger millions of writes.&lt;/li&gt;
&lt;li&gt;High-follower accounts can create enormous write amplification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We optimize reads, but writes become expensive.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Real Challenge: What About Celebrities?
&lt;/h2&gt;

&lt;p&gt;Here's where things get interesting.&lt;/p&gt;

&lt;p&gt;Consider an account with 30 million followers.&lt;/p&gt;

&lt;p&gt;Every time this account publishes a tweet, Fan-Out on Write could trigger 30 million timeline updates.&lt;/p&gt;

&lt;p&gt;That's a lot of unnecessary work!&lt;/p&gt;

&lt;p&gt;So, which approach should we choose?&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution C: The Hybrid Approach
&lt;/h2&gt;

&lt;p&gt;Why not combine both approaches?&lt;/p&gt;

&lt;p&gt;That's the idea behind Twitter's hybrid solution.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Normal accounts:&lt;/strong&gt; Use Fan-Out on Write. Precompute followers' timelines when a tweet is published.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Celebrity accounts:&lt;/strong&gt; Use Fan-Out on Read. Don't push tweets into millions of followers' timelines. Fetch their tweets when followers request their timelines.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       Tweet Published
              |
       +------+------+
       |             |
       v             v
   Normal User    Celebrity
       |             |
       v             v
   Fan-Out       Store Tweet
   on Write          |
       |             |
       v             | (Fetch on read)
  Update follower    |
   timelines         |
       |             |
       +------+------+
              |
              v
       User opens timeline
              |
              v
       Merge &amp;amp; Sort
              |
              v
        Home Timeline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a user opens their timeline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetch their precomputed timeline.&lt;/li&gt;
&lt;li&gt;Fetch recent tweets from celebrity accounts they follow.&lt;/li&gt;
&lt;li&gt;Merge both sets of tweets.&lt;/li&gt;
&lt;li&gt;Sort them by timestamp.&lt;/li&gt;
&lt;li&gt;Return the final timeline.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This balances the cost of reading and writing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Should We Learn From This?
&lt;/h2&gt;

&lt;p&gt;There is no universally perfect approach. Every architectural decision comes with trade-offs.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Optimizes&lt;/th&gt;
&lt;th&gt;Main trade-off&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fan-Out on Read&lt;/td&gt;
&lt;td&gt;Writes&lt;/td&gt;
&lt;td&gt;Expensive reads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fan-Out on Write&lt;/td&gt;
&lt;td&gt;Reads&lt;/td&gt;
&lt;td&gt;Expensive writes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hybrid&lt;/td&gt;
&lt;td&gt;Both&lt;/td&gt;
&lt;td&gt;More architectural complexity&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The right choice depends on your workload, traffic patterns, and data distribution.&lt;/p&gt;

&lt;p&gt;If you want to understand the underlying &lt;a href="https://dev.to/kevinrawal/fan-out-pattern-hc4"&gt;Fan-Out Pattern&lt;/a&gt;, I've covered it in a separate article.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Fan-Out on Read generates timelines when users request them. Fan-Out on Write prepares timelines when tweets are published. A hybrid approach combines both to handle different user workloads efficiently.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt; Designing Data-Intensive Applications (DDIA) by Martin Kleppmann — Chapter 1, Twitter's Home Timeline.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>distributedsystems</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Fan-Out Pattern</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Sun, 01 Nov 2026 08:38:47 +0000</pubDate>
      <link>https://dev.to/kevinrawal/fan-out-pattern-hc4</link>
      <guid>https://dev.to/kevinrawal/fan-out-pattern-hc4</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;In a microservices architecture, one event often needs to trigger multiple independent operations.&lt;/p&gt;

&lt;p&gt;Take an e-commerce application. When an order is placed, we might need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Send an email confirmation.&lt;/li&gt;
&lt;li&gt;Send an SMS notification.&lt;/li&gt;
&lt;li&gt;Update analytics.&lt;/li&gt;
&lt;li&gt;Notify the shipping service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A naive implementation might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service
     |
     v
Email Service
     |
     v
SMS Service
     |
     v
Analytics Service
     |
     v
Shipping Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each service is called one after another.&lt;/p&gt;

&lt;p&gt;Now what if the Email Service is slow or unavailable? The entire flow might get delayed, even though the other services could work independently.&lt;/p&gt;

&lt;p&gt;How do we decouple these operations and process them independently?&lt;/p&gt;

&lt;h2&gt;
  
  
  Option A: Synchronous Calls
&lt;/h2&gt;

&lt;p&gt;The Order Service directly calls every downstream service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Order Service
              /   |   \
             v    v    v
           Email  SMS  Analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The Order Service needs to know about every downstream service.&lt;/li&gt;
&lt;li&gt;Slow services increase the overall response time.&lt;/li&gt;
&lt;li&gt;Failures can affect the main request.&lt;/li&gt;
&lt;li&gt;Adding new consumers requires changes to the producer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It works, but it creates tight coupling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option B: Fan-Out Pattern
&lt;/h2&gt;

&lt;p&gt;Instead of calling every service directly, publish a single event to a &lt;a href="https://www.geeksforgeeks.org/system-design/what-are-message-brokers-in-system-design/" rel="noopener noreferrer"&gt;message broker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The broker distributes the event to multiple independent consumers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Order Service
                       |
                       v
                 Message Broker
                       |
          +------------+------------+
          |            |            |
          v            v            v
      Email Service  SMS Service  Analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, when an order is placed, the Order Service publishes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"OrderCreated"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"order_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ORD-123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"user_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"USER-456"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each consumer receives the event and processes it independently.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email Service sends the confirmation.&lt;/li&gt;
&lt;li&gt;SMS Service sends an SMS.&lt;/li&gt;
&lt;li&gt;Analytics Service updates its metrics.&lt;/li&gt;
&lt;li&gt;Shipping Service starts the delivery workflow.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, the Order Service doesn't need to know who consumes the event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's Fan-Out: One event, multiple independent consumers.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does It Work?
&lt;/h2&gt;

&lt;p&gt;A typical implementation looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The producer publishes an event to a message broker.&lt;/li&gt;
&lt;li&gt;The broker distributes a copy of the event to each subscriber.&lt;/li&gt;
&lt;li&gt;Each consumer processes its message independently.&lt;/li&gt;
&lt;li&gt;Consumers acknowledge successful processing.&lt;/li&gt;
&lt;li&gt;Failed messages can be retried or moved to a Dead Letter Queue (DLQ).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Trade-offs
&lt;/h2&gt;

&lt;p&gt;Fan-Out improves decoupling and scalability, but it comes with some considerations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Eventual Consistency:&lt;/strong&gt; Consumers may process the event at different times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Duplicate Delivery:&lt;/strong&gt; Consumers should be idempotent to handle duplicate messages safely.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Failure Handling:&lt;/strong&gt; Retries and Dead Letter Queues are needed for failed messages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Message Durability:&lt;/strong&gt; The broker must persist messages to avoid losing events.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fan-Out distributes work; it does not guarantee that every consumer completes its operation successfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Is It Used?
&lt;/h2&gt;

&lt;p&gt;Some common use cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Notification systems (Email, SMS, Push).&lt;/li&gt;
&lt;li&gt;Order processing and fulfillment.&lt;/li&gt;
&lt;li&gt;Analytics and event tracking.&lt;/li&gt;
&lt;li&gt;Audit logging.&lt;/li&gt;
&lt;li&gt;Real-time data processing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common implementations include Kafka (multiple consumer groups), RabbitMQ (Fanout Exchange), and cloud messaging services.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Need to notify multiple services about one event without tightly coupling them? Use Fan-Out to distribute the event and let each consumer process it independently.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  NOTE: What if a step in a business transaction fails?
&lt;/h2&gt;

&lt;p&gt;Fan-Out handles event distribution, but it doesn't manage transaction consistency. When multiple services participate in a single business transaction, the &lt;a href="https://dev.to/kevinrawal/saga-pattern-2heo"&gt;Saga Pattern&lt;/a&gt; can help coordinate the workflow and execute compensating transactions when a step fails.&lt;/p&gt;

</description>
      <category>distributedsystems</category>
      <category>designpatterns</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>Saga Pattern</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Tue, 20 Oct 2026 06:09:54 +0000</pubDate>
      <link>https://dev.to/kevinrawal/saga-pattern-2heo</link>
      <guid>https://dev.to/kevinrawal/saga-pattern-2heo</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;In a microservices app, one user action often touches several services.&lt;br&gt;
Take an e-commerce order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order Service → Payment Service → Inventory Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each service has its &lt;strong&gt;own database&lt;/strong&gt;. Now what if the payment succeeds but the item is out of stock? We can't just call &lt;code&gt;ROLLBACK&lt;/code&gt;, because no single transaction spans three databases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we undo things properly when one step fails?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Option A: One Big ACID Transaction
&lt;/h2&gt;

&lt;p&gt;A relational database gives us ACID guarantees, and a single transaction can roll everything back. But this only works &lt;strong&gt;inside one database&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microservices own separate databases, so one transaction can't cover them all.&lt;/li&gt;
&lt;li&gt;Sharing one database between services couples them tightly.&lt;/li&gt;
&lt;li&gt;Rows stay locked for the whole flow, which hurts speed and scalability.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Option B: Two-Phase Commit (2PC)
&lt;/h2&gt;

&lt;p&gt;A coordinator asks every service "can you commit?" (prepare phase), and only if all say yes does it say "commit" (commit phase).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Resources stay locked while everyone waits, so it is slow.&lt;/li&gt;
&lt;li&gt;If the coordinator crashes mid-way, services are stuck.&lt;/li&gt;
&lt;li&gt;Many modern databases and message brokers don't support it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It works, but it doesn't scale well for microservices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option C: Saga Pattern ✅
&lt;/h2&gt;

&lt;p&gt;A saga splits the big transaction into a &lt;strong&gt;sequence of small local transactions&lt;/strong&gt;, one per service. Each step has a matching &lt;strong&gt;compensating transaction&lt;/strong&gt; that undoes it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy path&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create Order → Deduct Payment → Reserve Stock → ✅ Done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Failure path&lt;/strong&gt; (out of stock)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create Order → Deduct Payment → Reserve Stock ❌
                                      │
         Cancel Order ← Refund Payment ◄┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Payment was deducted but the item is out of stock? The saga triggers a &lt;strong&gt;refund&lt;/strong&gt; and the order is &lt;strong&gt;cancelled&lt;/strong&gt;. The customer gets the money back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Ways to Run a Saga
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Style&lt;/th&gt;
&lt;th&gt;How it works&lt;/th&gt;
&lt;th&gt;Good for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Choreography&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Services publish events and react to each other's events. No central boss.&lt;/td&gt;
&lt;td&gt;Simple flows with few services&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Orchestration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A central orchestrator tells each service what to do next, and what to undo on failure.&lt;/td&gt;
&lt;td&gt;Complex flows, easier to track&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Trade-offs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The system is &lt;strong&gt;eventually consistent&lt;/strong&gt;, so for a moment the money may be deducted before the refund lands.&lt;/li&gt;
&lt;li&gt;Compensating actions must be &lt;strong&gt;idempotent&lt;/strong&gt;, meaning safe to run more than once.&lt;/li&gt;
&lt;li&gt;More code, because you write a "undo" for every step.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Can't roll back across services? Do each step locally, and if something fails, run the &lt;strong&gt;undo&lt;/strong&gt; steps for the ones already done.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>distributedsystems</category>
      <category>designpatterns</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>I built NexRAG: a framework-agnostic RAG pipeline SDK.</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Sun, 05 Jul 2026 06:44:49 +0000</pubDate>
      <link>https://dev.to/kevinrawal/i-built-nexrag-a-framework-agnostic-rag-pipeline-sdk-4b2j</link>
      <guid>https://dev.to/kevinrawal/i-built-nexrag-a-framework-agnostic-rag-pipeline-sdk-4b2j</guid>
      <description>&lt;p&gt;Over the past few months, while building RAG applications, I kept noticing the same pattern.&lt;/p&gt;

&lt;p&gt;Every new project meant rebuilding the same pipeline from scratch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;choosing an embedding model&lt;/li&gt;
&lt;li&gt;selecting a vector database&lt;/li&gt;
&lt;li&gt;experimenting with chunking strategies&lt;/li&gt;
&lt;li&gt;switching between LLMs&lt;/li&gt;
&lt;li&gt;adding rerankers&lt;/li&gt;
&lt;li&gt;integrating observability&lt;/li&gt;
&lt;li&gt;evaluating responses&lt;/li&gt;
&lt;li&gt;wiring it all together in code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The business logic changes across projects, but the underlying RAG architecture is largely the same. Yet every team ends up re-solving it, and optimization always gets pushed to "later."&lt;/p&gt;

&lt;p&gt;So I built NexRAG — an open-source framework that lets you build production-ready RAG pipelines using simple YAML configuration instead of rewriting orchestration code every time. What used to take 3,000+ lines of custom code now takes roughly 300 lines to get a production-grade pipeline wired up.&lt;/p&gt;

&lt;p&gt;With a few config changes, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Swap LLM providers&lt;/li&gt;
&lt;li&gt;Change embedding models&lt;/li&gt;
&lt;li&gt;Try different chunking and retrieval strategies&lt;/li&gt;
&lt;li&gt;Switch vector databases&lt;/li&gt;
&lt;li&gt;Configure rerankers&lt;/li&gt;
&lt;li&gt;Enable LLM-as-a-Judge evaluations&lt;/li&gt;
&lt;li&gt;Add observability and evaluation metrics&lt;/li&gt;
&lt;li&gt;Build custom components and plug them into the pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea is simple: configuration over boilerplate.&lt;/p&gt;

&lt;p&gt;Need something custom? Every component is extensible. Build your own retriever, embedder, chunker, vector store, or evaluator, and plug it in — no changes to the core framework required.&lt;/p&gt;

&lt;p&gt;From day one, NexRAG is designed with production in mind — not just retrieval, but observability, evaluation, and security, which most AI projects only think about after something breaks.&lt;/p&gt;

&lt;p&gt;🔗 NexRAG: &lt;a href="https://lnkd.in/d4QRBZmb" rel="noopener noreferrer"&gt;https://lnkd.in/d4QRBZmb&lt;/a&gt;&lt;br&gt;
🔗 Example project (Simple Policy Bot): &lt;a href="https://lnkd.in/drgMSq4C" rel="noopener noreferrer"&gt;https://lnkd.in/drgMSq4C&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is just the beginning. NexRAG is fully open source, and I'd love to collaborate with developers working in AI infrastructure, RAG, LLMOps, and production AI systems. Feedback, issues, feature requests, and contributions are all welcome.&lt;/p&gt;

&lt;p&gt;Looking forward to building this together.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>rag</category>
      <category>learning</category>
    </item>
    <item>
      <title>Master Git with Interactive Learning Platforms! 🚀</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Sat, 06 Jan 2024 04:29:58 +0000</pubDate>
      <link>https://dev.to/kevinrawal/master-git-with-interactive-learning-platforms-4ohk</link>
      <guid>https://dev.to/kevinrawal/master-git-with-interactive-learning-platforms-4ohk</guid>
      <description>&lt;p&gt;Hey folks,&lt;/p&gt;

&lt;p&gt;Are you looking to level up your Git version control skills? We've got you covered! Here are two awesome online platforms that offer interactive and engaging ways to enhance your Git proficiency:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LearnGitBranching:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://learngitbranching.js.org/" rel="noopener noreferrer"&gt;LearnGitBranching&lt;/a&gt; is an interactive and visually appealing tool that allows you to practice Git branching, merging, rebasing, and more. Whether you're a beginner or looking to refine your skills, this platform provides an intuitive way to understand and experiment with Git commands. It's a great resource to solidify your understanding of Git workflows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git Exercises:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://gitexercises.fracz.com/" rel="noopener noreferrer"&gt;Git Exercises&lt;/a&gt; is another excellent platform to enhance your Git proficiency. With various exercises and challenges, it covers a wide range of Git concepts and scenarios. The hands-on nature of these exercises makes it a valuable resource for individual learners and teams aiming to improve their version control practices.&lt;/p&gt;

&lt;p&gt;By actively engaging with these platforms, you can gain practical experience and boost your confidence in using Git effectively. Whether you're a developer, student, or simply curious about version control, these resources cater to various skill levels.&lt;/p&gt;

&lt;p&gt;do share other helpful resources in the comments.&lt;br&gt;
Happy coding! 🚀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>TLE Tales: When Unordered_map Bites You</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Fri, 29 Dec 2023 14:58:05 +0000</pubDate>
      <link>https://dev.to/kevinrawal/tle-tales-when-unorderedmap-bites-you-5h7c</link>
      <guid>https://dev.to/kevinrawal/tle-tales-when-unorderedmap-bites-you-5h7c</guid>
      <description>&lt;p&gt;Hey, fellow devs👋!&lt;/p&gt;

&lt;p&gt;I just tackled a &lt;a href="https://codeforces.com/contest/1915/problem/E" rel="noopener noreferrer"&gt;problem&lt;/a&gt; that taught me a valuable lesson about time complexity: always consider the worst-case scenario, even when average-case performance seems good ⚠️.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Here's the gist:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Problem: Find a subarray with a sum of zero.&lt;/li&gt;
&lt;li&gt;Constraints

&lt;ul&gt;
&lt;li&gt;Array size: 1 to 2*10^5&lt;/li&gt;
&lt;li&gt;Element range: 1 to 10^9&lt;/li&gt;
&lt;li&gt;Total sum of elements: ≤ 2*10^5&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;My initial approach:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used unordered_map to store sums for efficient lookup.&lt;/li&gt;
&lt;li&gt;Average-case time complexity: O(1) ✨&lt;/li&gt;
&lt;li&gt;Worst-case time complexity of entire code: O(n) (this led to the TLE)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The TLE surprise:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Got a Time Limit Exceeded (TLE) verdict, specifically during lookup operations in the unordered_map.&lt;/li&gt;
&lt;li&gt;Why? The worst-case lookup time in unordered_map can be linear O(n), so with the given constraint worst-case complexity of the program becomes O(n^2).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The solution:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Switched to map (ordered_map with worst-case complexity O(log n)):

&lt;ul&gt;
&lt;li&gt;Now Worst-case time complexity of my code become: O(nlogn), O(n) to traverse the array and O(long) for lookup.&lt;/li&gt;
&lt;li&gt;Accepted solution!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Key takeaways:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;just look at the complexity of ordered and unordered_map &lt;/p&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%2Fxlrswj4j1wrpvhz6axdy.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%2Fxlrswj4j1wrpvhz6axdy.png" alt=" " width="799" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This complexity tells you a lot about when to use which data structure, map stores the data in a sorted manner while unordered will not, here we do not need sorted data which's why in the first attempt I went with unordered_map but later I realized my mistake and correct it.&lt;/p&gt;

&lt;p&gt;instead of 10^5 if the number of elements is 10^9 then our ordered_map will not work so, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always analyze worst-case time complexity, especially when dealing with large inputs.&lt;/li&gt;
&lt;li&gt;Don't rely solely on average-case performance.&lt;/li&gt;
&lt;li&gt;Choose data structures wisely based on problem constraints and potential worst-case scenarios.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy coding!!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>competativeprogramming</category>
      <category>datastructures</category>
      <category>learning</category>
    </item>
    <item>
      <title>Quick Sort vs. Merge Sort: A Developer's Dilemma 🤔</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Sat, 23 Dec 2023 09:51:11 +0000</pubDate>
      <link>https://dev.to/kevinrawal/quick-sort-vs-merge-sort-a-developers-dilemma-5ble</link>
      <guid>https://dev.to/kevinrawal/quick-sort-vs-merge-sort-a-developers-dilemma-5ble</guid>
      <description>&lt;p&gt;Let's delve into the intriguing realm of sorting algorithms and zoom in on the dynamic duo—&lt;a href="https://www.geeksforgeeks.org/quick-sort/" rel="noopener noreferrer"&gt;Quick Sort&lt;/a&gt; and &lt;a href="https://www.geeksforgeeks.org/merge-sort/" rel="noopener noreferrer"&gt;Merge Sort&lt;/a&gt;. 🚀✨&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Quick Sort: The Swift Pathfinder 🏎️&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Quick Sort is the speed demon of sorting algorithms. Its divide-and-conquer strategy, coupled with clever pivot selection, makes it incredibly efficient.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Cases:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-Time Processing&lt;/strong&gt;: In scenarios like financial trading, where split-second decisions matter, Quick Sort's speed is a game-changer.&lt;br&gt;
&lt;strong&gt;Large Datasets&lt;/strong&gt;: When dealing with massive datasets, Quick Sort's average time complexity of O(n log n) shines, ensuring rapid data organization.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Worst Case Consideration:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caveat Emptor:&lt;/strong&gt; However, it's important to note the worst-case scenario. If the pivot selection consistently results in unbalanced partitions, Quick Sort can degrade to a quadratic time complexity (O(n^2)), making it less favorable for certain cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Merge Sort: The Consistent Performer 🔄&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Merge Sort, on the other hand, takes a more laid-back approach. It's stable, reliable, and maintains a consistent performance.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Cases:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stability Matters&lt;/strong&gt;: When stability is crucial, as in applications where the relative order of equal elements must be preserved, Merge Sort comes to the forefront.&lt;br&gt;
Predictable Performance: In scenarios where a consistent and predictable time complexity of O(n log n) is preferred over the fastest possible speed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choosing Wisely&lt;/strong&gt;: Balancing Speed and Consistency ⚖️&lt;/p&gt;

&lt;p&gt;As developers, the choice between Quick Sort and Merge Sort often boils down to the specific needs of the task at hand. Need blazing speed and can handle a bit of unpredictability? Quick Sort is your ally. Craving stability and a consistent performance profile? Merge Sort has your back. 🤝&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your Experiences?💬&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have you encountered situations where the choice between Quick Sort and Merge Sort made a significant impact on your project? Share your thoughts, experiences, and let's keep the conversation alive! 🚀✨&lt;/p&gt;

</description>
      <category>programming</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>2023 Leetcode Rewind</title>
      <dc:creator>kevinrawal</dc:creator>
      <pubDate>Thu, 21 Dec 2023 04:46:13 +0000</pubDate>
      <link>https://dev.to/kevinrawal/2023-leetcode-rewind-3101</link>
      <guid>https://dev.to/kevinrawal/2023-leetcode-rewind-3101</guid>
      <description>&lt;p&gt;"2023 was a great year for my coding skills! Thanks to &lt;a href="https://leetcode.com/win-son/" rel="noopener noreferrer"&gt;LeetCode&lt;/a&gt;&lt;br&gt;
 for helping me level up 🚀.&lt;/p&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%2Fks4ks8ym93ks9c67ws6y.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%2Fks4ks8ym93ks9c67ws6y.png" alt=" " width="800" height="1334"&gt;&lt;/a&gt;&lt;br&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%2Fst9l0jrqk1fdbekz7tuh.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%2Fst9l0jrqk1fdbekz7tuh.png" alt=" " width="800" height="1424"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
