<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet href="/static/feed.xsl" type="text/xsl" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:quartz="https://quartz.jzhao.xyz/ns">
  <script xmlns="http://www.w3.org/1999/xhtml" src="/static/scripts/xslt-polyfill-214fd525.js"></script>
  <title>/wiki / system-design</title>
  <subtitle>Recent notes in /wiki / system-design on Animesh Mishra</subtitle>
  <link href="https://animishraa05.github.io/wiki/system-design" />
  <link rel="alternate" type="text/html" href="https://animishraa05.github.io/wiki/system-design" />
  <category term="wiki/system-design" />
  <id>https://animishraa05.github.io/wiki/system-design</id>
  <updated>2026-09-02T00:00:00.000Z</updated>
  <contributor>
    <name>Animesh Mishra</name>
    <email>animesh.mishra818@gmail.com</email>
  </contributor>
  <logo>https://animishraa05.github.io/icon.png</logo>
  <icon>https://animishraa05.github.io/icon.png</icon>
  <generator>Quartz v4.6.0 -- quartz.jzhao.xyz</generator>
  <rights type="html">&amp;amp;copy; 2026 Animesh Mishra</rights>
  
  <entry>
    <title>System Design — Map of Content</title>
    <link href="https://animishraa05.github.io/wiki/system-design/system-design-moc" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/system-design-moc.md" />
    <summary> Map of Content for System Design — 40 concepts. Start here to navigate system-design.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="meta" label="meta" />
<category term="system-design" label="system-design" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;blockquote&gt;
&lt;p dir=&quot;auto&quot;&gt;Map of Content for &lt;strong&gt;System Design&lt;/strong&gt; — 40 concepts. Start here to navigate system-design.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;core-concepts&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Concepts&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-concepts&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../active-active-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-active-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Active Failover&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../active-passive-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-passive-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Passive Failover&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../ap-availability-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;ap-availability-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;AP — Availability and Partition Tolerance&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../availability-nines&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-nines&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability Nines&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../availability-parallel-vs-sequence&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-parallel-vs-sequence&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability in Parallel vs Sequence&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../back-of-envelope-estimates&quot; class=&quot;internal alias&quot; data-slug=&quot;back-of-envelope-estimates&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Back-of-the-Envelope Estimates&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../back-pressure&quot; class=&quot;internal alias&quot; data-slug=&quot;back-pressure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Back Pressure&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../cap-theorem&quot; class=&quot;internal alias&quot; data-slug=&quot;cap-theorem&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CAP Theorem&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../cdn-pull&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-pull&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Pull CDN&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../cdn-push&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-push&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Push CDN&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../cp-consistency-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;cp-consistency-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CP — Consistency and Partition Tolerance&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../database-federation&quot; class=&quot;internal alias&quot; data-slug=&quot;database-federation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Database Federation&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../denormalization&quot; class=&quot;internal alias&quot; data-slug=&quot;denormalization&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Denormalization&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../dns-system-design&quot; class=&quot;internal alias&quot; data-slug=&quot;dns-system-design&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DNS in System Design&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../eventual-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;eventual-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Eventual Consistency&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../latency-vs-throughput&quot; class=&quot;internal alias&quot; data-slug=&quot;latency-vs-throughput&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Latency vs Throughput&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../load-balancer-vs-reverse-proxy&quot; class=&quot;internal&quot; data-slug=&quot;load-balancer-vs-reverse-proxy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;load-balancer-vs-reverse-proxy&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../master-master-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-master-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Master Replication&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../microservices-architecture&quot; class=&quot;internal alias&quot; data-slug=&quot;microservices-architecture&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Microservices Architecture&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../nosql-database-types&quot; class=&quot;internal alias&quot; data-slug=&quot;nosql-database-types&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;NoSQL Database Types&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../performance-vs-scalability&quot; class=&quot;internal alias&quot; data-slug=&quot;performance-vs-scalability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Performance vs Scalability&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../refresh-ahead-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;refresh-ahead-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Refresh-Ahead Cache&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../rest-architectural-style&quot; class=&quot;internal alias&quot; data-slug=&quot;rest-architectural-style&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;REST (Architectural Style)&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy Pattern&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../rpc-remote-procedure-call&quot; class=&quot;internal alias&quot; data-slug=&quot;rpc-remote-procedure-call&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;RPC (Remote Procedure Call)&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../service-discovery&quot; class=&quot;internal alias&quot; data-slug=&quot;service-discovery&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Service Discovery&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../sql-tuning&quot; class=&quot;internal alias&quot; data-slug=&quot;sql-tuning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SQL Tuning&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../sql-vs-nosql&quot; class=&quot;internal&quot; data-slug=&quot;sql-vs-nosql&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;sql-vs-nosql&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../strong-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;strong-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Strong Consistency&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../task-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;task-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Task Queues&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../weak-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;weak-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Weak Consistency&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../write-behind-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-behind-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Behind Cache&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../write-through-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-through-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Through Cache&lt;/a&gt; — concept&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;mechanisms--how-things-work&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Mechanisms &amp;#x26; How Things Work&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#mechanisms--how-things-work&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;em&gt;Auto-generated — edit to curate. Pages that explain processes/flows.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;comparisons--tradeoffs&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparisons &amp;#x26; Tradeoffs&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparisons--tradeoffs&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;em&gt;(No synthesis yet — create via ingest or query —save)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;suggested-reading-order&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Suggested Reading Order&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#suggested-reading-order&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Browse Core Concepts above — start with most-linked page&lt;/li&gt;
&lt;li&gt;Follow Connections sections for dense graph traversal&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry><entry>
    <title>active-active-failover</title>
    <link href="https://animishraa05.github.io/wiki/system-design/active-active-failover" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/active-active-failover.md" />
    <summary>The Problem Standby servers in active-passive setups remain idle, wasting compute resources and providing no return on the hardware investment.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="high-availability" label="high-availability" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Standby servers in active-passive setups remain idle, wasting compute resources and providing no return on the hardware investment.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;In active-active failover, both servers manage traffic simultaneously, spreading the load between them and eliminating idle resources.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Both servers are active and handle client requests concurrently.&lt;/li&gt;
&lt;li&gt;A load balancer or DNS distributes incoming traffic across both servers.&lt;/li&gt;
&lt;li&gt;If one server fails, the remaining server continues handling all traffic (with degraded capacity).&lt;/li&gt;
&lt;li&gt;DNS must be configured with both IP addresses for public-facing services.&lt;/li&gt;
&lt;li&gt;Application logic must be aware of both servers for internal communication.&lt;/li&gt;
&lt;li&gt;Also called master-master failover.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: active_active_failover Pages: 1 --&gt;
&lt;svg width=&quot;519pt&quot; height=&quot;98pt&quot; viewBox=&quot;0.00 0.00 519.00 98.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 94)&quot;&gt;
&lt;title&gt;active_active_failover&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-94 515.38,-94 515.38,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CLIENTS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CLIENTS&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;54,-62 0,-62 0,-26 54,-26 54,-62&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Clients&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;LB&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;184.39,-62 91,-62 91,-26 184.39,-26 184.39,-62&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;137.7&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Load Balancer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CLIENTS&amp;#45;&amp;gt;LB --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CLIENTS-&gt;LB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.31,-44C61.91,-44 70.52,-44 79.24,-44&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;79.17,-47.5 89.17,-44 79.17,-40.5 79.17,-47.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- S1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S1&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;374.32,-90 267.63,-90 267.63,-54 374.32,-54 374.32,-90&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;320.97&quot; y=&quot;-68.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Server A (Active)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;S1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;S1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M184.44,-51.07C206.07,-54.41 232.27,-58.45 255.85,-62.09&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;255.26,-65.55 265.68,-63.61 256.33,-58.63 255.26,-65.55&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;226.01&quot; y=&quot;-63.51&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;50% traffic&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S2&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;374.32,-36 267.63,-36 267.63,0 374.32,0 374.32,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;320.97&quot; y=&quot;-14.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Server B (Active)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;S2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;S2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M184.58,-35.83C190.57,-34.83 196.62,-33.87 202.39,-33 219.75,-30.39 238.6,-27.86 256.02,-25.64&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;256.24,-29.14 265.72,-24.41 255.37,-22.19 256.24,-29.14&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;226.01&quot; y=&quot;-36&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;50% traffic&lt;/text&gt;
&lt;/g&gt;
&lt;!-- STORAGE --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;STORAGE&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;511.38,-62 411.32,-62 411.32,-26 511.38,-26 511.38,-62&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;461.35&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Shared Storage&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1&amp;#45;&amp;gt;STORAGE --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S1-&gt;STORAGE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M374.68,-61.33C382.87,-59.68 391.39,-57.95 399.74,-56.26&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;400.38,-59.7 409.49,-54.29 399,-52.84 400.38,-59.7&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- S2&amp;#45;&amp;gt;STORAGE --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S2-&gt;STORAGE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M374.68,-27.9C382.87,-29.44 391.39,-31.04 399.74,-32.61&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;399.01,-36.04 409.49,-34.44 400.31,-29.16 399.01,-36.04&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;No idle resources — both servers handle traffic&lt;/li&gt;
&lt;li&gt;Load is spread between both servers, improving throughput&lt;/li&gt;
&lt;li&gt;DNS or application must be aware of both server IPs&lt;/li&gt;
&lt;li&gt;Capacity is degraded (not lost) on single-server failure&lt;/li&gt;
&lt;li&gt;Also called master-master failover&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../active-passive-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-passive-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Passive Failover&lt;/a&gt; — both active vs one standby&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../availability-nines&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-nines&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability Nines&lt;/a&gt; — active-active improves overall availability&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — load balancers distribute traffic in active-active&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — active-active is a form of horizontal scaling&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Session affinity (sticky sessions) becomes harder — requests from one user may hit different servers&lt;/li&gt;
&lt;li&gt;Both servers must have consistent state or share storage to avoid data divergence&lt;/li&gt;
&lt;li&gt;Failover capacity is only 50% — if one server dies, the remaining server must handle full load&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>active-passive-failover</title>
    <link href="https://animishraa05.github.io/wiki/system-design/active-passive-failover" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/active-passive-failover.md" />
    <summary>The Problem A single server is a single point of failure — if it goes down, the service becomes unavailable.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="high-availability" label="high-availability" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A single server is a single point of failure — if it goes down, the service becomes unavailable. Unplanned downtime leads to revenue loss, user trust erosion, and SLA violations.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Active-passive failover uses a standby server that takes over if the active server fails, with heartbeat monitoring detecting failure and triggering the switch.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;The active server handles all production traffic while the passive server remains idle.&lt;/li&gt;
&lt;li&gt;Heartbeat signals are sent between the active and passive servers at regular intervals.&lt;/li&gt;
&lt;li&gt;If the passive server stops receiving heartbeats, it assumes the active has failed.&lt;/li&gt;
&lt;li&gt;The passive server takes over the active server’s IP address (via IP takeover or virtual IP).&lt;/li&gt;
&lt;li&gt;The passive resumes service from the point the active left off (with shared storage).&lt;/li&gt;
&lt;li&gt;Downtime depends on the standby type: hot standby (minutes) vs cold standby (hours).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: active_passive_failover Pages: 1 --&gt;
&lt;svg width=&quot;696pt&quot; height=&quot;76pt&quot; viewBox=&quot;0.00 0.00 696.00 76.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 72)&quot;&gt;
&lt;title&gt;active_passive_failover&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-72 691.82,-72 691.82,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- LB --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;LB&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;93.39,-53 0,-53 0,-17 93.39,-17 93.39,-53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;46.7&quot; y=&quot;-31.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Load Balancer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ACTIVE --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ACTIVE&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;271.77,-53 184.41,-53 184.41,-17 271.77,-17 271.77,-53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;228.09&quot; y=&quot;-31.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Active Server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;ACTIVE --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;ACTIVE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M93.43,-35C117.64,-35 147.54,-35 172.91,-35&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;172.7,-38.5 182.7,-35 172.7,-31.5 172.7,-38.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;138.9&quot; y=&quot;-38&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;routes traffic&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PASSIVE --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;PASSIVE&lt;/title&gt;
&lt;polygon fill=&quot;#ffe5cc&quot; stroke=&quot;black&quot; points=&quot;471.72,-68 375.02,-68 375.02,-32 471.72,-32 471.72,-68&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;423.37&quot; y=&quot;-46.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Passive Server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ACTIVE&amp;#45;&amp;gt;PASSIVE --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ACTIVE-&gt;PASSIVE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M272.01,-45.28C277.94,-46.39 283.99,-47.34 289.77,-48 313.74,-50.72 340.31,-51.55 363.33,-51.58&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;363.16,-55.08 373.15,-51.54 363.13,-48.08 363.16,-55.08&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;323.39&quot; y=&quot;-54.53&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;heartbeat&lt;/text&gt;
&lt;/g&gt;
&lt;!-- STORAGE --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;STORAGE&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;687.82,-36 587.77,-36 587.77,0 687.82,0 687.82,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;637.79&quot; y=&quot;-14.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Shared Storage&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ACTIVE&amp;#45;&amp;gt;STORAGE --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ACTIVE-&gt;STORAGE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M271.96,-26.06C300.92,-20.49 340.09,-13.85 375.02,-11 443.83,-5.38 523.12,-8.89 576.24,-12.68&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;575.76,-16.15 585.99,-13.4 576.27,-9.17 575.76,-16.15&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;423.37&quot; y=&quot;-14&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;reads/writes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PASSIVE&amp;#45;&amp;gt;ACTIVE --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;PASSIVE-&gt;ACTIVE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M374.82,-36.14C368.87,-34.85 362.84,-33.74 357.02,-33 332.99,-29.93 306.21,-29.83 283.39,-30.74&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;283.53,-27.23 273.71,-31.2 283.86,-34.22 283.53,-27.23&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;323.39&quot; y=&quot;-36&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;heartbeat (ack)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PASSIVE&amp;#45;&amp;gt;STORAGE --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;PASSIVE-&gt;STORAGE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M472.04,-42.82C502.79,-38.19 543.06,-32.12 576.08,-27.15&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;576.57,-30.61 585.94,-25.66 575.53,-23.69 576.57,-30.61&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;529.74&quot; y=&quot;-42.65&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;reads on takeover&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Passive server sits on standby, handling zero traffic during normal operation&lt;/li&gt;
&lt;li&gt;Only the active server handles client requests&lt;/li&gt;
&lt;li&gt;Heartbeat-based failure detection triggers automatic failover&lt;/li&gt;
&lt;li&gt;Also called master-slave failover&lt;/li&gt;
&lt;li&gt;Failover time varies by standby type: hot (minutes) vs cold (hours)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../active-active-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-active-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Active Failover&lt;/a&gt; — passive standby vs both serving traffic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../availability-nines&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-nines&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability Nines&lt;/a&gt; — failover improves uptime percentage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — load balancers orchestrate failover routing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — adding passive nodes is a scaling concern&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Split-brain scenario: both servers think the other is dead and both become active, causing data corruption&lt;/li&gt;
&lt;li&gt;Heartbeat network itself can be a single point of failure — redundant heartbeat links recommended&lt;/li&gt;
&lt;li&gt;Stateful services (in-memory sessions) are lost on failover unless backed by shared storage&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>ap-availability-partition-tolerance</title>
    <link href="https://animishraa05.github.io/wiki/system-design/ap-availability-partition-tolerance" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/ap-availability-partition-tolerance.md" />
    <summary>The Problem Some systems must remain operational during network partitions, even if the data served might be stale.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="distributed-systems" label="distributed-systems" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Some systems must remain operational during network partitions, even if the data served might be stale. Social media feeds, content delivery, and collaborative tools cannot show errors to users.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;AP systems choose availability over consistency during network partitions. Every request receives a response using the most readily available version of the data. Writes are accepted and propagated asynchronously — when the partition resolves, nodes reconcile any conflicts. The system is always responsive but may serve stale or divergent data temporarily.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Pre-partition&lt;/strong&gt;: Nodes replicate data asynchronously. A write to one node is propagated to others in the background. Reads may return slightly stale data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partition occurs&lt;/strong&gt;: A subset of nodes becomes unreachable. Each partition group continues operating independently.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serve what you have&lt;/strong&gt;: Reachable nodes accept reads and writes using local data. No request is refused.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conflict resolution&lt;/strong&gt;: When the partition heals, nodes exchange write logs. Conflicting writes are resolved using a strategy (last-write-wins, CRDT merge, application-level reconciliation).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Convergence&lt;/strong&gt;: All nodes eventually converge to the same state.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;1039pt&quot; height=&quot;284pt&quot; viewBox=&quot;0.00 0.00 1039.00 284.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 280)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-280 1035.21,-280 1035.21,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_normal&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-265.2 247,-265.2 247,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.5&quot; y=&quot;-248.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Normal Operation&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust3&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_partition&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;255,-96.8 255,-265.2 515,-265.2 515,-96.8 255,-96.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;385&quot; y=&quot;-248.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;During Partition&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust4&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_recovery&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;523,-96.8 523,-268 715,-268 715,-96.8 523,-96.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;619&quot; y=&quot;-251.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Partition Heals&lt;/text&gt;
&lt;/g&gt;
&lt;!-- client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M133.79,-232.4C133.79,-232.4 72.21,-232.4 72.21,-232.4 66.21,-232.4 60.21,-226.4 60.21,-220.4 60.21,-220.4 60.21,-208.4 60.21,-208.4 60.21,-202.4 66.21,-196.4 72.21,-196.4 72.21,-196.4 133.79,-196.4 133.79,-196.4 139.79,-196.4 145.79,-202.4 145.79,-208.4 145.79,-208.4 145.79,-220.4 145.79,-220.4 145.79,-226.4 139.79,-232.4 133.79,-232.4&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;103&quot; y=&quot;-210.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client Write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M119.41,-140.8C119.41,-140.8 86.59,-140.8 86.59,-140.8 80.59,-140.8 74.59,-134.8 74.59,-128.8 74.59,-128.8 74.59,-116.8 74.59,-116.8 74.59,-110.8 80.59,-104.8 86.59,-104.8 86.59,-104.8 119.41,-104.8 119.41,-104.8 125.41,-104.8 131.41,-110.8 131.41,-116.8 131.41,-116.8 131.41,-128.8 131.41,-128.8 131.41,-134.8 125.41,-140.8 119.41,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;103&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- client&amp;#45;&amp;gt;n1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;client-&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M103,-196.12C103,-183.73 103,-166.74 103,-152.35&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;106.5,-152.54 103,-142.54 99.5,-152.54 106.5,-152.54&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;143.61&quot; y=&quot;-163&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;write accepted&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M60.41,-52C60.41,-52 27.59,-52 27.59,-52 21.59,-52 15.59,-46 15.59,-40 15.59,-40 15.59,-28 15.59,-28 15.59,-22 21.59,-16 27.59,-16 27.59,-16 60.41,-16 60.41,-16 66.41,-16 72.41,-22 72.41,-28 72.41,-28 72.41,-40 72.41,-40 72.41,-46 66.41,-52 60.41,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;44&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1&amp;#45;&amp;gt;n2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1-&gt;n2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M74.25,-115.56C58.7,-110.57 40.8,-101.82 31.43,-86.8 26.98,-79.68 27.27,-71.09 29.49,-62.98&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;32.7,-64.4 32.93,-53.81 26.14,-61.95 32.7,-64.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;76.72&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;async propagate&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n3 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M164.41,-52C164.41,-52 131.59,-52 131.59,-52 125.59,-52 119.59,-46 119.59,-40 119.59,-40 119.59,-28 119.59,-28 119.59,-22 125.59,-16 131.59,-16 131.59,-16 164.41,-16 164.41,-16 170.41,-16 176.41,-22 176.41,-28 176.41,-28 176.41,-40 176.41,-40 176.41,-46 170.41,-52 164.41,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;148&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1&amp;#45;&amp;gt;n3 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1-&gt;n3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M115.34,-104.37C118.98,-98.88 122.84,-92.7 126,-86.8 130.07,-79.19 133.96,-70.66 137.3,-62.76&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;140.51,-64.14 141.04,-53.56 134.03,-61.5 140.51,-64.14&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;179.39&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;async propagate&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c2 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;c2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M333.24,-232.4C333.24,-232.4 274.76,-232.4 274.76,-232.4 268.76,-232.4 262.76,-226.4 262.76,-220.4 262.76,-220.4 262.76,-208.4 262.76,-208.4 262.76,-202.4 268.76,-196.4 274.76,-196.4 274.76,-196.4 333.24,-196.4 333.24,-196.4 339.24,-196.4 345.24,-202.4 345.24,-208.4 345.24,-208.4 345.24,-220.4 345.24,-220.4 345.24,-226.4 339.24,-232.4 333.24,-232.4&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;304&quot; y=&quot;-210.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client Read&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1p --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n1p&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M395.14,-140.8C395.14,-140.8 274.86,-140.8 274.86,-140.8 268.86,-140.8 262.86,-134.8 262.86,-128.8 262.86,-128.8 262.86,-116.8 262.86,-116.8 262.86,-110.8 268.86,-104.8 274.86,-104.8 274.86,-104.8 395.14,-104.8 395.14,-104.8 401.14,-104.8 407.14,-110.8 407.14,-116.8 407.14,-116.8 407.14,-128.8 407.14,-128.8 407.14,-134.8 401.14,-140.8 395.14,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;335&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Partition A (reachable)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c2&amp;#45;&amp;gt;n1p --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;c2-&gt;n1p&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M303.22,-196.14C303.29,-185.12 304.45,-170.71 309,-158.8 310.04,-156.08 311.36,-153.38 312.84,-150.77&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;315.74,-152.73 318.34,-142.46 309.9,-148.87 315.74,-152.73&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- n1p&amp;#45;&amp;gt;c2 --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1p-&gt;c2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M329.04,-141.02C324.67,-153.65 318.65,-171.07 313.6,-185.65&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;310.43,-184.1 310.47,-194.69 317.05,-186.39 310.43,-184.1&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;411.88&quot; y=&quot;-163&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;returns local data (may be stale)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n2p --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n2p&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;506.75,-232.4 363.25,-232.4 363.25,-196.4 506.75,-196.4 506.75,-232.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;435&quot; y=&quot;-210.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Partition B (reachable)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- merge --&gt;
&lt;g id=&quot;node8&quot; class=&quot;node&quot;&gt;
&lt;title&gt;merge&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M694.7,-235.2C694.7,-235.2 543.3,-235.2 543.3,-235.2 537.3,-235.2 531.3,-229.2 531.3,-223.2 531.3,-223.2 531.3,-205.6 531.3,-205.6 531.3,-199.6 537.3,-193.6 543.3,-193.6 543.3,-193.6 694.7,-193.6 694.7,-193.6 700.7,-193.6 706.7,-199.6 706.7,-205.6 706.7,-205.6 706.7,-223.2 706.7,-223.2 706.7,-229.2 700.7,-235.2 694.7,-235.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;619&quot; y=&quot;-218.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Conflict Resolution&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;619&quot; y=&quot;-201.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(CRDT / LWW / App-level)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- final --&gt;
&lt;g id=&quot;node9&quot; class=&quot;node&quot;&gt;
&lt;title&gt;final&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M669.43,-140.8C669.43,-140.8 568.57,-140.8 568.57,-140.8 562.57,-140.8 556.57,-134.8 556.57,-128.8 556.57,-128.8 556.57,-116.8 556.57,-116.8 556.57,-110.8 562.57,-104.8 568.57,-104.8 568.57,-104.8 669.43,-104.8 669.43,-104.8 675.43,-104.8 681.43,-110.8 681.43,-116.8 681.43,-116.8 681.43,-128.8 681.43,-128.8 681.43,-134.8 675.43,-140.8 669.43,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;619&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;All nodes converge&lt;/text&gt;
&lt;/g&gt;
&lt;!-- merge&amp;#45;&amp;gt;final --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;merge-&gt;final&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M619,-193.51C619,-181.52 619,-166.02 619,-152.68&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;622.5,-152.72 619,-142.72 615.5,-152.72 622.5,-152.72&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- label_ap --&gt;
&lt;g id=&quot;node10&quot; class=&quot;node&quot;&gt;
&lt;title&gt;label_ap&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;1025.21,-232.4 724.79,-232.4 724.79,-196.4 1031.21,-196.4 1031.21,-226.4 1025.21,-232.4&quot;&gt;&lt;/polygon&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;1025.21,-232.4 1025.21,-226.4&quot;&gt;&lt;/polyline&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;1031.21,-226.4 1025.21,-226.4&quot;&gt;&lt;/polyline&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;878&quot; y=&quot;-210.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;AP: Availability guaranteed, Consistency sacrificed&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Always returns a response&lt;/strong&gt;: No request is rejected or timed out due to consistency concerns&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;May return stale data&lt;/strong&gt;: Reads reflect the latest write the responding node has seen, which may lag behind&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes eventually propagate&lt;/strong&gt;: Asynchronous replication means write conflicts are resolved post-facto&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Common in social media, CDNs, DNS&lt;/strong&gt;: Applications where availability matters more than absolute consistency&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../cap-theorem&quot; class=&quot;internal alias&quot; data-slug=&quot;cap-theorem&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CAP Theorem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../cp-consistency-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;cp-consistency-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CP — Consistency and Partition Tolerance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../eventual-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;eventual-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Eventual Consistency&lt;/a&gt; — AP systems implement eventual consistency&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cdn-push&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-push&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Push CDN&lt;/a&gt; — an AP system that serves content despite partitions&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Conflict resolution is hard&lt;/strong&gt;: Last-write-wins can silently discard data. CRDTs avoid data loss but are complex to implement. Application-level merging (e.g., collaborative editing) may require user intervention.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stale reads can compound&lt;/strong&gt;: If many reads traverse a chain of eventually-consistent replicas, staleness can accumulate beyond expected bounds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not appropriate for all data&lt;/strong&gt;: Financial transactions, inventory counts, and lock services generally cannot tolerate AP behavior.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>availability-nines</title>
    <link href="https://animishraa05.github.io/wiki/system-design/availability-nines" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/availability-nines.md" />
    <summary>The Problem Uptime guarantees need a standardized measurement to compare systems and set meaningful SLAs between providers and customers.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="high-availability" label="high-availability" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Uptime guarantees need a standardized measurement to compare systems and set meaningful SLAs between providers and customers.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Availability is quantified by uptime percentage — “number of 9s” (99.9% = three 9s, 99.99% = four 9s). Each additional 9 represents a tenfold reduction in allowed downtime.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Availability is calculated as uptime divided by total time over a measurement period.&lt;/li&gt;
&lt;li&gt;99.9% (three 9s) permits approximately 8 hours 45 minutes of downtime per year.&lt;/li&gt;
&lt;li&gt;99.99% (four 9s) permits approximately 52 minutes of downtime per year.&lt;/li&gt;
&lt;li&gt;99.999% (five 9s) permits approximately 5 minutes of downtime per year.&lt;/li&gt;
&lt;li&gt;Each additional 9 requires exponentially more redundancy and operational discipline.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: availability_nines Pages: 1 --&gt;
&lt;svg width=&quot;132pt&quot; height=&quot;331pt&quot; viewBox=&quot;0.00 0.00 132.00 331.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 326.6)&quot;&gt;
&lt;title&gt;availability_nines&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-326.6 127.71,-326.6 127.71,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- NINES --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;NINES&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; points=&quot;115.21,-322.6 8.5,-322.6 8.5,-286.6 115.21,-286.6 115.21,-322.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-301&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Availability Nines&lt;/text&gt;
&lt;/g&gt;
&lt;!-- T3 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;T3&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;119.05,-249.6 4.66,-249.6 4.66,-198.4 119.05,-198.4 119.05,-249.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-234.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;99.9%&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-220.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;3 nines&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-206&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;~8.8h/yr downtime&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NINES&amp;#45;&amp;gt;T3 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;NINES-&gt;T3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M61.86,-286.16C61.86,-278.82 61.86,-269.99 61.86,-261.35&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;65.36,-261.36 61.86,-251.36 58.36,-261.36 65.36,-261.36&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- T4 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;T4&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;123.71,-150.4 0,-150.4 0,-99.2 123.71,-99.2 123.71,-150.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-135.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;99.99%&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-121.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;4 nines&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-106.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;~52min/yr downtime&lt;/text&gt;
&lt;/g&gt;
&lt;!-- T3&amp;#45;&amp;gt;T4 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;T3-&gt;T4&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M61.86,-197.97C61.86,-187.08 61.86,-174.12 61.86,-162.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;65.36,-162.26 61.86,-152.26 58.36,-162.26 65.36,-162.26&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.31&quot; y=&quot;-171.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;10x stricter&lt;/text&gt;
&lt;/g&gt;
&lt;!-- T5 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;T5&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;120.38,-51.2 3.34,-51.2 3.34,0 120.38,0 120.38,-51.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-36.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;99.999%&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;5 nines&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.86&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;~5min/yr downtime&lt;/text&gt;
&lt;/g&gt;
&lt;!-- T4&amp;#45;&amp;gt;T5 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;T4-&gt;T5&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M61.86,-98.77C61.86,-87.88 61.86,-74.92 61.86,-63&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;65.36,-63.06 61.86,-53.06 58.36,-63.06 65.36,-63.06&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.31&quot; y=&quot;-72.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;10x stricter&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Measured in “number of 9s” — 99.9%, 99.99%, 99.999%&lt;/li&gt;
&lt;li&gt;Each additional 9 is a 10x reduction in allowed downtime&lt;/li&gt;
&lt;li&gt;Three 9s = 99.9% uptime&lt;/li&gt;
&lt;li&gt;Four 9s = 99.99% uptime&lt;/li&gt;
&lt;li&gt;Five 9s = 99.999% uptime&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../availability-parallel-vs-sequence&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-parallel-vs-sequence&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability in Parallel vs Sequence&lt;/a&gt; — how component availability combines to produce overall nines&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-passive-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-passive-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Passive Failover&lt;/a&gt; — failover pattern increases achievable nines&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-active-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-active-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Active Failover&lt;/a&gt; — active-active improves achievable nines&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — adding nodes increases availability through redundancy&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Nines are calculated over a full year — a single prolonged outage can blow through the entire budget&lt;/li&gt;
&lt;li&gt;“Five 9s” is extraordinarily difficult in practice, requiring redundant everything (power, network, servers, data centers)&lt;/li&gt;
&lt;li&gt;Partial outages (degraded but not down) are often excluded from SLA calculations, masking real availability&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>availability-parallel-vs-sequence</title>
    <link href="https://animishraa05.github.io/wiki/system-design/availability-parallel-vs-sequence" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/availability-parallel-vs-sequence.md" />
    <summary>The Problem When a system has multiple components, overall availability depends on how they are connected.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="high-availability" label="high-availability" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;When a system has multiple components, overall availability depends on how they are connected. Naively combining component availability gives misleading results.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Components in sequence multiply their availability together (making total availability worse), while components in parallel multiply their unavailability together (making total availability dramatically better).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Sequence formula:&lt;/strong&gt; &lt;code class=&quot;notranslate&quot;&gt;Avail(Total) = Avail(A) × Avail(B)&lt;/code&gt;. Two 99.9% components in series yield 99.8% — worse than either alone.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parallel formula:&lt;/strong&gt; &lt;code class=&quot;notranslate&quot;&gt;Avail(Total) = 1 - (1 - Avail(A)) × (1 - Avail(B))&lt;/code&gt;. Two 99.9% components in parallel yield 99.9999% — better than either alone.&lt;/li&gt;
&lt;li&gt;Parallel systems only fail if both (or all) redundant components fail simultaneously.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: availability_parallel_sequence Pages: 1 --&gt;
&lt;svg width=&quot;297pt&quot; height=&quot;241pt&quot; viewBox=&quot;0.00 0.00 297.00 241.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 237)&quot;&gt;
&lt;title&gt;availability_parallel_sequence&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-237 292.98,-237 292.98,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_sequence&lt;/title&gt;
&lt;polygon fill=&quot;#ffe5cc&quot; stroke=&quot;black&quot; points=&quot;6.37,-8 6.37,-85 241.38,-85 241.38,-8 6.37,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;123.88&quot; y=&quot;-68.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;In Sequence (99.9% × 99.9% = 99.8%)&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_parallel&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;50.89,-93 50.89,-225 280.98,-225 280.98,-93 50.89,-93&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;165.94&quot; y=&quot;-208.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;In Parallel (1 - 0.001² = 99.9999%)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1 --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S1&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;105.38,-52.4 16,-52.4 16,-15.6 105.38,-15.6 105.38,-52.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.69&quot; y=&quot;-37.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Component A&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.69&quot; y=&quot;-23.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;99.9%&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S2 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S2&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;230.75,-52.4 141.38,-52.4 141.38,-15.6 230.75,-15.6 230.75,-52.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;186.07&quot; y=&quot;-37.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Component B&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;186.07&quot; y=&quot;-23.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;99.9%&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1&amp;#45;&amp;gt;S2 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S1-&gt;S2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M105.53,-34C113.35,-34 121.58,-34 129.67,-34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;129.43,-37.5 139.43,-34 129.43,-30.5 129.43,-37.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- P1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P1&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;230.75,-137.4 141.38,-137.4 141.38,-100.6 230.75,-100.6 230.75,-137.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;186.07&quot; y=&quot;-122.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Component A&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;186.07&quot; y=&quot;-108.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;99.9%&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P_OUT --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P_OUT&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; cx=&quot;271.18&quot; cy=&quot;-146&quot; rx=&quot;1.8&quot; ry=&quot;1.8&quot;&gt;&lt;/ellipse&gt;
&lt;/g&gt;
&lt;!-- P1&amp;#45;&amp;gt;P_OUT --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P1-&gt;P_OUT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M231.06,-133.29C241.1,-136.55 250.95,-139.75 258.25,-142.12&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;257.06,-145.42 267.66,-145.18 259.23,-138.76 257.06,-145.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- P2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P2&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;230.75,-192.4 141.38,-192.4 141.38,-155.6 230.75,-155.6 230.75,-192.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;186.07&quot; y=&quot;-177.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Component B&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;186.07&quot; y=&quot;-163.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;99.9%&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P2&amp;#45;&amp;gt;P_OUT --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P2-&gt;P_OUT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M231.06,-159.18C241.1,-155.8 250.95,-152.48 258.25,-150.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;259.3,-153.36 267.66,-146.85 257.07,-146.73 259.3,-153.36&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- P_IN --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P_IN&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; cx=&quot;60.69&quot; cy=&quot;-146&quot; rx=&quot;1.8&quot; ry=&quot;1.8&quot;&gt;&lt;/ellipse&gt;
&lt;/g&gt;
&lt;!-- P_IN&amp;#45;&amp;gt;P1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P_IN-&gt;P1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M62.48,-145.83C67.87,-144.65 100.01,-137.61 130.02,-131.05&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;130.43,-134.54 139.45,-128.98 128.94,-127.7 130.43,-134.54&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- P_IN&amp;#45;&amp;gt;P2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P_IN-&gt;P2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M62.48,-146.18C67.87,-147.4 100.01,-154.7 130.02,-161.51&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;128.93,-164.85 139.46,-163.65 130.48,-158.02 128.93,-164.85&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Sequential components multiply availability — total is always &lt;em&gt;worse&lt;/em&gt; than the worst component&lt;/li&gt;
&lt;li&gt;Parallel components multiply unavailability — total is always &lt;em&gt;better&lt;/em&gt; than the best component&lt;/li&gt;
&lt;li&gt;Fundamental principle underlying all reliability engineering and redundancy design&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../availability-nines&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-nines&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability Nines&lt;/a&gt; — the formula behind nines calculations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-passive-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-passive-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Passive Failover&lt;/a&gt; — parallel arrangement of servers for failover&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-active-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-active-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Active Failover&lt;/a&gt; — parallel arrangement for load sharing and redundancy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — adding parallel nodes improves overall system availability&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Components are rarely perfectly independent — shared power supplies, network links, or data centers create common-mode failures that violate the parallel model&lt;/li&gt;
&lt;li&gt;The parallel formula assumes instant failover, but real failover has non-zero downtime that reduces effective availability&lt;/li&gt;
&lt;li&gt;Very long dependency chains (many sequential components) degrade availability drastically — a system with ten 99.9% components in series is only 99.0% available&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>back-of-envelope-estimates</title>
    <link href="https://animishraa05.github.io/wiki/system-design/back-of-envelope-estimates" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/back-of-envelope-estimates.md" />
    <summary>The Problem System design interviews and architecture decisions require quick quantitative estimates to determine whether a design is feasible — how much storage is needed, how many servers are required, what the bottleneck will be — without access to calculators or reference systems.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="estimation" label="estimation" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;System design interviews and architecture decisions require quick quantitative estimates to determine whether a design is feasible — how much storage is needed, how many servers are required, what the bottleneck will be — without access to calculators or reference systems.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Back-of-the-envelope estimation uses powers of two for data sizing (2^10 = 1024 ≈ 1K, 2^20 ≈ 1M, 2^30 ≈ 1G) and known latency numbers (L1 cache 0.5ns, RAM 100ns, SSD 150μs, HDD 10ms, datacenter round-trip 500μs) to quickly approximate capacity, throughput, and performance of a system design.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Powers of Two&lt;/strong&gt;: memorize the table: 2^10 = 1K, 2^20 = 1M, 2^30 = 1G, 2^40 = 1T. Use these to estimate storage: a 4-byte integer, 1KB text document, 1MB image, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Latency Numbers&lt;/strong&gt;: memorize the approximate time each operation takes — L1 cache reference (0.5ns), branch mispredict (5ns), L2 cache reference (7ns), mutex lock/unlock (100ns), main memory reference (100ns), compress 1KB with Zippy (10μs), send 2KB over 1 Gbps (20μs), SSD random read (150μs), disk seek (10ms), datacenter round trip (500μs).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Combine&lt;/strong&gt;: for a given design, multiply the per-operation cost by the request volume. Example: 10M daily active users, each generating 100 requests/day = 1B requests/day ≈ 12K requests/sec. Then multiply by per-request CPU/memory/IO to estimate total resources.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: Estimates Pages: 1 --&gt;
&lt;svg width=&quot;564pt&quot; height=&quot;272pt&quot; viewBox=&quot;0.00 0.00 564.00 272.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 268)&quot;&gt;
&lt;title&gt;Estimates&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-268 559.58,-268 559.58,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Input --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Input&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M303.42,-264C303.42,-264 199.08,-264 199.08,-264 193.08,-264 187.08,-258 187.08,-252 187.08,-252 187.08,-217.6 187.08,-217.6 187.08,-211.6 193.08,-205.6 199.08,-205.6 199.08,-205.6 303.42,-205.6 303.42,-205.6 309.42,-205.6 315.42,-211.6 315.42,-217.6 315.42,-217.6 315.42,-252 315.42,-252 315.42,-258 309.42,-264 303.42,-264&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251.25&quot; y=&quot;-247.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Input:&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251.25&quot; y=&quot;-230.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;DAU, requests/user&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251.25&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;avg data per request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Storage --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Storage&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M152.5,-169.6C152.5,-169.6 12,-169.6 12,-169.6 6,-169.6 0,-163.6 0,-157.6 0,-157.6 0,-106.4 0,-106.4 0,-100.4 6,-94.4 12,-94.4 12,-94.4 152.5,-94.4 152.5,-94.4 158.5,-94.4 164.5,-100.4 164.5,-106.4 164.5,-106.4 164.5,-157.6 164.5,-157.6 164.5,-163.6 158.5,-169.6 152.5,-169.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.25&quot; y=&quot;-153&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Storage Estimate:&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.25&quot; y=&quot;-136.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;requests × data per request&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.25&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;× replication factor&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.25&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;= total GB/TB&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Input&amp;#45;&amp;gt;Storage --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Input-&gt;Storage&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M203.27,-205.18C187.94,-196.04 170.61,-185.7 153.97,-175.78&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;155.94,-172.88 145.56,-170.76 152.36,-178.89 155.94,-172.88&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Throughput --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Throughput&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M308.49,-161.2C308.49,-161.2 194.01,-161.2 194.01,-161.2 188.01,-161.2 182.01,-155.2 182.01,-149.2 182.01,-149.2 182.01,-114.8 182.01,-114.8 182.01,-108.8 188.01,-102.8 194.01,-102.8 194.01,-102.8 308.49,-102.8 308.49,-102.8 314.49,-102.8 320.49,-108.8 320.49,-114.8 320.49,-114.8 320.49,-149.2 320.49,-149.2 320.49,-155.2 314.49,-161.2 308.49,-161.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251.25&quot; y=&quot;-144.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Throughput Estimate:&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251.25&quot; y=&quot;-127.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;requests/day ÷ 86400&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251.25&quot; y=&quot;-111&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;= QPS (queries/sec)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Input&amp;#45;&amp;gt;Throughput --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Input-&gt;Throughput&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M251.25,-205.18C251.25,-195.18 251.25,-183.76 251.25,-173&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;254.75,-173.2 251.25,-163.2 247.75,-173.2 254.75,-173.2&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Latency --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Latency&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M543.58,-161.2C543.58,-161.2 350.92,-161.2 350.92,-161.2 344.92,-161.2 338.92,-155.2 338.92,-149.2 338.92,-149.2 338.92,-114.8 338.92,-114.8 338.92,-108.8 344.92,-102.8 350.92,-102.8 350.92,-102.8 543.58,-102.8 543.58,-102.8 549.58,-102.8 555.58,-108.8 555.58,-114.8 555.58,-114.8 555.58,-149.2 555.58,-149.2 555.58,-155.2 549.58,-161.2 543.58,-161.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;447.25&quot; y=&quot;-144.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Latency Budget:&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;447.25&quot; y=&quot;-127.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;map operations to latency numbers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;447.25&quot; y=&quot;-111&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;L1=0.5ns RAM=100ns SSD=150μs&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Input&amp;#45;&amp;gt;Latency --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Input-&gt;Latency&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M306.89,-205.18C330.06,-193.27 357.15,-179.34 381.31,-166.91&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;382.83,-170.07 390.12,-162.38 379.63,-163.84 382.83,-170.07&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Servers --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Servers&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M240.19,-58.4C240.19,-58.4 92.31,-58.4 92.31,-58.4 86.31,-58.4 80.31,-52.4 80.31,-46.4 80.31,-46.4 80.31,-12 80.31,-12 80.31,-6 86.31,0 92.31,0 92.31,0 240.19,0 240.19,0 246.19,0 252.19,-6 252.19,-12 252.19,-12 252.19,-46.4 252.19,-46.4 252.19,-52.4 246.19,-58.4 240.19,-58.4&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;166.25&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Server Count:&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;166.25&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;QPS ÷ (per-server capacity)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;166.25&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;add headroom (2x–3x)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Storage&amp;#45;&amp;gt;Servers --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Storage-&gt;Servers&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M113.05,-94.04C120.28,-85.36 127.98,-76.12 135.22,-67.43&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;137.87,-69.72 141.59,-59.79 132.5,-65.23 137.87,-69.72&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Throughput&amp;#45;&amp;gt;Servers --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Throughput-&gt;Servers&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M227.12,-102.38C217.97,-91.53 207.41,-79.01 197.68,-67.47&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;200.54,-65.43 191.41,-60.04 195.19,-69.95 200.54,-65.43&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;2^10 = 1024 ≈ 1000 (K)&lt;/strong&gt; — approximate for quick estimation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2^20 ≈ 1 million (M)&lt;/strong&gt; — typical for DAU and QPS estimates&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2^30 ≈ 1 billion (G)&lt;/strong&gt; — typical for storage estimates&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory is 80,000x faster than disk&lt;/strong&gt; — 100ns RAM vs 10ms HDD seek&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Datacenter round-trip dominates&lt;/strong&gt; — 500μs is 5,000x slower than a RAM access&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../performance-vs-scalability&quot; class=&quot;internal alias&quot; data-slug=&quot;performance-vs-scalability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Performance vs Scalability&lt;/a&gt; — estimates quantify both dimensions: latency measures performance, throughput measures scalability&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../latency-vs-throughput&quot; class=&quot;internal alias&quot; data-slug=&quot;latency-vs-throughput&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Latency vs Throughput&lt;/a&gt; — estimates use latency numbers to compute throughput bounds&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — estimates determine how many nodes are needed to achieve target throughput&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../availability-nines&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-nines&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability Nines&lt;/a&gt; — estimates help calculate uptime requirements and redundant capacity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — latency estimates reveal when caching is necessary (disk reads at 10ms vs cache at 100ns)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Orders of magnitude matter, exact numbers don’t&lt;/strong&gt; — if your estimate is off by 2x, that’s fine; if it’s off by 100x, the design is likely infeasible.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Latency numbers are for the median&lt;/strong&gt; — p99 latency can be 10-100x worse due to GC pauses, network jitter, and queueing; always add headroom.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Throughput ≠ latency&lt;/strong&gt; — a system can handle 10K QPS (good throughput) but have 500ms p99 latency (bad); estimate both independently.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>back-pressure</title>
    <link href="https://animishraa05.github.io/wiki/system-design/back-pressure" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/back-pressure.md" />
    <summary>The Problem Unbounded queue growth under high load causes memory exhaustion, increased cache misses, and eventual system collapse.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="messaging" label="messaging" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Unbounded queue growth under high load causes memory exhaustion, increased cache misses, and eventual system collapse. Without limits, backlog accumulates faster than workers can drain it.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Back pressure limits the size of a queue to maintain throughput and response times for already-accepted work. When the queue reaches its configured capacity, new requests are rejected — typically with HTTP 503 (Service Unavailable) — and clients retry with exponential backoff.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Set a maximum queue size based on memory and throughput constraints.&lt;/li&gt;
&lt;li&gt;When the queue reaches this limit, reject new incoming requests.&lt;/li&gt;
&lt;li&gt;Return HTTP 503 Service Unavailable to the client.&lt;/li&gt;
&lt;li&gt;Client retries using exponential backoff (1s, 2s, 4s, 8s… with jitter).&lt;/li&gt;
&lt;li&gt;Throughput for already-queued jobs is preserved — the system degrades gracefully instead of collapsing.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: BackPressure Pages: 1 --&gt;
&lt;svg width=&quot;539pt&quot; height=&quot;121pt&quot; viewBox=&quot;0.00 0.00 539.00 121.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 116.57)&quot;&gt;
&lt;title&gt;BackPressure&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-116.57 534.66,-116.57 534.66,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M60.89,-73.97C60.89,-73.97 30.89,-73.97 30.89,-73.97 24.89,-73.97 18.89,-67.97 18.89,-61.97 18.89,-61.97 18.89,-49.97 18.89,-49.97 18.89,-43.97 24.89,-37.97 30.89,-37.97 30.89,-37.97 60.89,-37.97 60.89,-37.97 66.89,-37.97 72.89,-43.97 72.89,-49.97 72.89,-49.97 72.89,-61.97 72.89,-61.97 72.89,-67.97 66.89,-73.97 60.89,-73.97&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;45.89&quot; y=&quot;-51.77&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M27.22,-74.13C24.35,-83.51 30.57,-91.97 45.89,-91.97 54.5,-91.97 60.24,-89.3 63.1,-85.28&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;66.54,-86 64.36,-75.63 59.6,-85.09 66.54,-86&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;45.89&quot; y=&quot;-96.17&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1s, 2s, 4s... retry&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Queue&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M315.18,-75.77C315.18,-75.77 249.22,-75.77 249.22,-75.77 243.22,-75.77 237.22,-69.77 237.22,-63.77 237.22,-63.77 237.22,-46.17 237.22,-46.17 237.22,-40.17 243.22,-34.17 249.22,-34.17 249.22,-34.17 315.18,-34.17 315.18,-34.17 321.18,-34.17 327.18,-40.17 327.18,-46.17 327.18,-46.17 327.18,-63.77 327.18,-63.77 327.18,-69.77 321.18,-75.77 315.18,-75.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;282.2&quot; y=&quot;-59.17&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Queue&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;282.2&quot; y=&quot;-42.37&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(capacity=N)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;Queue --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;Queue&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M73.32,-42.66C78.98,-40.38 85.03,-38.37 90.89,-37.17 141.55,-26.8 155.89,-31.08 207.25,-37.17 213.31,-37.89 219.6,-38.93 225.83,-40.16&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;224.94,-43.54 235.45,-42.21 226.4,-36.7 224.94,-43.54&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;149.07&quot; y=&quot;-41.37&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Request (queue &amp;#x3C; N)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;Queue --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;Queue&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M73.31,-55.86C110.02,-55.7 177.35,-55.42 225.44,-55.21&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;225.42,-58.71 235.4,-55.17 225.39,-51.71 225.42,-58.71&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;149.07&quot; y=&quot;-59.98&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Request (queue = N)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Worker --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Worker&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M491.67,-105.97C491.67,-105.97 456.91,-105.97 456.91,-105.97 450.91,-105.97 444.91,-99.97 444.91,-93.97 444.91,-93.97 444.91,-81.97 444.91,-81.97 444.91,-75.97 450.91,-69.97 456.91,-69.97 456.91,-69.97 491.67,-69.97 491.67,-69.97 497.67,-69.97 503.67,-75.97 503.67,-81.97 503.67,-81.97 503.67,-93.97 503.67,-93.97 503.67,-99.97 497.67,-105.97 491.67,-105.97&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;474.29&quot; y=&quot;-83.77&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Worker&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Worker --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Worker&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M327.29,-62.63C359.28,-68.18 402.22,-75.64 433.24,-81.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;432.55,-84.45 443.01,-82.72 433.75,-77.56 432.55,-84.45&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;378.53&quot; y=&quot;-78.63&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Process&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Reject --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Reject&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M530.66,-22.49C530.66,-22.49 530.66,-27.46 530.66,-27.46 530.66,-29.94 528.29,-33.19 525.92,-33.94 525.92,-33.94 502.37,-41.46 502.37,-41.46 500.01,-42.22 495.15,-42.97 492.67,-42.97 492.67,-42.97 455.91,-42.97 455.91,-42.97 453.43,-42.97 448.57,-42.22 446.21,-41.46 446.21,-41.46 422.66,-33.94 422.66,-33.94 420.29,-33.19 417.92,-29.94 417.92,-27.46 417.92,-27.46 417.92,-22.49 417.92,-22.49 417.92,-20 420.29,-16.76 422.66,-16.01 422.66,-16.01 446.21,-8.49 446.21,-8.49 448.57,-7.73 453.43,-6.97 455.91,-6.97 455.91,-6.97 492.67,-6.97 492.67,-6.97 495.15,-6.97 500.01,-7.73 502.37,-8.49 502.37,-8.49 525.92,-16.01 525.92,-16.01 528.29,-16.76 530.66,-20 530.66,-22.49&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;474.29&quot; y=&quot;-20.77&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;HTTP 503&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Reject --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Reject&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M327.65,-44.81C337.35,-42.78 347.57,-40.78 357.15,-39.17 373.1,-36.5 390.36,-34.12 406.58,-32.1&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;406.6,-35.62 416.11,-30.95 405.76,-28.67 406.6,-35.62&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;378.53&quot; y=&quot;-43.37&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Reject&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Worker&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Worker-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M444.76,-91.33C431.2,-92.76 414.75,-94.27 399.92,-94.97 380.93,-95.88 376.15,-95.62 357.15,-94.97 238.61,-90.97 205.62,-107.05 90.89,-76.97 88.58,-76.37 86.26,-75.65 83.94,-74.83&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;85.25,-71.59 74.67,-71.1 82.63,-78.08 85.25,-71.59&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;282.2&quot; y=&quot;-99.97&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Response&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Reject&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Reject-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M419.26,-16.65C394.86,-13.29 365.62,-9.82 339.15,-8.17 228.71,-1.28 194.41,12.1 90.89,-26.97 87.27,-28.34 83.64,-30.05 80.11,-31.94&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;78.61,-28.77 71.81,-36.89 82.19,-34.78 78.61,-28.77&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;282.2&quot; y=&quot;-12.37&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Exponential backoff&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Prevents memory exhaustion from unbounded queue growth&lt;/li&gt;
&lt;li&gt;Maintains throughput for jobs already accepted into the queue&lt;/li&gt;
&lt;li&gt;Rejected clients receive well-defined HTTP 503 responses&lt;/li&gt;
&lt;li&gt;Exponential backoff with jitter prevents thundering herd on retry&lt;/li&gt;
&lt;li&gt;Preserves overall system stability by shedding load at the boundary&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — back pressure protects message queues from overload&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../task-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;task-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Task Queues&lt;/a&gt; — back pressure prevents task queues from growing unboundedly&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../latency-vs-throughput&quot; class=&quot;internal alias&quot; data-slug=&quot;latency-vs-throughput&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Latency vs Throughput&lt;/a&gt; — back pressure maintains stable throughput by rejecting excess load&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — sustained back pressure is a signal to scale out the worker pool&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Retry storms&lt;/strong&gt;: Without jitter, all clients retry simultaneously, creating a thundering herd on the queue. Always add random jitter to backoff intervals.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Queue sizing&lt;/strong&gt;: Too small a queue underutilizes workers; too large defeats the purpose. Size based on expected worker drain rate and acceptable latency.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No back pressure on workers&lt;/strong&gt;: If workers themselves slow down (e.g., due to DB contention), back pressure at the queue level doesn’t protect upstream resources.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>cache-aside</title>
    <link href="https://animishraa05.github.io/wiki/system-design/cache-aside" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/cache-aside.md" />
    <summary>The Problem Databases are slow for frequently accessed data.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="caching" label="caching" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Databases are slow for frequently accessed data. Pre-loading all possible data into cache proactively wastes memory and is impractical at scale.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Cache-aside (lazy loading) puts the application in charge of the cache — it loads data into cache on demand only when a cache miss occurs. The application checks the cache first, falls back to the database on a miss, and populates the cache for subsequent reads.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Application checks cache for the requested entry.&lt;/li&gt;
&lt;li&gt;If found (cache hit), return the data immediately.&lt;/li&gt;
&lt;li&gt;If not found (cache miss), load the data from the database.&lt;/li&gt;
&lt;li&gt;Store the retrieved data in the cache with a TTL.&lt;/li&gt;
&lt;li&gt;Return the data to the caller.&lt;/li&gt;
&lt;li&gt;Subsequent requests for the same key will hit the cache until the TTL expires.&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;Memcached is typically used in this pattern. Only data that is actually requested ends up in the cache.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: CacheAside Pages: 1 --&gt;
&lt;svg width=&quot;358pt&quot; height=&quot;322pt&quot; viewBox=&quot;0.00 0.00 358.00 322.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 318.34)&quot;&gt;
&lt;title&gt;CacheAside&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-318.34 353.83,-318.34 353.83,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M70.1,-176.92C70.1,-176.92 12,-176.92 12,-176.92 6,-176.92 0,-170.92 0,-164.92 0,-164.92 0,-152.92 0,-152.92 0,-146.92 6,-140.92 12,-140.92 12,-140.92 70.1,-140.92 70.1,-140.92 76.1,-140.92 82.1,-146.92 82.1,-152.92 82.1,-152.92 82.1,-164.92 82.1,-164.92 82.1,-170.92 76.1,-176.92 70.1,-176.92&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.05&quot; y=&quot;-154.72&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Application&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M337.83,-239.72C337.83,-239.72 268.1,-239.72 268.1,-239.72 262.1,-239.72 256.1,-233.72 256.1,-227.72 256.1,-227.72 256.1,-210.12 256.1,-210.12 256.1,-204.12 262.1,-198.12 268.1,-198.12 268.1,-198.12 337.83,-198.12 337.83,-198.12 343.83,-198.12 349.83,-204.12 349.83,-210.12 349.83,-210.12 349.83,-227.72 349.83,-227.72 349.83,-233.72 343.83,-239.72 337.83,-239.72&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;302.97&quot; y=&quot;-223.12&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Cache&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;302.97&quot; y=&quot;-206.32&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Memcached)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M44.95,-177.3C50.36,-204.58 64.82,-254.96 100.1,-276.92 152.17,-309.34 180.89,-299.02 238.1,-276.92 253.35,-271.03 267.21,-259.61 278.09,-248.46&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;280.58,-250.92 284.78,-241.19 275.43,-246.18 280.58,-250.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-301.74&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Read(key)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M49.57,-177.09C58.49,-195.98 75.36,-224.49 100.1,-236.92 144.98,-259.47 202.57,-251.27 244.75,-239.61&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;245.59,-243.01 254.21,-236.84 243.63,-236.29 245.59,-243.01&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-255.37&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Read(key) — MISS&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M64.71,-177.34C74.93,-184.67 87.51,-192.41 100.1,-196.92 125.81,-206.13 194.34,-212.25 244.44,-215.65&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;244.06,-219.13 254.27,-216.29 244.52,-212.15 244.06,-219.13&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-219.41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;7. Write(key, data)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M324.62,-103.92C324.62,-103.92 281.31,-103.92 281.31,-103.92 275.31,-103.92 269.31,-97.92 269.31,-91.92 269.31,-91.92 269.31,-79.92 269.31,-79.92 269.31,-73.92 275.31,-67.92 281.31,-67.92 281.31,-67.92 324.62,-67.92 324.62,-67.92 330.62,-67.92 336.62,-73.92 336.62,-79.92 336.62,-79.92 336.62,-91.92 336.62,-91.92 336.62,-97.92 330.62,-103.92 324.62,-103.92&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;302.97&quot; y=&quot;-81.72&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Database&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;DB --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M55.88,-140.54C66.48,-127.96 82.28,-112.15 100.1,-104.12 150.54,-81.4 215.16,-79.72 257.52,-81.81&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;257.15,-85.29 267.34,-82.39 257.57,-78.3 257.15,-85.29&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-108.32&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. SELECT ...&lt;/text&gt;
&lt;/g&gt;
&lt;!-- User --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;User&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M317.97,-36.92C317.97,-36.92 287.97,-36.92 287.97,-36.92 281.97,-36.92 275.97,-30.92 275.97,-24.92 275.97,-24.92 275.97,-12.92 275.97,-12.92 275.97,-6.92 281.97,-0.92 287.97,-0.92 287.97,-0.92 317.97,-0.92 317.97,-0.92 323.97,-0.92 329.97,-6.92 329.97,-12.92 329.97,-12.92 329.97,-24.92 329.97,-24.92 329.97,-30.92 323.97,-36.92 317.97,-36.92&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;302.97&quot; y=&quot;-14.72&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;User&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;User --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;User&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M43.83,-140.64C47.85,-110.44 60.64,-50.83 100.1,-24.12 149.03,9 221.04,0.76 264.52,-8.73&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;263.71,-12.14 274.25,-11 265.3,-5.32 263.71,-12.14&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-28.32&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;8. Return data&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M273.09,-197.69C262.57,-190.98 250.26,-184.24 238.1,-180.12 191.03,-164.17 134.3,-159.49 94,-158.43&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;94.15,-154.93 84.09,-158.24 94.02,-161.93 94.15,-154.93&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-184.32&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Cache Hit: return data&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M292.23,-197.88C281.9,-178.33 263.53,-150.43 238.1,-138.12 192.67,-116.12 134.52,-126.37 93.38,-139.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.39,-135.66 83.96,-142.07 94.55,-142.32 92.39,-135.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-142.32&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. null&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DB-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M269.16,-70.12C227.11,-52.35 153.3,-29.67 100.1,-60.12 74.13,-74.98 58.64,-106.48 50.28,-129.94&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;47.01,-128.67 47.2,-139.26 53.66,-130.86 47.01,-128.67&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.1&quot; y=&quot;-64.32&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Result Set&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Application manages cache lifecycle explicitly&lt;/li&gt;
&lt;li&gt;Lazy loading — only requested data is cached (on-demand)&lt;/li&gt;
&lt;li&gt;Cache does not interact with the database directly&lt;/li&gt;
&lt;li&gt;Each cache miss costs 3 round trips (check cache, load DB, write cache)&lt;/li&gt;
&lt;li&gt;Avoids filling cache with unused data, keeping memory efficient&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../write-through-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-through-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Through Cache&lt;/a&gt; — lazy vs eager write&lt;/li&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../write-behind-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-behind-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Behind Cache&lt;/a&gt; — synchronous vs async write&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../cdn-pull&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-pull&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Pull CDN&lt;/a&gt; — similar on-demand pull pattern&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../refresh-ahead-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;refresh-ahead-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Refresh-Ahead Cache&lt;/a&gt; — proactive vs reactive refresh&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Cache stampede&lt;/strong&gt;: If many requests miss simultaneously (e.g., after TTL expiry), all hit the database at once. Mitigate with mutex locks or early recomputation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stale data&lt;/strong&gt;: If the database is updated directly (bypassing cache), the cache serves stale data until TTL expiry.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Thundering herd&lt;/strong&gt;: A popular key’s TTL expiry can trigger a database overload from concurrent misses.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>cap-theorem</title>
    <link href="https://animishraa05.github.io/wiki/system-design/cap-theorem" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/cap-theorem.md" />
    <summary>The Problem Distributed systems must handle network partitions (when nodes cannot communicate).</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="distributed-systems" label="distributed-systems" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Distributed systems must handle network partitions (when nodes cannot communicate). Designers need a framework to reason about what properties a distributed system can guarantee under such failures.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The CAP Theorem states that a distributed data store can simultaneously provide at most two of three guarantees: &lt;strong&gt;Consistency&lt;/strong&gt; (every read receives the most recent write or an error), &lt;strong&gt;Availability&lt;/strong&gt; (every request receives a non-error response), and &lt;strong&gt;Partition Tolerance&lt;/strong&gt; (the system continues operating despite arbitrary network failures). Since network partitions are inevitable, designers effectively choose between CP (Consistency + Partition Tolerance) and AP (Availability + Partition Tolerance).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Normal operation&lt;/strong&gt;: All three properties are satisfied — nodes communicate, reads are consistent, responses are returned.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partition occurs&lt;/strong&gt;: Network failure splits nodes into groups that cannot communicate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CP choice&lt;/strong&gt;: The system refuses responses from nodes that cannot be confirmed as consistent — returns errors or timeouts until the partition heals.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AP choice&lt;/strong&gt;: The system returns whatever data is available from reachable nodes, accepting that data may be stale. Writes are queued and merged when the partition resolves.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;671pt&quot; height=&quot;292pt&quot; viewBox=&quot;0.00 0.00 671.00 292.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 288)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-288 667,-288 667,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_choices&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-162.4 655,-162.4 655,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;331.5&quot; y=&quot;-145.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Choose 2 of 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- cap --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;cap&lt;/title&gt;
&lt;ellipse fill=&quot;gold&quot; stroke=&quot;black&quot; cx=&quot;344&quot; cy=&quot;-188.4&quot; rx=&quot;67.09&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;344&quot; y=&quot;-184.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CAP Theorem&lt;/text&gt;
&lt;/g&gt;
&lt;!-- cp --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;cp&lt;/title&gt;
&lt;polygon fill=&quot;lightcoral&quot; stroke=&quot;black&quot; points=&quot;223,-129.6 169,-129.6 169,-93.6 223,-93.6 223,-129.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;196&quot; y=&quot;-107.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CP&lt;/text&gt;
&lt;/g&gt;
&lt;!-- cap&amp;#45;&amp;gt;cp --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;cap-&gt;cp&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M313.69,-172.08C290.46,-160.34 258.27,-144.07 233.43,-131.52&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;235.13,-128.46 224.63,-127.07 231.97,-134.7 235.13,-128.46&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- ap --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ap&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;371,-129.6 317,-129.6 317,-93.6 371,-93.6 371,-129.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;344&quot; y=&quot;-107.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;AP&lt;/text&gt;
&lt;/g&gt;
&lt;!-- cap&amp;#45;&amp;gt;ap --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;cap-&gt;ap&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M344,-170.05C344,-161.46 344,-150.87 344,-141.12&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;347.5,-141.37 344,-131.37 340.5,-141.37 347.5,-141.37&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- ca --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ca&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;557.99,-129.6 444.01,-129.6 444.01,-93.6 557.99,-93.6 557.99,-129.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;501&quot; y=&quot;-107.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CA (not realistic)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- cap&amp;#45;&amp;gt;ca --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;cap-&gt;ca&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M375.77,-172.26C398.29,-161.53 428.89,-146.96 454.2,-134.9&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;455.43,-138.19 462.95,-130.73 452.42,-131.87 455.43,-138.19&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- cp_desc --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;cp_desc&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;217.51,-57.6 16.49,-57.6 16.49,-16 223.51,-16 223.51,-51.6 217.51,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;217.51,-57.6 217.51,-51.6&quot;&gt;&lt;/polyline&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;223.51,-51.6 217.51,-51.6&quot;&gt;&lt;/polyline&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;120&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Banking&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;120&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Consistency + Partition Tolerance&lt;/text&gt;
&lt;/g&gt;
&lt;!-- cp&amp;#45;&amp;gt;cp_desc --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;cp-&gt;cp_desc&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M177.99,-93.35C169.43,-85.15 158.99,-75.15 149.33,-65.9&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;151.85,-63.46 142.21,-59.07 147.01,-68.52 151.85,-63.46&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- ap_desc --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ap_desc&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;440.73,-57.6 241.27,-57.6 241.27,-16 446.73,-16 446.73,-51.6 440.73,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;440.73,-57.6 440.73,-51.6&quot;&gt;&lt;/polyline&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;446.73,-51.6 440.73,-51.6&quot;&gt;&lt;/polyline&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;344&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Social Media&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;344&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Availability + Partition Tolerance&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ap&amp;#45;&amp;gt;ap_desc --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ap-&gt;ap_desc&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M344,-93.35C344,-86.15 344,-77.55 344,-69.29&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;347.5,-69.54 344,-59.54 340.5,-69.54 347.5,-69.54&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- ca_desc --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ca_desc&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;641.01,-57.6 464.99,-57.6 464.99,-16 647.01,-16 647.01,-51.6 641.01,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;641.01,-57.6 641.01,-51.6&quot;&gt;&lt;/polyline&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;647.01,-51.6 641.01,-51.6&quot;&gt;&lt;/polyline&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;556&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Single-node systems&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;556&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(few real distributed systems)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ca&amp;#45;&amp;gt;ca_desc --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ca-&gt;ca_desc&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M514.03,-93.35C519.98,-85.48 527.18,-75.95 533.92,-67.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;536.57,-69.32 539.81,-59.24 530.99,-65.1 536.57,-69.32&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- consistency --&gt;
&lt;g id=&quot;node8&quot; class=&quot;node&quot;&gt;
&lt;title&gt;consistency&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M223.08,-284C223.08,-284 84.92,-284 84.92,-284 78.92,-284 72.92,-278 72.92,-272 72.92,-272 72.92,-254.4 72.92,-254.4 72.92,-248.4 78.92,-242.4 84.92,-242.4 84.92,-242.4 223.08,-242.4 223.08,-242.4 229.08,-242.4 235.08,-248.4 235.08,-254.4 235.08,-254.4 235.08,-272 235.08,-272 235.08,-278 229.08,-284 223.08,-284&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;154&quot; y=&quot;-267.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Consistency (C)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;154&quot; y=&quot;-250.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Latest write on every read&lt;/text&gt;
&lt;/g&gt;
&lt;!-- consistency&amp;#45;&amp;gt;cap --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;consistency-&gt;cap&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M206.93,-241.92C234.94,-231.19 269.07,-218.11 296.27,-207.69&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;297.2,-211.08 305.29,-204.23 294.7,-204.54 297.2,-211.08&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- availability --&gt;
&lt;g id=&quot;node9&quot; class=&quot;node&quot;&gt;
&lt;title&gt;availability&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M422.8,-284C422.8,-284 265.2,-284 265.2,-284 259.2,-284 253.2,-278 253.2,-272 253.2,-272 253.2,-254.4 253.2,-254.4 253.2,-248.4 259.2,-242.4 265.2,-242.4 265.2,-242.4 422.8,-242.4 422.8,-242.4 428.8,-242.4 434.8,-248.4 434.8,-254.4 434.8,-254.4 434.8,-272 434.8,-272 434.8,-278 428.8,-284 422.8,-284&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;344&quot; y=&quot;-267.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Availability (A)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;344&quot; y=&quot;-250.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Every request gets a response&lt;/text&gt;
&lt;/g&gt;
&lt;!-- availability&amp;#45;&amp;gt;cap --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;availability-&gt;cap&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M344,-241.92C344,-234.55 344,-226.06 344,-218.1&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;347.5,-218.13 344,-208.13 340.5,-218.13 347.5,-218.13&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- partition --&gt;
&lt;g id=&quot;node10&quot; class=&quot;node&quot;&gt;
&lt;title&gt;partition&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M644.88,-284C644.88,-284 465.12,-284 465.12,-284 459.12,-284 453.12,-278 453.12,-272 453.12,-272 453.12,-254.4 453.12,-254.4 453.12,-248.4 459.12,-242.4 465.12,-242.4 465.12,-242.4 644.88,-242.4 644.88,-242.4 650.88,-242.4 656.88,-248.4 656.88,-254.4 656.88,-254.4 656.88,-272 656.88,-272 656.88,-278 650.88,-284 644.88,-284&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;555&quot; y=&quot;-267.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Partition Tolerance (P)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;555&quot; y=&quot;-250.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Operates despite network failures&lt;/text&gt;
&lt;/g&gt;
&lt;!-- partition&amp;#45;&amp;gt;cap --&gt;
&lt;g id=&quot;edge9&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;partition-&gt;cap&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M496.22,-241.92C464.4,-230.94 425.48,-217.51 394.95,-206.98&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;396.14,-203.69 385.55,-203.73 393.86,-210.3 396.14,-203.69&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;C (Consistency)&lt;/strong&gt;: Every read receives the most recent write or an error&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A (Availability)&lt;/strong&gt;: Every request receives a (non-error) response, without guarantee it contains the latest write&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;P (Partition Tolerance)&lt;/strong&gt;: The system continues to function despite network partitions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;P is mandatory in distributed systems&lt;/strong&gt; — networks are unreliable by nature&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CA is a theoretical option&lt;/strong&gt; that only applies to single-node systems or systems that can guarantee no network faults&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../cp-consistency-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;cp-consistency-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CP — Consistency and Partition Tolerance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../ap-availability-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;ap-availability-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;AP — Availability and Partition Tolerance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../strong-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;strong-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Strong Consistency&lt;/a&gt; — guaranteed in CP systems&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../eventual-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;eventual-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Eventual Consistency&lt;/a&gt; — used in AP systems&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;PACELC extension&lt;/strong&gt;: CAP only considers partitions. PACELC adds that even without a partition (Else), there’s a latency-consistency trade-off. Most systems don’t operate in partition mode.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CA is misleading&lt;/strong&gt;: Single-node systems aren’t distributed. Therefore, real distributed systems are either CP or AP.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partition recovery is not automatic&lt;/strong&gt;: When a partition heals, reconciliation logic is needed — stale writes may conflict, and resolution strategies (last-write-wins, CRDTs, etc.) must be in place.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>cdn-pull</title>
    <link href="https://animishraa05.github.io/wiki/system-design/cdn-pull" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/cdn-pull.md" />
    <summary>The Problem Pre-pushing all content to a CDN is wasteful if much of the content is rarely accessed, filling CDN storage with cold data.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="infrastructure" label="infrastructure" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Pre-pushing all content to a CDN is wasteful if much of the content is rarely accessed, filling CDN storage with cold data.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Pull CDNs grab content from the origin server on the first user request, cache it at the edge with a TTL, and serve subsequent requests from cache.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;A user requests content that is not yet cached at the nearest CDN edge.&lt;/li&gt;
&lt;li&gt;The CDN edge pulls the content from the origin server.&lt;/li&gt;
&lt;li&gt;The edge caches the content and serves it to the user.&lt;/li&gt;
&lt;li&gt;Subsequent requests for the same content are served directly from the edge cache.&lt;/li&gt;
&lt;li&gt;The cached content expires based on its TTL or is evicted by a cache replacement policy.&lt;/li&gt;
&lt;li&gt;Best suited for high-traffic sites with long-tail content access patterns.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;digraph pull_cdn {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  rankdir=LR&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  node [shape=box style=filled fillcolor=&quot;#f0f4ff&quot; fontname=&quot;Helvetica&quot; fontsize=12]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  edge [fontname=&quot;Helvetica&quot; fontsize=10]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  USER1 [label=&quot;First User Request&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  USER2 [label=&quot;Subsequent Users&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  EDGE [label=&quot;CDN Edge Node&quot; fillcolor=&quot;#d4edda&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  ORIGIN [label=&quot;Origin Server&quot; fillcolor=&quot;#ffe5cc&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  USER1 -&gt; EDGE [label=&quot;cache miss&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  EDGE -&gt; ORIGIN [label=&quot;pull from origin&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  ORIGIN -&gt; EDGE [label=&quot;serve content&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  EDGE -&gt; USER1 [label=&quot;serve &amp;#x26; cache&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  USER2 -&gt; EDGE [label=&quot;cache hit&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  EDGE -&gt; USER2 [label=&quot;serve from cache&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;First-request-triggered caching — content is pulled on demand&lt;/li&gt;
&lt;li&gt;TTL-based expiration controls how long content stays cached&lt;/li&gt;
&lt;li&gt;Minimizes CDN storage costs — only accessed content is stored&lt;/li&gt;
&lt;li&gt;Slower first request (cache miss penalty) vs fast subsequent requests&lt;/li&gt;
&lt;li&gt;Best suited for high-traffic sites with diverse content&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../cdn-push&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-push&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Push CDN&lt;/a&gt; — lazy-pull vs proactive-push content delivery&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../dns-system-design&quot; class=&quot;internal alias&quot; data-slug=&quot;dns-system-design&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DNS in System Design&lt;/a&gt; — DNS routing directs users to the CDN edge&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — pull CDN follows the same lazy-loading pattern as cache-aside&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy&lt;/a&gt; — pull CDN is a geographically distributed reverse proxy&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Thundering herd problem: if popular content expires simultaneously, a flood of origin requests hits the server&lt;/li&gt;
&lt;li&gt;Pull CDNs contribute to origin traffic on first access — large content (videos) causes significant origin load on first requests&lt;/li&gt;
&lt;li&gt;TTL tuning is critical — too short defeats caching, too long serves stale content&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>cdn-push</title>
    <link href="https://animishraa05.github.io/wiki/system-design/cdn-push" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/cdn-push.md" />
    <summary>The Problem Serving all content from a single origin server creates latency for distant users and places heavy load on the origin infrastructure.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="infrastructure" label="infrastructure" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Serving all content from a single origin server creates latency for distant users and places heavy load on the origin infrastructure.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Push CDNs receive new content whenever changes occur on the server — the server proactively uploads content to the CDN edge nodes.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;When content is created or updated on the origin server, the server uploads it to the CDN.&lt;/li&gt;
&lt;li&gt;The CDN distributes the content to its edge nodes worldwide.&lt;/li&gt;
&lt;li&gt;URLs in the application are rewritten to point to the CDN endpoint.&lt;/li&gt;
&lt;li&gt;User requests hit the nearest CDN edge, which serves the pre-pushed content.&lt;/li&gt;
&lt;li&gt;Content expires from the CDN based on a configured TTL or is explicitly invalidated.&lt;/li&gt;
&lt;li&gt;Best suited for sites with low traffic or content that changes infrequently.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: push_cdn Pages: 1 --&gt;
&lt;svg width=&quot;590pt&quot; height=&quot;118pt&quot; viewBox=&quot;0.00 0.00 590.00 118.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 114.09)&quot;&gt;
&lt;title&gt;push_cdn&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-114.09 586.13,-114.09 586.13,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- ORIGIN --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ORIGIN&lt;/title&gt;
&lt;polygon fill=&quot;#ffe5cc&quot; stroke=&quot;black&quot; points=&quot;86.69,-78.11 0,-78.11 0,-42.11 86.69,-42.11 86.69,-78.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;43.34&quot; y=&quot;-56.51&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Origin Server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CDN --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CDN&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;340.82,-78.11 229.44,-78.11 229.44,-42.11 340.82,-42.11 340.82,-78.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;285.13&quot; y=&quot;-56.51&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;CDN Edge Nodes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ORIGIN&amp;#45;&amp;gt;CDN --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ORIGIN-&gt;CDN&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M86.94,-60.11C123.23,-60.11 175.99,-60.11 217.8,-60.11&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;217.77,-63.61 227.77,-60.11 217.77,-56.61 217.77,-63.61&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;158.06&quot; y=&quot;-63.11&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;push content on change&lt;/text&gt;
&lt;/g&gt;
&lt;!-- USER1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;USER1&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;574.45,-109.11 498.45,-109.11 498.45,-73.11 574.45,-73.11 574.45,-109.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;536.45&quot; y=&quot;-87.51&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;User (Asia)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CDN&amp;#45;&amp;gt;USER1 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CDN-&gt;USER1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M321.44,-78.54C333.03,-83.66 346.18,-88.53 358.82,-91.11 401.52,-99.83 451.24,-98.87 487.04,-96.29&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;486.94,-99.81 496.63,-95.52 486.38,-92.83 486.94,-99.81&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;415.79&quot; y=&quot;-101.09&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;cached content&lt;/text&gt;
&lt;/g&gt;
&lt;!-- USER2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;USER2&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;582.13,-47.11 490.77,-47.11 490.77,-11.11 582.13,-11.11 582.13,-47.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;536.45&quot; y=&quot;-25.51&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;User (Europe)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CDN&amp;#45;&amp;gt;USER2 --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CDN-&gt;USER2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M341.28,-52.41C347.2,-51.62 353.13,-50.84 358.82,-50.11 399,-44.96 444.37,-39.57 479.07,-35.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;479.37,-39.03 488.91,-34.4 478.57,-32.08 479.37,-39.03&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;415.79&quot; y=&quot;-53.11&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;cached content&lt;/text&gt;
&lt;/g&gt;
&lt;!-- USER1&amp;#45;&amp;gt;CDN --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;USER1-&gt;CDN&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M498.09,-83.4C489.78,-81.84 480.99,-80.31 472.77,-79.11 432.93,-73.28 388.05,-68.65 352.28,-65.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;352.78,-61.95 342.51,-64.55 352.16,-68.92 352.78,-61.95&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;415.79&quot; y=&quot;-82.11&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;request served from edge&lt;/text&gt;
&lt;/g&gt;
&lt;!-- USER2&amp;#45;&amp;gt;CDN --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;USER2-&gt;CDN&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M490.31,-12.9C484.48,-11.34 478.53,-10 472.77,-9.11 422.73,-1.32 407.11,6.14 358.82,-9.11 342.5,-14.26 326.66,-24.54 313.95,-34.53&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;311.95,-31.65 306.46,-40.71 316.4,-37.05 311.95,-31.65&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;415.79&quot; y=&quot;-12.11&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;request served from edge&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Server-initiated content push — origin decides what to upload&lt;/li&gt;
&lt;li&gt;Full responsibility for content distribution lies with the origin server&lt;/li&gt;
&lt;li&gt;Content is uploaded only when it changes (not on every request)&lt;/li&gt;
&lt;li&gt;Minimizes origin traffic but may waste CDN storage for rarely accessed content&lt;/li&gt;
&lt;li&gt;Best suited for low-traffic sites or content with predictable access patterns&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../cdn-pull&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-pull&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Pull CDN&lt;/a&gt; — server-push vs lazy-pull content delivery strategies&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../dns-system-design&quot; class=&quot;internal alias&quot; data-slug=&quot;dns-system-design&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DNS in System Design&lt;/a&gt; — DNS directs clients to the nearest CDN edge&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy&lt;/a&gt; — both serve cached content closer to users&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Cache invalidation is difficult — if content needs to be removed, you must explicitly purge it from all CDN edges&lt;/li&gt;
&lt;li&gt;Pushing content that nobody ever requests wastes CDN storage&lt;/li&gt;
&lt;li&gt;If the push mechanism fails, stale content remains served until manually invalidated&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>cp-consistency-partition-tolerance</title>
    <link href="https://animishraa05.github.io/wiki/system-design/cp-consistency-partition-tolerance" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/cp-consistency-partition-tolerance.md" />
    <summary>The Problem When a network partition occurs, the system must decide whether to return potentially stale data or refuse to respond.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="distributed-systems" label="distributed-systems" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;When a network partition occurs, the system must decide whether to return potentially stale data or refuse to respond. Applications like banking and inventory management cannot tolerate stale reads.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;CP systems choose consistency over availability during network partitions. When nodes cannot verify they have the latest data, the system returns errors or times out rather than serving stale data. Consistency is guaranteed at all times, but availability is sacrificed during partitions.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Pre-partition&lt;/strong&gt;: All nodes agree on the latest write. Reads go to any node and return the same value. Writes must be acknowledged by a majority/quorum before the client receives confirmation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partition occurs&lt;/strong&gt;: A subset of nodes becomes unreachable. The reachable nodes cannot confirm whether the isolated nodes have accepted a newer write.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reject to be safe&lt;/strong&gt;: The reachable nodes refuse reads (return error or timeout) because they cannot guarantee the returned value is the most recent write.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partition heals&lt;/strong&gt;: Nodes re-establish communication. Reconciliation replays any writes that were accepted by the isolated minority. The system resumes full operation.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;855pt&quot; height=&quot;278pt&quot; viewBox=&quot;0.00 0.00 855.00 278.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 274.4)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-274.4 850.82,-274.4 850.82,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_normal&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-262.4 266,-262.4 266,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;137&quot; y=&quot;-245.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Normal Operation&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust4&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_partition&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;274,-8 274,-262.4 533,-262.4 533,-8 274,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;403.5&quot; y=&quot;-245.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;During Partition&lt;/text&gt;
&lt;/g&gt;
&lt;!-- client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M222.04,-229.6C222.04,-229.6 65.96,-229.6 65.96,-229.6 59.96,-229.6 53.96,-223.6 53.96,-217.6 53.96,-217.6 53.96,-205.6 53.96,-205.6 53.96,-199.6 59.96,-193.6 65.96,-193.6 65.96,-193.6 222.04,-193.6 222.04,-193.6 228.04,-193.6 234.04,-199.6 234.04,-205.6 234.04,-205.6 234.04,-217.6 234.04,-217.6 234.04,-223.6 228.04,-229.6 222.04,-229.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;144&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client Write w/ Quorum Ack&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M181.38,-140.8C181.38,-140.8 90.62,-140.8 90.62,-140.8 84.62,-140.8 78.62,-134.8 78.62,-128.8 78.62,-128.8 78.62,-116.8 78.62,-116.8 78.62,-110.8 84.62,-104.8 90.62,-104.8 90.62,-104.8 181.38,-104.8 181.38,-104.8 187.38,-104.8 193.38,-110.8 193.38,-116.8 193.38,-116.8 193.38,-128.8 193.38,-128.8 193.38,-134.8 187.38,-140.8 181.38,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;136&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 1 (Primary)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- client&amp;#45;&amp;gt;n1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;client-&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M134.92,-193.25C132.5,-187.75 130.22,-181.56 129,-175.6 127.47,-168.13 127.69,-159.99 128.69,-152.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;132.12,-153.12 130.48,-142.65 125.23,-151.86 132.12,-153.12&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- n1&amp;#45;&amp;gt;client --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1-&gt;client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M137.6,-141.21C138.69,-152.96 140.14,-168.74 141.39,-182.28&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;137.88,-182.31 142.28,-191.94 144.85,-181.66 137.88,-182.31&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;161.71&quot; y=&quot;-163&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;success&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M116.2,-52C116.2,-52 27.8,-52 27.8,-52 21.8,-52 15.8,-46 15.8,-40 15.8,-40 15.8,-28 15.8,-28 15.8,-22 21.8,-16 27.8,-16 27.8,-16 116.2,-16 116.2,-16 122.2,-16 128.2,-22 128.2,-28 128.2,-28 128.2,-40 128.2,-40 128.2,-46 122.2,-52 116.2,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;72&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 2 (Replica)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1&amp;#45;&amp;gt;n2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1-&gt;n2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M78.31,-114.64C61.65,-109.59 45.23,-101.08 35.07,-86.8 29.04,-78.32 32.45,-69.06 39.18,-60.75&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;41.66,-63.22 46.07,-53.59 36.62,-58.36 41.66,-63.22&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;64.04&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;sync write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n3 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M246.2,-52C246.2,-52 157.8,-52 157.8,-52 151.8,-52 145.8,-46 145.8,-40 145.8,-40 145.8,-28 145.8,-28 145.8,-22 151.8,-16 157.8,-16 157.8,-16 246.2,-16 246.2,-16 252.2,-16 258.2,-22 258.2,-28 258.2,-28 258.2,-40 258.2,-40 258.2,-46 252.2,-52 246.2,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;202&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 3 (Replica)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1&amp;#45;&amp;gt;n3 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1-&gt;n3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M141.02,-104.34C144.63,-93.72 150.26,-80.27 158.07,-70 160.78,-66.44 163.94,-63.02 167.29,-59.82&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;169.49,-62.54 174.73,-53.33 164.89,-57.27 169.49,-62.54&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;187.04&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;sync write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n2&amp;#45;&amp;gt;n1 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n2-&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.84,-52.41C93.94,-64.76 106.32,-81.55 116.62,-95.52&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;113.71,-97.46 122.46,-103.43 119.34,-93.31 113.71,-97.46&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;119.45&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ack&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n3&amp;#45;&amp;gt;n1 --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n3-&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M213.41,-52.44C218.8,-63.06 222.73,-76.51 216,-86.8 212.58,-92.03 208.18,-96.49 203.21,-100.28&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;201.5,-97.22 195.01,-105.59 205.31,-103.1 201.5,-97.22&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;229.27&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ack&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c2 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;c2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M352.24,-229.6C352.24,-229.6 293.76,-229.6 293.76,-229.6 287.76,-229.6 281.76,-223.6 281.76,-217.6 281.76,-217.6 281.76,-205.6 281.76,-205.6 281.76,-199.6 287.76,-193.6 293.76,-193.6 293.76,-193.6 352.24,-193.6 352.24,-193.6 358.24,-193.6 364.24,-199.6 364.24,-205.6 364.24,-205.6 364.24,-217.6 364.24,-217.6 364.24,-223.6 358.24,-229.6 352.24,-229.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;323&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client Read&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1p --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n1p&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M393.63,-140.8C393.63,-140.8 294.37,-140.8 294.37,-140.8 288.37,-140.8 282.37,-134.8 282.37,-128.8 282.37,-128.8 282.37,-116.8 282.37,-116.8 282.37,-110.8 288.37,-104.8 294.37,-104.8 294.37,-104.8 393.63,-104.8 393.63,-104.8 399.63,-104.8 405.63,-110.8 405.63,-116.8 405.63,-116.8 405.63,-128.8 405.63,-128.8 405.63,-134.8 399.63,-140.8 393.63,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;344&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 1 (reachable)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c2&amp;#45;&amp;gt;n1p --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;c2-&gt;n1p&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M299.96,-193.35C289.75,-183.5 281.37,-170.76 288,-158.8 290.07,-155.07 292.71,-151.69 295.73,-148.63&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;297.9,-151.37 303.28,-142.24 293.38,-146.03 297.9,-151.37&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- n1p&amp;#45;&amp;gt;c2 --&gt;
&lt;g id=&quot;edge9&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1p-&gt;c2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;red&quot; d=&quot;M339.79,-141.21C336.94,-152.96 333.13,-168.74 329.85,-182.28&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;red&quot; stroke=&quot;red&quot; points=&quot;326.45,-181.44 327.5,-191.98 333.26,-183.08 326.45,-181.44&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;444.43&quot; y=&quot;-163&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ERROR: cannot guarantee consistency&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n_isolated --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n_isolated&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; points=&quot;444.08,-52 281.92,-52 281.92,-16 444.08,-16 444.08,-52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;363&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 2 &amp;#x26; 3 (unreachable)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1p&amp;#45;&amp;gt;n_isolated --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1p-&gt;n_isolated&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;red&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M347.75,-104.65C350.31,-92.96 353.76,-77.19 356.74,-63.62&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;red&quot; stroke=&quot;red&quot; points=&quot;360.15,-64.41 358.87,-53.89 353.31,-62.91 360.15,-64.41&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;401.66&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;consensus check&lt;/text&gt;
&lt;/g&gt;
&lt;!-- label_cp --&gt;
&lt;g id=&quot;node8&quot; class=&quot;node&quot;&gt;
&lt;title&gt;label_cp&lt;/title&gt;
&lt;polygon fill=&quot;lightcoral&quot; stroke=&quot;black&quot; points=&quot;840.82,-229.6 541.18,-229.6 541.18,-193.6 846.82,-193.6 846.82,-223.6 840.82,-229.6&quot;&gt;&lt;/polygon&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;840.82,-229.6 840.82,-223.6&quot;&gt;&lt;/polyline&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;846.82,-223.6 840.82,-223.6&quot;&gt;&lt;/polyline&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;694&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CP: Consistency guaranteed, Availability sacrificed&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Atomic consistent reads&lt;/strong&gt;: Every read returns the latest write or an error — never stale data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;May return errors during partition&lt;/strong&gt;: Availability drops to zero for the affected data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Business-critical use cases&lt;/strong&gt;: Banking, inventory, booking systems where stale data causes real harm&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Synchronous replication&lt;/strong&gt;: Writes are synchronously replicated to a quorum before acknowledgment&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../cap-theorem&quot; class=&quot;internal alias&quot; data-slug=&quot;cap-theorem&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CAP Theorem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../ap-availability-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;ap-availability-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;AP — Availability and Partition Tolerance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../strong-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;strong-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Strong Consistency&lt;/a&gt; — CP systems guarantee strong consistency&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — reading from master ensures strong consistency (a CP pattern)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Quorum failure&lt;/strong&gt;: If a majority of nodes are lost during partition, the system becomes read-only or entirely unavailable until the partition resolves.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tail latency in normal operation&lt;/strong&gt;: The synchronous replication quorum means the slowest node in the quorum determines write latency.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not all CP is equal&lt;/strong&gt;: Some CP systems (e.g., ZooKeeper) prioritize partition recovery speed, while others (e.g., traditional RDBMS with sync replication) may remain unavailable for longer.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>database-federation</title>
    <link href="https://animishraa05.github.io/wiki/system-design/database-federation" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/database-federation.md" />
    <summary>The Problem A single monolithic database handling all application functions (users, products, forums, analytics) creates bottlenecks.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A single monolithic database handling all application functions (users, products, forums, analytics) creates bottlenecks. It becomes a shared contention point for writes, its replication lag affects every feature, and a schema change for one domain risks affecting unrelated features.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Federation splits databases by business function — forums, users, and products each get their own dedicated database. This reduces write contention, shrinks replication lag, improves cache locality, and allows each database to be tuned for its specific workload.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Identify functional domains in the application (e.g., users, products, forums, analytics).&lt;/li&gt;
&lt;li&gt;Create a separate database instance for each domain.&lt;/li&gt;
&lt;li&gt;Route all reads and writes for a domain to its dedicated database.&lt;/li&gt;
&lt;li&gt;Each database operates independently — its own replication topology, backup schedule, and schema.&lt;/li&gt;
&lt;li&gt;Application logic or an API gateway determines which database to query based on the operation.&lt;/li&gt;
&lt;li&gt;Cross-database queries are handled in application code (two separate queries joined in memory).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: Federation Pages: 1 --&gt;
&lt;svg width=&quot;394pt&quot; height=&quot;263pt&quot; viewBox=&quot;0.00 0.00 394.00 263.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 259)&quot;&gt;
&lt;title&gt;Federation&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-259 389.77,-259 389.77,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_db&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; points=&quot;254.32,-8 254.32,-247 385.77,-247 385.77,-8 254.32,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;320.04&quot; y=&quot;-230.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Federated Databases&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M110.13,-129C110.13,-129 12,-129 12,-129 6,-129 0,-123 0,-117 0,-117 0,-105 0,-105 0,-99 6,-93 12,-93 12,-93 110.13,-93 110.13,-93 116.13,-93 122.13,-99 122.13,-105 122.13,-105 122.13,-117 122.13,-117 122.13,-123 116.13,-129 110.13,-129&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.07&quot; y=&quot;-106.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Application Server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- UsersDB --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;UsersDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M354.96,-210.73C354.96,-212.53 339.09,-214 319.54,-214 300,-214 284.13,-212.53 284.13,-210.73 284.13,-210.73 284.13,-181.27 284.13,-181.27 284.13,-179.47 300,-178 319.54,-178 339.09,-178 354.96,-179.47 354.96,-181.27 354.96,-181.27 354.96,-210.73 354.96,-210.73&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M354.96,-210.73C354.96,-208.92 339.09,-207.45 319.54,-207.45 300,-207.45 284.13,-208.92 284.13,-210.73&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;319.54&quot; y=&quot;-191.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Users DB&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;UsersDB --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;UsersDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M90.81,-129.3C105.18,-137.79 123.09,-147.44 140.13,-154 183.68,-170.76 235.87,-182.1 272.52,-188.73&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;271.9,-192.17 282.35,-190.45 273.11,-185.28 271.9,-192.17&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;192.23&quot; y=&quot;-186.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;user.* queries&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ProductsDB --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ProductsDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M363.52,-156.73C363.52,-158.53 343.81,-160 319.54,-160 295.28,-160 275.57,-158.53 275.57,-156.73 275.57,-156.73 275.57,-127.27 275.57,-127.27 275.57,-125.47 295.28,-124 319.54,-124 343.81,-124 363.52,-125.47 363.52,-127.27 363.52,-127.27 363.52,-156.73 363.52,-156.73&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M363.52,-156.73C363.52,-154.92 343.81,-153.45 319.54,-153.45 295.28,-153.45 275.57,-154.92 275.57,-156.73&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;319.54&quot; y=&quot;-137.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Products DB&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;ProductsDB --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;ProductsDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M122.52,-118.31C165.44,-123.49 222.56,-130.4 264.06,-135.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;263.48,-138.87 273.83,-136.6 264.32,-131.92 263.48,-138.87&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;192.23&quot; y=&quot;-137.04&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;product.* queries&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ForumsDB --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ForumsDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M360.41,-102.73C360.41,-104.53 342.09,-106 319.54,-106 296.99,-106 278.68,-104.53 278.68,-102.73 278.68,-102.73 278.68,-73.27 278.68,-73.27 278.68,-71.47 296.99,-70 319.54,-70 342.09,-70 360.41,-71.47 360.41,-73.27 360.41,-73.27 360.41,-102.73 360.41,-102.73&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M360.41,-102.73C360.41,-100.92 342.09,-99.45 319.54,-99.45 296.99,-99.45 278.68,-100.92 278.68,-102.73&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;319.54&quot; y=&quot;-83.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Forums DB&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;ForumsDB --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;ForumsDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M122.52,-101.33C128.46,-100.54 134.41,-99.81 140.13,-99.2 182.88,-94.64 231.6,-91.73 267.31,-90.03&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;267.08,-93.54 276.91,-89.59 266.76,-86.55 267.08,-93.54&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;192.23&quot; y=&quot;-103.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;forum.* queries&lt;/text&gt;
&lt;/g&gt;
&lt;!-- AnalyticsDB --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;AnalyticsDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M365.85,-48.73C365.85,-50.53 345.09,-52 319.54,-52 294,-52 273.24,-50.53 273.24,-48.73 273.24,-48.73 273.24,-19.27 273.24,-19.27 273.24,-17.47 294,-16 319.54,-16 345.09,-16 365.85,-17.47 365.85,-19.27 365.85,-19.27 365.85,-48.73 365.85,-48.73&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M365.85,-48.73C365.85,-46.92 345.09,-45.45 319.54,-45.45 294,-45.45 273.24,-46.92 273.24,-48.73&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;319.54&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Analytics DB&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;AnalyticsDB --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;AnalyticsDB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M92.31,-92.65C106.43,-84.76 123.7,-76.03 140.13,-70.2 179.64,-56.18 226.11,-46.97 261.71,-41.35&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;262.01,-44.85 271.37,-39.88 260.96,-37.93 262.01,-44.85&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;192.23&quot; y=&quot;-74.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;analytics.* queries&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Function-based splitting&lt;/strong&gt; — each database owns a distinct business domain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Smaller databases&lt;/strong&gt; — less data per DB means faster backups, lower replication lag&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reduced contention&lt;/strong&gt; — writes to users don’t block writes to products&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More cache hits&lt;/strong&gt; — domain-specific working sets fit better in memory&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Requires application routing&lt;/strong&gt; — the application layer must know which DB to query&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — federation splits by function, sharding splits by key (both are forms of data partitioning)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; monolithic database — single shared DB vs multiple function-specific DBs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../denormalization&quot; class=&quot;internal alias&quot; data-slug=&quot;denormalization&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Denormalization&lt;/a&gt; — often needed with federation since cross-DB joins are impractical&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../microservices-architecture&quot; class=&quot;internal alias&quot; data-slug=&quot;microservices-architecture&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Microservices Architecture&lt;/a&gt; — the database-per-service pattern is a natural fit for microservices&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — each federated database can have its own replication topology&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Cross-domain queries&lt;/strong&gt; — a report that needs user names and product names requires two database queries and application-level join, which is slower than a SQL JOIN.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Uneven load distribution&lt;/strong&gt; — one domain (users) may have 100x the traffic of another (analytics), requiring different infrastructure per federation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transaction boundaries&lt;/strong&gt; — an operation that updates both users and forums cannot use a cross-database ACID transaction; requires a saga or eventual consistency pattern.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>denormalization</title>
    <link href="https://animishraa05.github.io/wiki/system-design/denormalization" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/denormalization.md" />
    <summary>The Problem Complex SQL joins across normalized tables become prohibitively expensive as data grows — especially when joins span shards, federated databases, or high-traffic tables.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Complex SQL joins across normalized tables become prohibitively expensive as data grows — especially when joins span shards, federated databases, or high-traffic tables. These joins add milliseconds to query time, which compounds under load.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Denormalization intentionally adds redundant copies of data across multiple tables to avoid expensive joins at read time. This improves read performance at the cost of write performance — reads become fast single-table lookups, but writes must update multiple copies of the data.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Profile query patterns to identify frequent, expensive joins.&lt;/li&gt;
&lt;li&gt;Add redundant columns to tables that are frequently joined together (e.g., store &lt;code class=&quot;notranslate&quot;&gt;username&lt;/code&gt; in the &lt;code class=&quot;notranslate&quot;&gt;orders&lt;/code&gt; table instead of joining &lt;code class=&quot;notranslate&quot;&gt;users&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;On write operations, update all copies of the redundant data — either in application code or via database triggers.&lt;/li&gt;
&lt;li&gt;Use materialized views (PostgreSQL, Oracle) that automatically refresh the denormalized result set on a schedule or on change.&lt;/li&gt;
&lt;li&gt;Monitor consistency — periodic reconciliation jobs can detect and fix diverging copies.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: Denormalization Pages: 1 --&gt;
&lt;svg width=&quot;600pt&quot; height=&quot;198pt&quot; viewBox=&quot;0.00 0.00 600.00 198.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 194)&quot;&gt;
&lt;title&gt;Denormalization&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-194 596.46,-194 596.46,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_normalized&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; points=&quot;12.98,-8 12.98,-91 584.46,-91 584.46,-8 12.98,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;298.72&quot; y=&quot;-74.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Normalized (3 queries)&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_denormalized&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; points=&quot;8,-99 8,-182 165.2,-182 165.2,-99 8,-99&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.6&quot; y=&quot;-165.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Denormalized (1 query)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Users --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Users&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M140.22,-57.8C140.22,-57.8 32.98,-57.8 32.98,-57.8 26.98,-57.8 20.98,-51.8 20.98,-45.8 20.98,-45.8 20.98,-28.2 20.98,-28.2 20.98,-22.2 26.98,-16.2 32.98,-16.2 32.98,-16.2 140.22,-16.2 140.22,-16.2 146.22,-16.2 152.22,-22.2 152.22,-28.2 152.22,-28.2 152.22,-45.8 152.22,-45.8 152.22,-51.8 146.22,-57.8 140.22,-57.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.6&quot; y=&quot;-41.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;users&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.6&quot; y=&quot;-24.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;id | username | email&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Orders --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Orders&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M324.12,-57.8C324.12,-57.8 235.53,-57.8 235.53,-57.8 229.53,-57.8 223.53,-51.8 223.53,-45.8 223.53,-45.8 223.53,-28.2 223.53,-28.2 223.53,-22.2 229.53,-16.2 235.53,-16.2 235.53,-16.2 324.12,-16.2 324.12,-16.2 330.12,-16.2 336.12,-22.2 336.12,-28.2 336.12,-28.2 336.12,-45.8 336.12,-45.8 336.12,-51.8 330.12,-57.8 324.12,-57.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;279.83&quot; y=&quot;-41.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;orders&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;279.83&quot; y=&quot;-24.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;id | user_id | total&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Users&amp;#45;&amp;gt;Orders --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Users-&gt;Orders&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;1 5&quot; d=&quot;M152.61,-37C171.71,-37 192.63,-37 211.85,-37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;211.74,-40.5 221.74,-37 211.74,-33.5 211.74,-40.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;190.37&quot; y=&quot;-41.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;JOIN&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Products --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Products&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M564.46,-57.8C564.46,-57.8 414.45,-57.8 414.45,-57.8 408.45,-57.8 402.45,-51.8 402.45,-45.8 402.45,-45.8 402.45,-28.2 402.45,-28.2 402.45,-22.2 408.45,-16.2 414.45,-16.2 414.45,-16.2 564.46,-16.2 564.46,-16.2 570.46,-16.2 576.46,-22.2 576.46,-28.2 576.46,-28.2 576.46,-45.8 576.46,-45.8 576.46,-51.8 570.46,-57.8 564.46,-57.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;489.46&quot; y=&quot;-41.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;order_items&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;489.46&quot; y=&quot;-24.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;id | order_id | product_name&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Orders&amp;#45;&amp;gt;Products --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Orders-&gt;Products&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;1 5&quot; d=&quot;M336.47,-37C353.26,-37 372.21,-37 390.89,-37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;390.64,-40.5 400.64,-37 390.64,-33.5 390.64,-40.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;369.29&quot; y=&quot;-41.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;JOIN&lt;/text&gt;
&lt;/g&gt;
&lt;!-- OrdersDenorm --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;OrdersDenorm&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M145.2,-148.8C145.2,-148.8 28,-148.8 28,-148.8 22,-148.8 16,-142.8 16,-136.8 16,-136.8 16,-119.2 16,-119.2 16,-113.2 22,-107.2 28,-107.2 28,-107.2 145.2,-107.2 145.2,-107.2 151.2,-107.2 157.2,-113.2 157.2,-119.2 157.2,-119.2 157.2,-136.8 157.2,-136.8 157.2,-142.8 151.2,-148.8 145.2,-148.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.6&quot; y=&quot;-132.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;orders_denormalized&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.6&quot; y=&quot;-115.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(single table, no joins)&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Improves read performance&lt;/strong&gt; — single-table lookups instead of multi-table joins&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Adds data redundancy&lt;/strong&gt; — the same information exists in multiple places&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes become more expensive&lt;/strong&gt; — every write must update all redundant copies&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Constraints help maintain consistency&lt;/strong&gt; — foreign keys and check constraints reduce drift&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Materialized views automate management&lt;/strong&gt; — database-native denormalization with refresh schedules&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sql-tuning&quot; class=&quot;internal alias&quot; data-slug=&quot;sql-tuning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SQL Tuning&lt;/a&gt; — denormalization is a specific SQL optimization technique&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — denormalization avoids expensive cross-shard joins by colocating related data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../database-federation&quot; class=&quot;internal alias&quot; data-slug=&quot;database-federation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Database Federation&lt;/a&gt; — reduces the need for cross-database joins by duplicating reference data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; normalized schema — third-normal-form (3NF) eliminates redundancy; denormalization reintroduces it intentionally&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../nosql-database-types&quot; class=&quot;internal alias&quot; data-slug=&quot;nosql-database-types&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;NoSQL Database Types&lt;/a&gt; — NoSQL databases are inherently denormalized; joins are done in application code&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Data drift&lt;/strong&gt; — if one copy of the data is updated but another is not, queries return inconsistent results; write atomicity is critical.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Storage bloat&lt;/strong&gt; — redundant copies increase disk usage; factor in at least 2x–3x storage for heavily denormalized schemas.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Update anomaly complexity&lt;/strong&gt; — a single logical change (user changes their name) may need to update dozens of denormalized copies across multiple tables or databases.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>dns-system-design</title>
    <link href="https://animishraa05.github.io/wiki/system-design/dns-system-design" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/dns-system-design.md" />
    <summary>The Problem Users cannot remember numerical IP addresses for every service they access. A human-readable naming system that scales globally is needed.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="infrastructure" label="infrastructure" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Users cannot remember numerical IP addresses for every service they access. A human-readable naming system that scales globally is needed.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;DNS translates domain names (&lt;a href=&quot;http://www.example.com&quot; class=&quot;external&quot; rel=&quot;nofollow&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;www.example.com&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -12 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;1.5&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; aria-hidden class=&quot;external-icon&quot;&gt;&lt;use href=&quot;#arrow-ne&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;) to IP addresses using a hierarchical, distributed system of name servers with caching at every level.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;A user types a domain name into a browser.&lt;/li&gt;
&lt;li&gt;The browser checks its local cache, then the OS cache, then the ISP resolver.&lt;/li&gt;
&lt;li&gt;The recursive resolver queries the root name server for the TLD server.&lt;/li&gt;
&lt;li&gt;The TLD server directs to the authoritative name server for the domain.&lt;/li&gt;
&lt;li&gt;The authoritative server returns the IP address (A record) or other record type.&lt;/li&gt;
&lt;li&gt;Results are cached at each level for the duration of the TTL.&lt;/li&gt;
&lt;li&gt;Record types include A (address), CNAME (canonical name), MX (mail exchange), NS (name server).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: dns_resolution Pages: 1 --&gt;
&lt;svg width=&quot;566pt&quot; height=&quot;214pt&quot; viewBox=&quot;0.00 0.00 566.00 214.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 209.6)&quot;&gt;
&lt;title&gt;dns_resolution&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-209.6 561.86,-209.6 561.86,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- USER --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;USER&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;224.03,-205.6 123.34,-205.6 123.34,-169.6 224.03,-169.6 224.03,-205.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;173.68&quot; y=&quot;-184&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Browser / Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CACHE --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CACHE&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;156.7,-121.6 18.67,-121.6 18.67,-84.8 156.7,-84.8 156.7,-121.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;87.68&quot; y=&quot;-106.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Cache&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;87.68&quot; y=&quot;-92.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Browser → OS → ISP)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- USER&amp;#45;&amp;gt;CACHE --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;USER-&gt;CACHE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M122.93,-180.23C88.36,-174.73 46.98,-165.45 36.21,-151.6 29.89,-143.47 33.4,-135.53 40.92,-128.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;42.56,-131.69 48.36,-122.82 38.3,-126.14 42.56,-131.69&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;73.45&quot; y=&quot;-142.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;check cache first&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RESOLVER --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;RESOLVER&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;310.7,-121.2 190.67,-121.2 190.67,-85.2 310.7,-85.2 310.7,-121.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;250.68&quot; y=&quot;-99.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Recursive Resolver&lt;/text&gt;
&lt;/g&gt;
&lt;!-- USER&amp;#45;&amp;gt;RESOLVER --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;USER-&gt;RESOLVER&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M188.64,-169.44C196.56,-160.46 206.53,-149.33 215.67,-139.6 218.71,-136.36 221.95,-133 225.17,-129.69&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;227.47,-132.34 231.99,-122.75 222.48,-127.43 227.47,-132.34&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;240.68&quot; y=&quot;-142.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;cache miss&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CACHE&amp;#45;&amp;gt;USER --&gt;
&lt;g id=&quot;edge10&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CACHE-&gt;USER&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M106.19,-121.93C118.14,-133.38 133.88,-148.46 147.15,-161.17&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;144.71,-163.69 154.35,-168.08 149.55,-158.63 144.71,-163.69&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;165.57&quot; y=&quot;-142.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;cached result&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RESOLVER&amp;#45;&amp;gt;USER --&gt;
&lt;g id=&quot;edge9&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RESOLVER-&gt;USER&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M263.14,-121.53C268.32,-131.02 271.86,-142.65 265.68,-151.6 258.26,-162.37 247.04,-169.83 234.97,-175&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;233.8,-171.7 225.63,-178.45 236.23,-178.26 233.8,-171.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;288.13&quot; y=&quot;-142.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;return IP&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ROOT --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ROOT&lt;/title&gt;
&lt;polygon fill=&quot;#ffe5cc&quot; stroke=&quot;black&quot; points=&quot;115.37,-36.4 0,-36.4 0,-0.4 115.37,-0.4 115.37,-36.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.68&quot; y=&quot;-14.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Root Name Server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RESOLVER&amp;#45;&amp;gt;ROOT --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RESOLVER-&gt;ROOT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M190.44,-89.17C182.14,-87.58 173.72,-86.07 165.68,-84.8 130.46,-79.22 29.99,-93.39 6.23,-66.8 -0.87,-58.85 2.94,-50.78 11.02,-43.61&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;13.09,-46.43 19.06,-37.67 8.93,-40.8 13.09,-46.43&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;33.46&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;ask for .com&lt;/text&gt;
&lt;/g&gt;
&lt;!-- TLD --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;TLD&lt;/title&gt;
&lt;polygon fill=&quot;#ffe5cc&quot; stroke=&quot;black&quot; points=&quot;274.03,-36.8 161.34,-36.8 161.34,0 274.03,0 274.03,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;217.68&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;TLD Name Server&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;217.68&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(.com, .org, etc.)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RESOLVER&amp;#45;&amp;gt;TLD --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RESOLVER-&gt;TLD&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M211.5,-84.9C204.65,-80.06 198.45,-74.07 194.43,-66.8 190.94,-60.48 191.8,-53.56 194.66,-47.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;197.63,-48.86 199.7,-38.47 191.6,-45.31 197.63,-48.86&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;240.56&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;ask for example.com&lt;/text&gt;
&lt;/g&gt;
&lt;!-- AUTH --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;AUTH&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;527.05,-36.4 370.32,-36.4 370.32,-0.4 527.05,-0.4 527.05,-36.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;448.68&quot; y=&quot;-14.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Authoritative Name Server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RESOLVER&amp;#45;&amp;gt;AUTH --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RESOLVER-&gt;AUTH&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M311.19,-89.5C332.71,-83.91 356.78,-76.39 377.68,-66.8 391.5,-60.46 405.65,-51.59 417.64,-43.24&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;419.43,-46.26 425.51,-37.59 415.35,-40.57 419.43,-46.26&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;419.43&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;ask for IP&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ROOT&amp;#45;&amp;gt;RESOLVER --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ROOT-&gt;RESOLVER&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M69,-36.75C76.55,-46.99 87.38,-59.36 99.88,-66.8 107.18,-71.15 144.05,-79.83 179.5,-87.51&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;178.43,-90.86 188.94,-89.54 179.9,-84.02 178.43,-90.86&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;143.78&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;TLD server address&lt;/text&gt;
&lt;/g&gt;
&lt;!-- TLD&amp;#45;&amp;gt;RESOLVER --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;TLD-&gt;RESOLVER&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M268.67,-37.08C275.84,-41.74 282.26,-47.56 286.68,-54.8 291.15,-62.12 288.95,-69.67 283.92,-76.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;281.54,-73.95 277.35,-83.68 286.7,-78.69 281.54,-73.95&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;331.62&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;authoritative server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- AUTH&amp;#45;&amp;gt;RESOLVER --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;AUTH-&gt;RESOLVER&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M451.98,-36.77C452.82,-46.75 451.9,-58.85 444.68,-66.8 428.38,-84.75 370.73,-93.67 322.48,-98.07&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;322.25,-94.57 312.59,-98.91 322.85,-101.55 322.25,-94.57&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;504.21&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;A record: 93.184.216.34&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Hierarchical tree structure: root → TLD → authoritative&lt;/li&gt;
&lt;li&gt;Cached at multiple levels: browser, OS, ISP resolver&lt;/li&gt;
&lt;li&gt;TTL (Time To Live) controls how long entries are cached&lt;/li&gt;
&lt;li&gt;Supports weighted routing, latency-based routing, and geo-routing via managed DNS providers&lt;/li&gt;
&lt;li&gt;Managed DNS services: Route53, CloudFlare DNS, Google Cloud DNS&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cdn-push&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-push&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Push CDN&lt;/a&gt; — DNS routes users to the nearest CDN edge server&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cdn-pull&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-pull&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Pull CDN&lt;/a&gt; — DNS resolution directs users to the appropriate CDN endpoint&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — DNS can distribute traffic across multiple server IPs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-active-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-active-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Active Failover&lt;/a&gt; — DNS must be configured with all active server IPs&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;DNS propagation delays mean changes to records take time (up to 48 hours for TTL expiration everywhere)&lt;/li&gt;
&lt;li&gt;DNS is vulnerable to cache poisoning attacks if DNSSEC is not implemented&lt;/li&gt;
&lt;li&gt;CNAME records cannot coexist with other record types at the same DNS node — use ALIAS or ANAME records instead&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>eventual-consistency</title>
    <link href="https://animishraa05.github.io/wiki/system-design/eventual-consistency" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/eventual-consistency.md" />
    <summary>The Problem Strong consistency limits availability and throughput because it requires synchronous coordination before every read.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="distributed-systems" label="distributed-systems" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Strong consistency limits availability and throughput because it requires synchronous coordination before every read. Many applications can tolerate temporary inconsistency in exchange for higher availability and lower latency.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;After a write, reads will eventually see it — typically within milliseconds — as data is replicated asynchronously across nodes. The system guarantees convergence: given enough time without new writes, all replicas will hold the same value. Between the write and convergence, reads may return stale data.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Client writes to one node&lt;/strong&gt;: The write is acknowledged immediately without waiting for replicas. The write is placed in a replication log.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Asynchronous propagation&lt;/strong&gt;: The replication log is streamed to other nodes in the background. Propagation delay depends on network latency, load, and batch size.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stale reads during window&lt;/strong&gt;: A read to a node that hasn’t received the replication log returns the old value.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Convergence&lt;/strong&gt;: Once all replicas have processed the log, every read returns the latest write. If no new writes occur, the system becomes consistent.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;1125pt&quot; height=&quot;149pt&quot; viewBox=&quot;0.00 0.00 1125.00 149.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 144.8)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-144.8 1120.54,-144.8 1120.54,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_timeline&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-91 1108.54,-91 1108.54,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;558.27&quot; y=&quot;-74.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Time →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- t0 --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;t0&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M173.31,-55C173.31,-55 28,-55 28,-55 22,-55 16,-49 16,-43 16,-43 16,-31 16,-31 16,-25 22,-19 28,-19 28,-19 173.31,-19 173.31,-19 179.31,-19 185.31,-25 185.31,-31 185.31,-31 185.31,-43 185.31,-43 185.31,-49 179.31,-55 173.31,-55&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;100.65&quot; y=&quot;-32.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;T0: Write X=10 to Primary&lt;/text&gt;
&lt;/g&gt;
&lt;!-- t1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;t1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M556.26,-55C556.26,-55 328.55,-55 328.55,-55 322.55,-55 316.55,-49 316.55,-43 316.55,-43 316.55,-31 316.55,-31 316.55,-25 322.55,-19 328.55,-19 328.55,-19 556.26,-19 556.26,-19 562.26,-19 568.26,-25 568.26,-31 568.26,-31 568.26,-43 568.26,-43 568.26,-49 562.26,-55 556.26,-55&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;442.41&quot; y=&quot;-32.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;T1: Read from Replica → old value (X=5)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- t0&amp;#45;&amp;gt;t1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;t0-&gt;t1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M185.64,-37C221.65,-37 264.65,-37 305.03,-37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;304.82,-40.5 314.82,-37 304.82,-33.5 304.82,-40.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- t2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;t2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M893.25,-55C893.25,-55 713.85,-55 713.85,-55 707.85,-55 701.85,-49 701.85,-43 701.85,-43 701.85,-31 701.85,-31 701.85,-25 707.85,-19 713.85,-19 713.85,-19 893.25,-19 893.25,-19 899.25,-19 905.25,-25 905.25,-31 905.25,-31 905.25,-43 905.25,-43 905.25,-49 899.25,-55 893.25,-55&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;803.55&quot; y=&quot;-32.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;T2: Async replication in progress&lt;/text&gt;
&lt;/g&gt;
&lt;!-- t1&amp;#45;&amp;gt;t2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;t1-&gt;t2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M568.76,-37C608.27,-37 651.64,-37 690.18,-37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;689.93,-40.5 699.93,-37 689.93,-33.5 689.93,-40.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- t3 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;t3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M1088.54,-57.8C1088.54,-57.8 954.25,-57.8 954.25,-57.8 948.25,-57.8 942.25,-51.8 942.25,-45.8 942.25,-45.8 942.25,-28.2 942.25,-28.2 942.25,-22.2 948.25,-16.2 954.25,-16.2 954.25,-16.2 1088.54,-16.2 1088.54,-16.2 1094.54,-16.2 1100.54,-22.2 1100.54,-28.2 1100.54,-28.2 1100.54,-45.8 1100.54,-45.8 1100.54,-51.8 1094.54,-57.8 1088.54,-57.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;1021.39&quot; y=&quot;-41.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;T3: Replication complete&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;1021.39&quot; y=&quot;-24.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;All reads return X=10&lt;/text&gt;
&lt;/g&gt;
&lt;!-- t2&amp;#45;&amp;gt;t3 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;t2-&gt;t3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M905.52,-37C913.8,-37 922.13,-37 930.32,-37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;930.27,-40.5 940.27,-37 930.27,-33.5 930.27,-40.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- primary --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;primary&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;131.21,-140.8 70.1,-140.8 70.1,-99.2 131.21,-99.2 131.21,-140.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;100.65&quot; y=&quot;-124.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Primary&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;100.65&quot; y=&quot;-107.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;X=10&lt;/text&gt;
&lt;/g&gt;
&lt;!-- replica_before --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;replica_before&lt;/title&gt;
&lt;polygon fill=&quot;lightcoral&quot; stroke=&quot;black&quot; points=&quot;482.15,-140.8 402.66,-140.8 402.66,-99.2 482.15,-99.2 482.15,-140.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;442.41&quot; y=&quot;-124.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Replica&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;442.41&quot; y=&quot;-107.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;X=5 (stale)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- primary&amp;#45;&amp;gt;replica_before --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;primary-&gt;replica_before&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M131.51,-120C189.72,-120 318.96,-120 390.79,-120&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;390.72,-123.5 400.72,-120 390.72,-116.5 390.72,-123.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;250.93&quot; y=&quot;-124.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;async replication&lt;/text&gt;
&lt;/g&gt;
&lt;!-- replica_after --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;replica_after&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;863.11,-140.8 743.98,-140.8 743.98,-99.2 863.11,-99.2 863.11,-140.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;803.55&quot; y=&quot;-124.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Replica&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;803.55&quot; y=&quot;-107.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;X=10 (converged)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- replica_before&amp;#45;&amp;gt;replica_after --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;replica_before-&gt;replica_after&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M482.52,-120C542.44,-120 657.83,-120 732.44,-120&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;732.08,-123.5 742.08,-120 732.08,-116.5 732.08,-123.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;635.06&quot; y=&quot;-124.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;propagation done&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Convergence guaranteed&lt;/strong&gt;: Given no new writes, all replicas will eventually hold the same value&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Asynchronous replication&lt;/strong&gt;: Writes are acknowledged immediately; replication happens in the background&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Temporary inconsistency window&lt;/strong&gt;: Brief period between write and full propagation where stale reads are possible&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Works in DNS (TTL propagation), email (SMTP delay), and many NoSQL databases (DynamoDB, Cassandra)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../strong-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;strong-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Strong Consistency&lt;/a&gt; — sync vs async replication, guarantees vs temporary inconsistency&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../weak-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;weak-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Weak Consistency&lt;/a&gt; — eventual guarantees convergence, weak does not&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../ap-availability-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;ap-availability-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;AP — Availability and Partition Tolerance&lt;/a&gt; — AP systems use eventual consistency as their consistency model&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — slaves are eventually consistent with the master&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../dns-system-design&quot; class=&quot;internal alias&quot; data-slug=&quot;dns-system-design&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DNS in System Design&lt;/a&gt; — DNS uses eventual consistency with TTL-based caching&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Write conflicts&lt;/strong&gt;: Concurrent writes to different replicas may produce conflicts that require reconciliation (last-write-wins, CRDTs, application-level merging).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Staleness bounds are application-defined&lt;/strong&gt;: DNS uses TTLs to bound inconsistency. Without explicit bounds, staleness can grow arbitrarily under heavy load or network issues.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Read-your-write consistency is not guaranteed&lt;/strong&gt;: A client that writes to one node and immediately reads from another may not see its own write. Session consistency or quorum reads can mitigate this.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>horizontal-scaling</title>
    <link href="https://animishraa05.github.io/wiki/system-design/horizontal-scaling" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/horizontal-scaling.md" />
    <summary>The Problem Vertical scaling (buying a bigger server) hits diminishing returns — costs grow super-linearly while performance gains taper off, and high-end hardware requires specialized expertise.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="scalability" label="scalability" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Vertical scaling (buying a bigger server) hits diminishing returns — costs grow super-linearly while performance gains taper off, and high-end hardware requires specialized expertise.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Horizontal scaling adds more commodity machines to distribute load across them, improving both performance and availability through parallelism and redundancy.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Clone identical server instances behind a load balancer.&lt;/li&gt;
&lt;li&gt;Servers must be stateless — no user data stored locally on any instance.&lt;/li&gt;
&lt;li&gt;Session data is stored in a centralized, shared store (Redis, Memcached, database).&lt;/li&gt;
&lt;li&gt;The load balancer distributes incoming requests across all available instances.&lt;/li&gt;
&lt;li&gt;More instances are added during traffic spikes and removed during lulls (auto-scaling).&lt;/li&gt;
&lt;li&gt;Commodity hardware costs less than equivalent vertical upgrades and is easier to hire for.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: horizontal_scaling Pages: 1 --&gt;
&lt;svg width=&quot;552pt&quot; height=&quot;152pt&quot; viewBox=&quot;0.00 0.00 552.00 152.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 148)&quot;&gt;
&lt;title&gt;horizontal_scaling&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-148 548.08,-148 548.08,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CLIENTS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CLIENTS&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;54,-90 0,-90 0,-54 54,-54 54,-90&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-68.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Clients&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;LB&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;184.39,-90 91,-90 91,-54 184.39,-54 184.39,-90&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;137.7&quot; y=&quot;-68.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Load Balancer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CLIENTS&amp;#45;&amp;gt;LB --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CLIENTS-&gt;LB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.31,-72C61.91,-72 70.52,-72 79.24,-72&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;79.17,-75.5 89.17,-72 79.17,-68.5 79.17,-75.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- S1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S1&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;308.42,-144 222.39,-144 222.39,-108 308.42,-108 308.42,-144&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;265.41&quot; y=&quot;-122.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;App Server 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;S1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;S1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M181.61,-90.43C191.32,-94.61 201.74,-99.08 211.8,-103.4&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;210.15,-106.5 220.72,-107.24 212.92,-100.07 210.15,-106.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- S2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S2&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;308.42,-90 222.39,-90 222.39,-54 308.42,-54 308.42,-90&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;265.41&quot; y=&quot;-68.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;App Server 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;S2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;S2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M184.79,-72C193.17,-72 201.99,-72 210.57,-72&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;210.55,-75.5 220.55,-72 210.55,-68.5 210.55,-75.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- S3 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S3&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;309.42,-36 221.39,-36 221.39,0 309.42,0 309.42,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;265.41&quot; y=&quot;-14.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;App Server N&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;S3 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;S3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M181.61,-53.57C191.11,-49.48 201.3,-45.11 211.16,-40.87&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;212.49,-44.11 220.3,-36.95 209.73,-37.68 212.49,-44.11&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- STORE --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;STORE&lt;/title&gt;
&lt;polygon fill=&quot;#ffe5cc&quot; stroke=&quot;black&quot; points=&quot;544.08,-90.4 426.01,-90.4 426.01,-53.6 544.08,-53.6 544.08,-90.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;485.04&quot; y=&quot;-75.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Shared State Store&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;485.04&quot; y=&quot;-61.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Redis / DB)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1&amp;#45;&amp;gt;STORE --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S1-&gt;STORE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M308.88,-115.46C338.91,-108.01 379.84,-97.86 414.58,-89.24&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;415.28,-92.67 424.15,-86.86 413.6,-85.87 415.28,-92.67&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;367.72&quot; y=&quot;-113.04&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;read/write session&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S2&amp;#45;&amp;gt;STORE --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S2-&gt;STORE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M308.88,-72C338.78,-72 379.48,-72 414.12,-72&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;414.1,-75.5 424.1,-72 414.1,-68.5 414.1,-75.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- S3&amp;#45;&amp;gt;STORE --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S3-&gt;STORE&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M309.66,-28.73C339.64,-36.17 380.2,-46.24 414.66,-54.79&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;413.6,-58.13 424.15,-57.14 415.28,-51.33 413.6,-58.13&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Scales out by adding more machines (contrast: scaling up = bigger machine)&lt;/li&gt;
&lt;li&gt;Requires a load balancer to distribute traffic&lt;/li&gt;
&lt;li&gt;Servers must be stateless — user sessions live in an external store&lt;/li&gt;
&lt;li&gt;More cost-effective than vertical scaling at medium to large scale&lt;/li&gt;
&lt;li&gt;Higher availability than a single server — failure of one instance doesn’t take down the system&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — load balancers are the entry point that enables horizontal scaling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt; — L7 LB enables routing to specific horizontally scaled services&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-active-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-active-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Active Failover&lt;/a&gt; — active-active is a specific form of horizontal scaling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../availability-parallel-vs-sequence&quot; class=&quot;internal alias&quot; data-slug=&quot;availability-parallel-vs-sequence&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Availability in Parallel vs Sequence&lt;/a&gt; — horizontal scaling improves availability through parallel redundancy&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Statelessness is hard for legacy applications that assume local file system access or in-memory session state&lt;/li&gt;
&lt;li&gt;Auto-scaling can cause thundering herds if new instances all hit the database simultaneously on startup&lt;/li&gt;
&lt;li&gt;Horizontal scaling does not help with database writes — those require sharding or read replicas&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>latency-vs-throughput</title>
    <link href="https://animishraa05.github.io/wiki/system-design/latency-vs-throughput" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/latency-vs-throughput.md" />
    <summary>The Problem Low latency and high throughput are often competing goals — optimizing for one can degrade the other.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="system-design" label="system-design" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Low latency and high throughput are often competing goals — optimizing for one can degrade the other. Systems must balance both based on application requirements.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Latency is the time taken to complete a single operation (e.g., one HTTP request). Throughput is the number of operations completed per unit time (e.g., requests per second). A system can have low latency but low throughput, or high latency but high throughput.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Single request measurement&lt;/strong&gt;: Measure the time from request initiation to response completion (latency).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Aggregate measurement&lt;/strong&gt;: Count completed requests over a fixed time window (throughput).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pipeline effect&lt;/strong&gt;: With a queue and multiple workers, each request’s latency may increase slightly while total throughput rises significantly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trade-off tuning&lt;/strong&gt;: Increasing concurrency boosts throughput up to a point, beyond which contention causes latency to spike.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;752pt&quot; height=&quot;278pt&quot; viewBox=&quot;0.00 0.00 752.00 278.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 274.4)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-274.4 747.63,-274.4 747.63,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_low_latency&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-96.8 8,-262.4 208,-262.4 208,-96.8 8,-96.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;108&quot; y=&quot;-245.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Low Latency, Low Throughput&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_high_throughput&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;216,-8 216,-262.4 622,-262.4 622,-8 216,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;419&quot; y=&quot;-245.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;High Throughput, Higher Latency&lt;/text&gt;
&lt;/g&gt;
&lt;!-- r1 --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;r1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M188.05,-229.6C188.05,-229.6 27.95,-229.6 27.95,-229.6 21.95,-229.6 15.95,-223.6 15.95,-217.6 15.95,-217.6 15.95,-205.6 15.95,-205.6 15.95,-199.6 21.95,-193.6 27.95,-193.6 27.95,-193.6 188.05,-193.6 188.05,-193.6 194.05,-193.6 200.05,-199.6 200.05,-205.6 200.05,-205.6 200.05,-217.6 200.05,-217.6 200.05,-223.6 194.05,-229.6 188.05,-229.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;108&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Request A -&gt; Response (5ms)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- r2 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;r2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M187.66,-140.8C187.66,-140.8 28.34,-140.8 28.34,-140.8 22.34,-140.8 16.34,-134.8 16.34,-128.8 16.34,-128.8 16.34,-116.8 16.34,-116.8 16.34,-110.8 22.34,-104.8 28.34,-104.8 28.34,-104.8 187.66,-104.8 187.66,-104.8 193.66,-104.8 199.66,-110.8 199.66,-116.8 199.66,-116.8 199.66,-128.8 199.66,-128.8 199.66,-134.8 193.66,-140.8 187.66,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;108&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Request B -&gt; Response (5ms)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- r1&amp;#45;&amp;gt;r2 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;r1-&gt;r2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M108,-193.45C108,-181.76 108,-165.99 108,-152.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;111.5,-152.72 108,-142.72 104.5,-152.72 111.5,-152.72&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- a --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;a&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M330.31,-229.6C330.31,-229.6 235.69,-229.6 235.69,-229.6 229.69,-229.6 223.69,-223.6 223.69,-217.6 223.69,-217.6 223.69,-205.6 223.69,-205.6 223.69,-199.6 229.69,-193.6 235.69,-193.6 235.69,-193.6 330.31,-193.6 330.31,-193.6 336.31,-193.6 342.31,-199.6 342.31,-205.6 342.31,-205.6 342.31,-217.6 342.31,-217.6 342.31,-223.6 336.31,-229.6 330.31,-229.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;283&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Req A (enqueued)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- worker1 --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;worker1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M305.63,-140.8C305.63,-140.8 260.37,-140.8 260.37,-140.8 254.37,-140.8 248.37,-134.8 248.37,-128.8 248.37,-128.8 248.37,-116.8 248.37,-116.8 248.37,-110.8 254.37,-104.8 260.37,-104.8 260.37,-104.8 305.63,-104.8 305.63,-104.8 311.63,-104.8 317.63,-110.8 317.63,-116.8 317.63,-116.8 317.63,-128.8 317.63,-128.8 317.63,-134.8 311.63,-140.8 305.63,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;283&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Worker 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- a&amp;#45;&amp;gt;worker1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;a-&gt;worker1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M283,-193.45C283,-181.76 283,-165.99 283,-152.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;286.5,-152.72 283,-142.72 279.5,-152.72 286.5,-152.72&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- b --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;b&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M465.93,-229.6C465.93,-229.6 372.07,-229.6 372.07,-229.6 366.07,-229.6 360.07,-223.6 360.07,-217.6 360.07,-217.6 360.07,-205.6 360.07,-205.6 360.07,-199.6 366.07,-193.6 372.07,-193.6 372.07,-193.6 465.93,-193.6 465.93,-193.6 471.93,-193.6 477.93,-199.6 477.93,-205.6 477.93,-205.6 477.93,-217.6 477.93,-217.6 477.93,-223.6 471.93,-229.6 465.93,-229.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;419&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Req B (enqueued)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- worker2 --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;worker2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M441.63,-140.8C441.63,-140.8 396.37,-140.8 396.37,-140.8 390.37,-140.8 384.37,-134.8 384.37,-128.8 384.37,-128.8 384.37,-116.8 384.37,-116.8 384.37,-110.8 390.37,-104.8 396.37,-104.8 396.37,-104.8 441.63,-104.8 441.63,-104.8 447.63,-104.8 453.63,-110.8 453.63,-116.8 453.63,-116.8 453.63,-128.8 453.63,-128.8 453.63,-134.8 447.63,-140.8 441.63,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;419&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Worker 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- b&amp;#45;&amp;gt;worker2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;b-&gt;worker2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M419,-193.45C419,-181.76 419,-165.99 419,-152.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;422.5,-152.72 419,-142.72 415.5,-152.72 422.5,-152.72&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- c --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;c&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M601.93,-229.6C601.93,-229.6 508.07,-229.6 508.07,-229.6 502.07,-229.6 496.07,-223.6 496.07,-217.6 496.07,-217.6 496.07,-205.6 496.07,-205.6 496.07,-199.6 502.07,-193.6 508.07,-193.6 508.07,-193.6 601.93,-193.6 601.93,-193.6 607.93,-193.6 613.93,-199.6 613.93,-205.6 613.93,-205.6 613.93,-217.6 613.93,-217.6 613.93,-223.6 607.93,-229.6 601.93,-229.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;555&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Req C (enqueued)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- worker3 --&gt;
&lt;g id=&quot;node8&quot; class=&quot;node&quot;&gt;
&lt;title&gt;worker3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M577.63,-140.8C577.63,-140.8 532.37,-140.8 532.37,-140.8 526.37,-140.8 520.37,-134.8 520.37,-128.8 520.37,-128.8 520.37,-116.8 520.37,-116.8 520.37,-110.8 526.37,-104.8 532.37,-104.8 532.37,-104.8 577.63,-104.8 577.63,-104.8 583.63,-104.8 589.63,-110.8 589.63,-116.8 589.63,-116.8 589.63,-128.8 589.63,-128.8 589.63,-134.8 583.63,-140.8 577.63,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;555&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Worker 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- c&amp;#45;&amp;gt;worker3 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;c-&gt;worker3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M555,-193.45C555,-181.76 555,-165.99 555,-152.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;558.5,-152.72 555,-142.72 551.5,-152.72 558.5,-152.72&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- resp_a --&gt;
&lt;g id=&quot;node9&quot; class=&quot;node&quot;&gt;
&lt;title&gt;resp_a&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M298,-52C298,-52 268,-52 268,-52 262,-52 256,-46 256,-40 256,-40 256,-28 256,-28 256,-22 262,-16 268,-16 268,-16 298,-16 298,-16 304,-16 310,-22 310,-28 310,-28 310,-40 310,-40 310,-46 304,-52 298,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;283&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;resp_a&lt;/text&gt;
&lt;/g&gt;
&lt;!-- worker1&amp;#45;&amp;gt;resp_a --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;worker1-&gt;resp_a&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M283,-104.65C283,-92.96 283,-77.19 283,-63.62&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;286.5,-63.92 283,-53.92 279.5,-63.92 286.5,-63.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;298.17&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;15ms&lt;/text&gt;
&lt;/g&gt;
&lt;!-- resp_b --&gt;
&lt;g id=&quot;node10&quot; class=&quot;node&quot;&gt;
&lt;title&gt;resp_b&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M434,-52C434,-52 404,-52 404,-52 398,-52 392,-46 392,-40 392,-40 392,-28 392,-28 392,-22 398,-16 404,-16 404,-16 434,-16 434,-16 440,-16 446,-22 446,-28 446,-28 446,-40 446,-40 446,-46 440,-52 434,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;419&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;resp_b&lt;/text&gt;
&lt;/g&gt;
&lt;!-- worker2&amp;#45;&amp;gt;resp_b --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;worker2-&gt;resp_b&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M419,-104.65C419,-92.96 419,-77.19 419,-63.62&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;422.5,-63.92 419,-53.92 415.5,-63.92 422.5,-63.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;434.17&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;15ms&lt;/text&gt;
&lt;/g&gt;
&lt;!-- resp_c --&gt;
&lt;g id=&quot;node11&quot; class=&quot;node&quot;&gt;
&lt;title&gt;resp_c&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M570,-52C570,-52 540,-52 540,-52 534,-52 528,-46 528,-40 528,-40 528,-28 528,-28 528,-22 534,-16 540,-16 540,-16 570,-16 570,-16 576,-16 582,-22 582,-28 582,-28 582,-40 582,-40 582,-46 576,-52 570,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;555&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;resp_c&lt;/text&gt;
&lt;/g&gt;
&lt;!-- worker3&amp;#45;&amp;gt;resp_c --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;worker3-&gt;resp_c&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M555,-104.65C555,-92.96 555,-77.19 555,-63.62&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;558.5,-63.92 555,-53.92 551.5,-63.92 558.5,-63.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;570.17&quot; y=&quot;-74.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;15ms&lt;/text&gt;
&lt;/g&gt;
&lt;!-- latency --&gt;
&lt;g id=&quot;node12&quot; class=&quot;node&quot;&gt;
&lt;title&gt;latency&lt;/title&gt;
&lt;ellipse fill=&quot;lightcoral&quot; stroke=&quot;black&quot; cx=&quot;687&quot; cy=&quot;-211.6&quot; rx=&quot;42.13&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;687&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Latency&lt;/text&gt;
&lt;/g&gt;
&lt;!-- throughput --&gt;
&lt;g id=&quot;node13&quot; class=&quot;node&quot;&gt;
&lt;title&gt;throughput&lt;/title&gt;
&lt;ellipse fill=&quot;lightblue&quot; stroke=&quot;black&quot; cx=&quot;687&quot; cy=&quot;-122.8&quot; rx=&quot;56.63&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;687&quot; y=&quot;-118.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Throughput&lt;/text&gt;
&lt;/g&gt;
&lt;!-- latency&amp;#45;&amp;gt;throughput --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;latency-&gt;throughput&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M687,-193.45C687,-181.76 687,-165.99 687,-152.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;690.5,-152.72 687,-142.72 683.5,-152.72 690.5,-152.72&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;711.48&quot; y=&quot;-163&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;trade-off&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Latency&lt;/strong&gt; measured in milliseconds or nanoseconds (time per operation)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Throughput&lt;/strong&gt; measured in requests per second or operations per second&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Goal&lt;/strong&gt;: maximize throughput while keeping latency within acceptable bounds&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Little’s Law&lt;/strong&gt;: &lt;code class=&quot;notranslate&quot;&gt;L = λ × W&lt;/code&gt; — average concurrency equals throughput times latency&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../performance-vs-scalability&quot; class=&quot;internal alias&quot; data-slug=&quot;performance-vs-scalability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Performance vs Scalability&lt;/a&gt; — latency and throughput are the two dimensions of performance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../back-pressure&quot; class=&quot;internal alias&quot; data-slug=&quot;back-pressure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Back Pressure&lt;/a&gt; — queue sizing affects both latency and throughput&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cdn-pull&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-pull&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Pull CDN&lt;/a&gt; — reduces latency by serving content from edge locations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — improves throughput by decoupling producers and consumers&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Tail latency matters&lt;/strong&gt;: Average latency hides outliers. P99 latency spikes often cause user-perceived slowness even when the average looks fine.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Throughput vs bandwidth&lt;/strong&gt;: Throughput is completed operations; bandwidth is capacity. You can have high bandwidth but low throughput due to protocol overhead or lock contention.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Coordinated omission&lt;/strong&gt;: If you exclude slow requests from measurements, reported latency looks artificially low — a common benchmarking mistake.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>layer4-load-balancing</title>
    <link href="https://animishraa05.github.io/wiki/system-design/layer4-load-balancing" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/layer4-load-balancing.md" />
    <summary>The Problem A single server can be overwhelmed by traffic.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="infrastructure" label="infrastructure" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A single server can be overwhelmed by traffic. Requests need to be distributed across multiple servers, but inspecting application-level content is expensive and unnecessary for basic distribution.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Layer 4 load balancers distribute requests using transport-layer information (source/destination IP and port) without inspecting packet contents, performing NAT to forward traffic to upstream servers.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;A client makes a TCP connection to the load balancer’s virtual IP.&lt;/li&gt;
&lt;li&gt;The L4 LB reads the TCP/UDP header fields (source IP, dest IP, ports).&lt;/li&gt;
&lt;li&gt;The LB selects a backend server using a scheduling algorithm (round robin, least connections, etc.).&lt;/li&gt;
&lt;li&gt;The LB performs Network Address Translation (NAT), rewriting the destination IP/port to the selected server.&lt;/li&gt;
&lt;li&gt;The server responds directly to the client (DSR mode) or through the LB.&lt;/li&gt;
&lt;li&gt;The LB sees only TCP handshake and layer 4 metadata — it never decrypts or inspects the payload.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: layer4_lb Pages: 1 --&gt;
&lt;svg width=&quot;562pt&quot; height=&quot;100pt&quot; viewBox=&quot;0.00 0.00 562.00 100.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 95.8)&quot;&gt;
&lt;title&gt;layer4_lb&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-95.8 558.27,-95.8 558.27,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CLIENT --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CLIENT&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;78.02,-36.8 7.34,-36.8 7.34,0 78.02,0 78.02,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.68&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Client&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.68&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(IP:port A)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;LB&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;293.45,-68.8 219.42,-68.8 219.42,-32 293.45,-32 293.45,-68.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;256.44&quot; y=&quot;-54&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Layer 4 LB&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;256.44&quot; y=&quot;-39.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(VIP:80)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CLIENT&amp;#45;&amp;gt;LB --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CLIENT-&gt;LB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M78.18,-23.61C113.48,-28.95 168.61,-37.28 208.01,-43.23&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;207.28,-46.66 217.69,-44.7 208.32,-39.74 207.28,-46.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;142.42&quot; y=&quot;-42.14&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;SYN dest=VIP:80&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S1&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;554.27,-36.8 468.9,-36.8 468.9,0 554.27,0 554.27,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;511.59&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Server 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;511.59&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(IP: 10.0.0.1)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;S1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;S1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M293.71,-45.82C336.49,-40.41 407.98,-31.37 457.12,-25.16&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;457.49,-28.64 466.98,-23.91 456.62,-21.69 457.49,-28.64&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;391.15&quot; y=&quot;-43.94&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;NAT: rewrite to 10.0.0.1:80&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1&amp;#45;&amp;gt;CLIENT --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S1-&gt;CLIENT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M468.57,-16.26C408.79,-13.48 295.75,-9.24 199.47,-11.4 162.51,-12.23 120.65,-14.17 89.64,-15.79&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;89.63,-12.29 79.83,-16.32 90,-19.28 89.63,-12.29&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;256.44&quot; y=&quot;-14.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;response (DSR or via LB)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S2&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;85.37,-91.8 0,-91.8 0,-55 85.37,-55 85.37,-91.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.68&quot; y=&quot;-77&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Server 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.68&quot; y=&quot;-62.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(IP: 10.0.0.2)&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Operates at the transport layer (TCP/UDP), never inspects payload content&lt;/li&gt;
&lt;li&gt;Uses Network Address Translation (NAT) to rewrite packet headers&lt;/li&gt;
&lt;li&gt;Lower CPU overhead per packet compared to Layer 7 load balancers&lt;/li&gt;
&lt;li&gt;Faster throughput on modern hardware due to simpler processing&lt;/li&gt;
&lt;li&gt;Supports any TCP/UDP protocol, not just HTTP&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt; — transport vs application layer routing tradeoffs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — L4 LB is the primary enabler of horizontal scaling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy&lt;/a&gt; — both terminate and forward traffic; LB focuses on distribution&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-passive-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-passive-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Passive Failover&lt;/a&gt; — LB can detect server failure and reroute traffic&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;L4 LB cannot route based on HTTP headers, cookies, or URL paths — all servers must be interchangeable&lt;/li&gt;
&lt;li&gt;Sticky sessions require client IP hashing or a separate session store since the LB cannot read cookies&lt;/li&gt;
&lt;li&gt;NAT rewrites break some protocols that embed IP addresses in the payload (FTP, SIP) without protocol-specific helpers&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>layer7-load-balancing</title>
    <link href="https://animishraa05.github.io/wiki/system-design/layer7-load-balancing" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/layer7-load-balancing.md" />
    <summary>The Problem Not all requests are equal — some requests need different backend treatment based on their content (e.g., API version, user type, resource type).</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="infrastructure" label="infrastructure" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Not all requests are equal — some requests need different backend treatment based on their content (e.g., API version, user type, resource type). Layer 4 distribution cannot make these distinctions.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Layer 7 load balancers inspect application-layer content (HTTP headers, cookies, message bodies) to make intelligent routing decisions based on request content rather than just IP and port.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;The L7 LB terminates the incoming TCP connection from the client.&lt;/li&gt;
&lt;li&gt;It reads the full request payload — HTTP method, URI, headers, cookies, body.&lt;/li&gt;
&lt;li&gt;It makes a routing decision based on content: route &lt;code class=&quot;notranslate&quot;&gt;/api/v2/&lt;/code&gt; to server group A, &lt;code class=&quot;notranslate&quot;&gt;/images/&lt;/code&gt; to dedicated media servers.&lt;/li&gt;
&lt;li&gt;It opens a new TCP connection to the selected backend server (or uses a keep-alive pool).&lt;/li&gt;
&lt;li&gt;It forwards the request, potentially transforming headers or rewriting paths.&lt;/li&gt;
&lt;li&gt;The response flows back through the LB, which may modify headers or compress content.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: layer7_lb Pages: 1 --&gt;
&lt;svg width=&quot;437pt&quot; height=&quot;155pt&quot; viewBox=&quot;0.00 0.00 437.00 155.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 150.8)&quot;&gt;
&lt;title&gt;layer7_lb&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-150.8 433.02,-150.8 433.02,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CLIENT --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CLIENT&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;54,-91.4 0,-91.4 0,-55.4 54,-55.4 54,-91.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-69.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;LB&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;235.74,-91.8 91,-91.8 91,-55 235.74,-55 235.74,-91.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;163.37&quot; y=&quot;-77&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Layer 7 LB&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;163.37&quot; y=&quot;-62.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(inspects headers, path)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CLIENT&amp;#45;&amp;gt;LB --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CLIENT-&gt;LB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.23,-73.4C61.69,-73.4 70.25,-73.4 79.2,-73.4&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;79.2,-76.9 89.2,-73.4 79.2,-69.9 79.2,-76.9&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- API --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;API&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;422.35,-146.8 342.33,-146.8 342.33,-110 422.35,-110 422.35,-146.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.34&quot; y=&quot;-132&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;API Servers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.34&quot; y=&quot;-117.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(/api/*)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;API --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;API&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M236.02,-91.56C267.18,-99.46 302.95,-108.53 331.2,-115.69&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;330.01,-119 340.56,-118.06 331.73,-112.21 330.01,-119&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;285.7&quot; y=&quot;-115.15&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;route /api/*&lt;/text&gt;
&lt;/g&gt;
&lt;!-- MEDIA --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;MEDIA&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;429.02,-91.8 335.66,-91.8 335.66,-55 429.02,-55 429.02,-91.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.34&quot; y=&quot;-77&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Media Servers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.34&quot; y=&quot;-62.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(/videos/*)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;MEDIA --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;MEDIA&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M236.02,-73.4C264.64,-73.4 297.14,-73.4 324.14,-73.4&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;323.83,-76.9 333.83,-73.4 323.83,-69.9 323.83,-76.9&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;285.7&quot; y=&quot;-76.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;route /videos/*&lt;/text&gt;
&lt;/g&gt;
&lt;!-- AUTH --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;AUTH&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;425.02,-36.8 339.66,-36.8 339.66,0 425.02,0 425.02,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.34&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Auth Servers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.34&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(/login)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;AUTH --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;AUTH&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M236.02,-55.24C266.07,-47.62 300.4,-38.92 328.14,-31.89&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;328.91,-35.3 337.74,-29.45 327.19,-28.52 328.91,-35.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;285.7&quot; y=&quot;-52.19&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;route /login&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Operates at the application layer (HTTP, gRPC, WebSocket)&lt;/li&gt;
&lt;li&gt;Inspects message content for advanced routing decisions&lt;/li&gt;
&lt;li&gt;More flexible routing than Layer 4 — path-based, header-based, cookie-based&lt;/li&gt;
&lt;li&gt;Higher CPU overhead per request due to content inspection and connection termination&lt;/li&gt;
&lt;li&gt;Commonly acts as a reverse proxy (e.g., Nginx, HAProxy, Envoy)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — application vs transport layer routing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy&lt;/a&gt; — L7 LB often functions as a reverse proxy with routing logic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — L7 LB enables granular scaling of individual service groups&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;TLS termination at the LB means the LB must manage certificates, adding key management complexity&lt;/li&gt;
&lt;li&gt;L7 LB is slower than L4 under high load because it terminates connections and inspects payloads&lt;/li&gt;
&lt;li&gt;WebSocket connections require special handling — the LB must recognize the upgrade header and switch to tunnel mode&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>Load Balancer vs Reverse Proxy — Infrastructure Component Comparison</title>
    <link href="https://animishraa05.github.io/wiki/system-design/load-balancer-vs-reverse-proxy" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/load-balancer-vs-reverse-proxy.md" />
    <summary>What’s Being Compared Load balancers and reverse proxies are both network intermediaries that sit between clients and servers, but they serve different primary purposes.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="infrastructure" label="infrastructure" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;whats-being-compared&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;What’s Being Compared&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#whats-being-compared&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Load balancers and reverse proxies are both network intermediaries that sit between clients and servers, but they serve different primary purposes. Load balancers distribute traffic across multiple servers; reverse proxies provide a unified interface to backend services. Understanding when to use which — or both — is essential for system architecture.&lt;/p&gt;
&lt;h2 id=&quot;the-core-tension&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Core Tension&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-core-tension&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The fundamental distinction is whether you have multiple servers doing the same thing (load balancer territory) or whether you need to abstract, protect, and augment a backend (reverse proxy territory). In practice, tools like Nginx and HAProxy blur this line by supporting both roles.&lt;/p&gt;
&lt;h2 id=&quot;comparison&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparison&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparison&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;&lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; / &lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy&lt;/a&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Primary purpose&lt;/td&gt;
&lt;td&gt;Distribute load across multiple servers&lt;/td&gt;
&lt;td&gt;Centralize and protect backend services&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;When needed&lt;/td&gt;
&lt;td&gt;Multiple servers serving same function&lt;/td&gt;
&lt;td&gt;Even a single server benefits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traffic distribution&lt;/td&gt;
&lt;td&gt;Yes — random, round-robin, least-loaded&lt;/td&gt;
&lt;td&gt;Not primary focus&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSL termination&lt;/td&gt;
&lt;td&gt;Supported&lt;/td&gt;
&lt;td&gt;Supported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Caching&lt;/td&gt;
&lt;td&gt;Not primary focus&lt;/td&gt;
&lt;td&gt;Supported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compression&lt;/td&gt;
&lt;td&gt;Not primary focus&lt;/td&gt;
&lt;td&gt;Supported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Static content serving&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Single point of failure&lt;/td&gt;
&lt;td&gt;Yes — requires multiple LBs&lt;/td&gt;
&lt;td&gt;Yes — requires multiple RPs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Examples&lt;/td&gt;
&lt;td&gt;HAProxy (LB mode), AWS ELB&lt;/td&gt;
&lt;td&gt;Nginx, HAProxy (reverse proxy mode)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;when-to-choose-load-balancer&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;When to Choose Load Balancer&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#when-to-choose-load-balancer&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;You have multiple application servers that need traffic distributed among them&lt;/li&gt;
&lt;li&gt;You need health checks to route away from failing servers&lt;/li&gt;
&lt;li&gt;You need session persistence (sticky sessions)&lt;/li&gt;
&lt;li&gt;You need to support horizontal scaling of stateless services&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;when-to-choose-reverse-proxy&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;When to Choose Reverse Proxy&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#when-to-choose-reverse-proxy&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;You have only one application server but want SSL termination, caching, or compression&lt;/li&gt;
&lt;li&gt;You want to hide backend server details from clients&lt;/li&gt;
&lt;li&gt;You need to serve static content directly without hitting the app server&lt;/li&gt;
&lt;li&gt;You want to compress responses before sending to clients&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-insight&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Insight&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-insight&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Nginx and HAProxy can act as &lt;strong&gt;both&lt;/strong&gt;, and in production they often do. A typical setup: reverse proxy (Nginx) terminates SSL, serves static files, and reverse-proxies API calls to a set of application servers behind a load balancer (HAProxy) that distributes requests. The lines blur because a Layer 7 load balancer IS a reverse proxy by function — it terminates connections, inspects content, and forwards to backends.&lt;/p&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — transport-level LB compared in this analysis&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt; — application-level LB, often same as reverse proxy&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy&lt;/a&gt; — the other side of this comparison&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — LB enables horizontal scaling&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../dns-system-design&quot; class=&quot;internal alias&quot; data-slug=&quot;dns-system-design&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DNS in System Design&lt;/a&gt; — DNS can direct traffic to load balancers&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>master-master-replication</title>
    <link href="https://animishraa05.github.io/wiki/system-design/master-master-replication" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/master-master-replication.md" />
    <summary>The Problem Master-slave replication has a single write point — if the master fails, the system cannot accept writes until a slave is promoted to master, causing write downtime.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Master-slave replication has a single write point — if the master fails, the system cannot accept writes until a slave is promoted to master, causing write downtime.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Master-master replication designates two or more database nodes as masters, each accepting both reads and writes. Masters synchronize writes between each other. If one master fails, the other continues serving both reads and writes, eliminating write downtime.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Both masters accept read and write operations from clients.&lt;/li&gt;
&lt;li&gt;A load balancer distributes write traffic between masters, or application logic decides which master to write to.&lt;/li&gt;
&lt;li&gt;Each write is recorded in the node’s binary log and replicated to the other master(s).&lt;/li&gt;
&lt;li&gt;Masters coordinate to apply each other’s changes, detecting and resolving conflicting writes.&lt;/li&gt;
&lt;li&gt;With two masters, conflicts are rare — with three or more, conflict resolution (last-write-wins, CRDTs, or custom merge logic) becomes necessary.&lt;/li&gt;
&lt;li&gt;If one master fails, the other continues handling all traffic.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: MasterMaster Pages: 1 --&gt;
&lt;svg width=&quot;619pt&quot; height=&quot;112pt&quot; viewBox=&quot;0.00 0.00 619.00 112.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 108.2)&quot;&gt;
&lt;title&gt;MasterMaster&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-108.2 614.94,-108.2 614.94,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Writes --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Writes&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M82.91,-46.6C82.91,-46.6 12,-46.6 12,-46.6 6,-46.6 0,-40.6 0,-34.6 0,-34.6 0,-22.6 0,-22.6 0,-16.6 6,-10.6 12,-10.6 12,-10.6 82.91,-10.6 82.91,-10.6 88.91,-10.6 94.91,-16.6 94.91,-22.6 94.91,-22.6 94.91,-34.6 94.91,-34.6 94.91,-40.6 88.91,-46.6 82.91,-46.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;47.45&quot; y=&quot;-24.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Write Queries&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;LB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M217.92,-46.6C217.92,-46.6 143.91,-46.6 143.91,-46.6 137.91,-46.6 131.91,-40.6 131.91,-34.6 131.91,-34.6 131.91,-22.6 131.91,-22.6 131.91,-16.6 137.91,-10.6 143.91,-10.6 143.91,-10.6 217.92,-10.6 217.92,-10.6 223.92,-10.6 229.92,-16.6 229.92,-22.6 229.92,-22.6 229.92,-34.6 229.92,-34.6 229.92,-40.6 223.92,-46.6 217.92,-46.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.91&quot; y=&quot;-24.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Load Balancer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Writes&amp;#45;&amp;gt;LB --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Writes-&gt;LB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M95.17,-28.6C103.29,-28.6 111.83,-28.6 120.24,-28.6&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;120.06,-32.1 130.06,-28.6 120.06,-25.1 120.06,-32.1&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- MasterA --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;MasterA&lt;/title&gt;
&lt;path fill=&quot;#d4f0d4&quot; stroke=&quot;black&quot; d=&quot;M403.33,-99C403.33,-101.87 378.29,-104.2 347.46,-104.2 316.62,-104.2 291.58,-101.87 291.58,-99 291.58,-99 291.58,-52.2 291.58,-52.2 291.58,-49.33 316.62,-47 347.46,-47 378.29,-47 403.33,-49.33 403.33,-52.2 403.33,-52.2 403.33,-99 403.33,-99&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M403.33,-99C403.33,-96.13 378.29,-93.8 347.46,-93.8 316.62,-93.8 291.58,-96.13 291.58,-99&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;347.46&quot; y=&quot;-79.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Master A&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;347.46&quot; y=&quot;-63&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Reads + Writes)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;MasterA --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;MasterA&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M230.39,-42.45C246.02,-46.91 263.62,-51.94 280.3,-56.7&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;279.07,-59.99 289.64,-59.37 280.99,-53.26 279.07,-59.99&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;260.75&quot; y=&quot;-57.71&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;50%&lt;/text&gt;
&lt;/g&gt;
&lt;!-- MasterB --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;MasterB&lt;/title&gt;
&lt;path fill=&quot;#d4f0d4&quot; stroke=&quot;black&quot; d=&quot;M610.94,-52C610.94,-54.87 585.9,-57.2 555.07,-57.2 524.24,-57.2 499.19,-54.87 499.19,-52 499.19,-52 499.19,-5.2 499.19,-5.2 499.19,-2.33 524.24,0 555.07,0 585.9,0 610.94,-2.33 610.94,-5.2 610.94,-5.2 610.94,-52 610.94,-52&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M610.94,-52C610.94,-49.13 585.9,-46.8 555.07,-46.8 524.24,-46.8 499.19,-49.13 499.19,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;555.07&quot; y=&quot;-32.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Master B&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;555.07&quot; y=&quot;-16&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Reads + Writes)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- LB&amp;#45;&amp;gt;MasterB --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;LB-&gt;MasterB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M230.19,-24.42C249.29,-22.97 271.46,-21.51 291.58,-20.8 358.22,-18.43 434.4,-21.32 487.46,-24.22&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;487.06,-27.71 497.25,-24.78 487.46,-20.72 487.06,-27.71&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;347.46&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;50%&lt;/text&gt;
&lt;/g&gt;
&lt;!-- MasterA&amp;#45;&amp;gt;MasterB --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;MasterA-&gt;MasterB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M414.81,-60.43C438.17,-55.09 464.4,-49.1 487.75,-43.76&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;414.27,-56.97 405.3,-62.61 415.83,-63.79 414.27,-56.97&quot;&gt;&lt;/polygon&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;488.51,-47.18 497.48,-41.54 486.95,-40.35 488.51,-47.18&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;451.26&quot; y=&quot;-61.89&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;replication&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Multi-master writes&lt;/strong&gt; — any master can accept write operations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Both serve reads and writes&lt;/strong&gt; — no read-only nodes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Continued operation on single failure&lt;/strong&gt; — remaining master handles all traffic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loosely consistent or higher write latency&lt;/strong&gt; — synchronous replication between masters adds latency; async risks divergence&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conflict resolution complexity&lt;/strong&gt; — concurrent writes to the same data on different masters must be reconciled&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — multi-writer vs single-writer with read replicas&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-active-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-active-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Active Failover&lt;/a&gt; — similar pattern where both servers handle traffic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../database-federation&quot; class=&quot;internal alias&quot; data-slug=&quot;database-federation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Database Federation&lt;/a&gt; — an alternative scaling approach that splits data by function&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — each shard can use master-master replication for high write availability&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cap-theorem&quot; class=&quot;internal alias&quot; data-slug=&quot;cap-theorem&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CAP Theorem&lt;/a&gt; — master-master typically favors availability and partition tolerance over strong consistency&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Write conflicts&lt;/strong&gt; — two masters accepting concurrent writes to the same row can produce conflicting values; resolution strategies (LWW, application-merge, CRDT) each have tradeoffs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Replication loops&lt;/strong&gt; — a write from Master A replicated to Master B may replicate back to Master A unless the system tracks which origin a change came from.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Higher write latency&lt;/strong&gt; — synchronous multi-master requires each write to be acknowledged by all masters, increasing p99 write latency significantly.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>master-slave-replication</title>
    <link href="https://animishraa05.github.io/wiki/system-design/master-slave-replication" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/master-slave-replication.md" />
    <summary>The Problem A single database is a single point of failure — if it goes down, the entire system loses data access.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A single database is a single point of failure — if it goes down, the entire system loses data access. It also creates a read bottleneck: all read queries hit one server, limiting throughput.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Master-slave replication designates one database as the master (handling all writes) and one or more slaves (handling read queries). The master asynchronously replicates writes to slaves. If the master fails, the system runs in read-only mode until a slave is promoted to master.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;All write operations (INSERT, UPDATE, DELETE) are sent to the master database.&lt;/li&gt;
&lt;li&gt;The master records the write in its binary log (binlog).&lt;/li&gt;
&lt;li&gt;Slaves connect to the master and pull changes from the binlog.&lt;/li&gt;
&lt;li&gt;Slaves replay the changes locally, staying eventually consistent with the master.&lt;/li&gt;
&lt;li&gt;Read queries can be routed to any slave to distribute read load.&lt;/li&gt;
&lt;li&gt;Slaves can chain — one slave acts as a replication source for other slaves (tree topology).&lt;/li&gt;
&lt;li&gt;If the master fails, an operator or automated system promotes a slave to become the new master.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: MasterSlave Pages: 1 --&gt;
&lt;svg width=&quot;329pt&quot; height=&quot;248pt&quot; viewBox=&quot;0.00 0.00 329.00 248.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 244.2)&quot;&gt;
&lt;title&gt;MasterSlave&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-244.2 325.04,-244.2 325.04,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Writes --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Writes&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M231.97,-240.2C231.97,-240.2 161.07,-240.2 161.07,-240.2 155.07,-240.2 149.07,-234.2 149.07,-228.2 149.07,-228.2 149.07,-216.2 149.07,-216.2 149.07,-210.2 155.07,-204.2 161.07,-204.2 161.07,-204.2 231.97,-204.2 231.97,-204.2 237.97,-204.2 243.97,-210.2 243.97,-216.2 243.97,-216.2 243.97,-228.2 243.97,-228.2 243.97,-234.2 237.97,-240.2 231.97,-240.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;196.52&quot; y=&quot;-218&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Write Queries&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Master --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Master&lt;/title&gt;
&lt;path fill=&quot;#d4f0d4&quot; stroke=&quot;black&quot; d=&quot;M252.39,-162C252.39,-164.87 227.35,-167.2 196.52,-167.2 165.69,-167.2 140.64,-164.87 140.64,-162 140.64,-162 140.64,-115.2 140.64,-115.2 140.64,-112.33 165.69,-110 196.52,-110 227.35,-110 252.39,-112.33 252.39,-115.2 252.39,-115.2 252.39,-162 252.39,-162&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M252.39,-162C252.39,-159.13 227.35,-156.8 196.52,-156.8 165.69,-156.8 140.64,-159.13 140.64,-162&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;196.52&quot; y=&quot;-142.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Master&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;196.52&quot; y=&quot;-126&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Reads + Writes)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Writes&amp;#45;&amp;gt;Master --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Writes-&gt;Master&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M196.52,-203.89C196.52,-196.54 196.52,-187.65 196.52,-178.85&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;200.02,-178.99 196.52,-168.99 193.02,-178.99 200.02,-178.99&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Reads --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Reads&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M89.42,-156.6C89.42,-156.6 21.62,-156.6 21.62,-156.6 15.62,-156.6 9.62,-150.6 9.62,-144.6 9.62,-144.6 9.62,-132.6 9.62,-132.6 9.62,-126.6 15.62,-120.6 21.62,-120.6 21.62,-120.6 89.42,-120.6 89.42,-120.6 95.42,-120.6 101.42,-126.6 101.42,-132.6 101.42,-132.6 101.42,-144.6 101.42,-144.6 101.42,-150.6 95.42,-156.6 89.42,-156.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;55.52&quot; y=&quot;-134.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Read Queries&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Slave1 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Slave1&lt;/title&gt;
&lt;path fill=&quot;#f0f0d4&quot; stroke=&quot;black&quot; d=&quot;M91.04,-52C91.04,-54.87 70.64,-57.2 45.52,-57.2 20.4,-57.2 0,-54.87 0,-52 0,-52 0,-5.2 0,-5.2 0,-2.33 20.4,0 45.52,0 70.64,0 91.04,-2.33 91.04,-5.2 91.04,-5.2 91.04,-52 91.04,-52&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M91.04,-52C91.04,-49.13 70.64,-46.8 45.52,-46.8 20.4,-46.8 0,-49.13 0,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;45.52&quot; y=&quot;-32.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Slave 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;45.52&quot; y=&quot;-16&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Reads Only)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Reads&amp;#45;&amp;gt;Slave1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Reads-&gt;Slave1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M50.36,-120.45C48.08,-111.98 45.65,-101.54 44.52,-92 43.64,-84.57 43.3,-76.61 43.28,-68.94&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;46.78,-69.21 43.45,-59.15 39.78,-69.09 46.78,-69.21&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Slave2 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Slave2&lt;/title&gt;
&lt;path fill=&quot;#f0f0d4&quot; stroke=&quot;black&quot; d=&quot;M321.04,-52C321.04,-54.87 300.64,-57.2 275.52,-57.2 250.4,-57.2 230,-54.87 230,-52 230,-52 230,-5.2 230,-5.2 230,-2.33 250.4,0 275.52,0 300.64,0 321.04,-2.33 321.04,-5.2 321.04,-5.2 321.04,-52 321.04,-52&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M321.04,-52C321.04,-49.13 300.64,-46.8 275.52,-46.8 250.4,-46.8 230,-49.13 230,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;275.52&quot; y=&quot;-32.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Slave 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;275.52&quot; y=&quot;-16&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Reads Only)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Reads&amp;#45;&amp;gt;Slave2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Reads-&gt;Slave2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M93.41,-120.16C110.7,-111.96 131.33,-101.84 149.52,-92 162.28,-85.09 164.66,-81.92 177.52,-75.2 194.8,-66.17 199.83,-65.39 217.52,-57.2 218.14,-56.91 218.76,-56.63 219.38,-56.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;220.71,-59.58 228.28,-52.18 217.74,-53.24 220.71,-59.58&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Slave3 --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Slave3&lt;/title&gt;
&lt;path fill=&quot;#f0f0d4&quot; stroke=&quot;black&quot; d=&quot;M208.04,-52C208.04,-54.87 187.64,-57.2 162.52,-57.2 137.4,-57.2 117,-54.87 117,-52 117,-52 117,-5.2 117,-5.2 117,-2.33 137.4,0 162.52,0 187.64,0 208.04,-2.33 208.04,-5.2 208.04,-5.2 208.04,-52 208.04,-52&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M208.04,-52C208.04,-49.13 187.64,-46.8 162.52,-46.8 137.4,-46.8 117,-49.13 117,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;162.52&quot; y=&quot;-32.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Slave 3&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;162.52&quot; y=&quot;-16&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Reads Only)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Reads&amp;#45;&amp;gt;Slave3 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Reads-&gt;Slave3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M55.47,-120.27C56.3,-106.69 59.41,-88.01 69.52,-75.2 72.43,-71.51 88.5,-63.22 106.48,-54.7&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;107.64,-58.02 115.22,-50.62 104.68,-51.68 107.64,-58.02&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Master&amp;#45;&amp;gt;Slave1 --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Master-&gt;Slave1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M144.52,-111.47C134.02,-105.51 123.26,-98.89 113.66,-92 102.46,-83.97 91.1,-74.29 80.95,-64.99&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;83.53,-62.62 73.84,-58.34 78.75,-67.73 83.53,-62.62&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;143.59&quot; y=&quot;-79.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;replication&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Master&amp;#45;&amp;gt;Slave2 --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Master-&gt;Slave2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M229.66,-109.99C235.35,-104.38 240.9,-98.27 245.52,-92 250.93,-84.65 255.77,-76.17 259.91,-67.88&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;263.02,-69.48 264.11,-58.94 256.68,-66.5 263.02,-69.48&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;285.58&quot; y=&quot;-79.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;replication&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Master&amp;#45;&amp;gt;Slave3 --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Master-&gt;Slave3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M187.67,-109.51C183.74,-97.01 179.04,-82.08 174.77,-68.53&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;178.12,-67.48 171.77,-59 171.44,-69.59 178.12,-67.48&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;211.49&quot; y=&quot;-79.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;replication&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Single write master&lt;/strong&gt; — all writes go through one node, simplifying conflict resolution&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple read slaves&lt;/strong&gt; — read capacity scales linearly with number of slaves&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Asynchronous replication&lt;/strong&gt; — slaves may lag behind the master (eventual consistency)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Read-only on master failure&lt;/strong&gt; — writes stop until a slave is promoted&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Requires promotion logic&lt;/strong&gt; — automated or manual failover to elect a new master&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../master-master-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-master-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Master Replication&lt;/a&gt; — single write point vs multiple write points&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../active-passive-failover&quot; class=&quot;internal alias&quot; data-slug=&quot;active-passive-failover&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Active-Passive Failover&lt;/a&gt; — similar pattern where one server is active, another stands by&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../strong-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;strong-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Strong Consistency&lt;/a&gt; — reading from the master guarantees consistency; slaves may serve stale data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — each shard can use master-slave replication for fault tolerance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sql-tuning&quot; class=&quot;internal alias&quot; data-slug=&quot;sql-tuning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SQL Tuning&lt;/a&gt; — tuning benefits both master (write performance) and slaves (read performance)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Replication lag&lt;/strong&gt; — under heavy write load, slaves can fall seconds or minutes behind, serving stale data to users.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Split-brain on async failover&lt;/strong&gt; — if the old master comes back after a slave is promoted, two masters may accept writes. Use fencing or STONITH to prevent this.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not all storage engines support it&lt;/strong&gt; — MySQL MyISAM does not support replication the same way InnoDB does; check engine compatibility.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>message-queues</title>
    <link href="https://animishraa05.github.io/wiki/system-design/message-queues" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/message-queues.md" />
    <summary>The Problem Synchronous execution of expensive operations blocks the user and degrades responsiveness.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="messaging" label="messaging" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Synchronous execution of expensive operations blocks the user and degrades responsiveness. Direct point-to-point integration between services creates tight coupling and makes systems brittle under load spikes.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Message queues receive, hold, and deliver messages asynchronously — a publisher sends a job, a worker picks it up later, and the user is not blocked. This decouples producers from consumers and provides a buffer during traffic spikes.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Application (publisher) sends a job message to the queue.&lt;/li&gt;
&lt;li&gt;Queue acknowledges receipt immediately.&lt;/li&gt;
&lt;li&gt;Application notifies the user of job status (“processing”).&lt;/li&gt;
&lt;li&gt;A worker (consumer) picks up the job from the queue.&lt;/li&gt;
&lt;li&gt;Worker processes the job and signals completion.&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;Popular implementations: Redis (simple, high throughput, messages can be lost), RabbitMQ (AMQP, managed delivery guarantees), and SQS (fully hosted, at-least-once delivery, may deliver duplicates).&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: MessageQueues Pages: 1 --&gt;
&lt;svg width=&quot;513pt&quot; height=&quot;149pt&quot; viewBox=&quot;0.00 0.00 513.00 149.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 145.18)&quot;&gt;
&lt;title&gt;MessageQueues&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-145.18 509.3,-145.18 509.3,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Pub --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Pub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M63.86,-98.6C63.86,-98.6 12,-98.6 12,-98.6 6,-98.6 0,-92.6 0,-86.6 0,-86.6 0,-69 0,-69 0,-63 6,-57 12,-57 12,-57 63.86,-57 63.86,-57 69.86,-57 75.86,-63 75.86,-69 75.86,-69 75.86,-86.6 75.86,-86.6 75.86,-92.6 69.86,-98.6 63.86,-98.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;37.93&quot; y=&quot;-82&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Publisher&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;37.93&quot; y=&quot;-65.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Producer)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Queue&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M297.06,-129.8C297.06,-129.8 216.03,-129.8 216.03,-129.8 210.03,-129.8 204.03,-123.8 204.03,-117.8 204.03,-117.8 204.03,-105.8 204.03,-105.8 204.03,-99.8 210.03,-93.8 216.03,-93.8 216.03,-93.8 297.06,-93.8 297.06,-93.8 303.06,-93.8 309.06,-99.8 309.06,-105.8 309.06,-105.8 309.06,-117.8 309.06,-117.8 309.06,-123.8 303.06,-129.8 297.06,-129.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;256.54&quot; y=&quot;-107.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Message Queue&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Pub&amp;#45;&amp;gt;Queue --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Pub-&gt;Queue&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M62.93,-99.09C71.99,-105.79 82.79,-112.34 93.86,-115.8 125.35,-125.63 161.99,-125.6 192.42,-122.68&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;192.7,-126.17 202.25,-121.6 191.93,-119.21 192.7,-126.17&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;139.95&quot; y=&quot;-128.58&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Publish job&lt;/text&gt;
&lt;/g&gt;
&lt;!-- User --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;User&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M271.54,-75.8C271.54,-75.8 241.54,-75.8 241.54,-75.8 235.54,-75.8 229.54,-69.8 229.54,-63.8 229.54,-63.8 229.54,-51.8 229.54,-51.8 229.54,-45.8 235.54,-39.8 241.54,-39.8 241.54,-39.8 271.54,-39.8 271.54,-39.8 277.54,-39.8 283.54,-45.8 283.54,-51.8 283.54,-51.8 283.54,-63.8 283.54,-63.8 283.54,-69.8 277.54,-75.8 271.54,-75.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;256.54&quot; y=&quot;-53.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;User&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Pub&amp;#45;&amp;gt;User --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Pub-&gt;User&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M76.34,-63.22C82.13,-61.48 88.1,-59.98 93.86,-59 135.88,-51.85 184.94,-52.76 217.9,-54.68&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;217.56,-58.17 227.76,-55.33 218.01,-51.18 217.56,-58.17&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;139.95&quot; y=&quot;-63.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Job submitted&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Pub --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Pub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M203.69,-98.54C197.75,-97.24 191.78,-96.03 186.03,-95 153.44,-89.18 116.42,-84.86 87.67,-82.01&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;88.09,-78.53 77.8,-81.06 87.42,-85.5 88.09,-78.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;139.95&quot; y=&quot;-99.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. ACK&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Worker --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Worker&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M493.3,-41.6C493.3,-41.6 434.42,-41.6 434.42,-41.6 428.42,-41.6 422.42,-35.6 422.42,-29.6 422.42,-29.6 422.42,-12 422.42,-12 422.42,-6 428.42,0 434.42,0 434.42,0 493.3,0 493.3,0 499.3,0 505.3,-6 505.3,-12 505.3,-12 505.3,-29.6 505.3,-29.6 505.3,-35.6 499.3,-41.6 493.3,-41.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;463.86&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Worker&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;463.86&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Consumer)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Worker --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Worker&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M299.09,-93.38C331.59,-78.98 376.93,-58.89 411.66,-43.49&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;412.97,-46.74 420.69,-39.49 410.13,-40.34 412.97,-46.74&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;365.74&quot; y=&quot;-83.97&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Deliver job&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Worker&amp;#45;&amp;gt;Pub --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Worker-&gt;Pub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M422.21,-15.18C370.99,-9.13 280.4,-1.9 204.03,-14 153.18,-22.05 141.43,-30.09 93.86,-49.8 91.4,-50.82 88.9,-51.91 86.39,-53.04&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;85.02,-49.81 77.46,-57.23 88,-56.15 85.02,-49.81&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;256.54&quot; y=&quot;-18.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Completion&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Asynchronous processing — producers never wait for consumers&lt;/li&gt;
&lt;li&gt;Decouples producers and consumers (they don’t need to know about each other)&lt;/li&gt;
&lt;li&gt;Buffers messages during traffic spikes, preventing producer overload&lt;/li&gt;
&lt;li&gt;Worker-based processing enables horizontal scaling of consumers&lt;/li&gt;
&lt;li&gt;Different reliability guarantees (at-most-once, at-least-once, exactly-once)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../task-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;task-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Task Queues&lt;/a&gt; — message queues focus on message delivery; task queues focus on scheduling and executing compute work&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../back-pressure&quot; class=&quot;internal alias&quot; data-slug=&quot;back-pressure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Back Pressure&lt;/a&gt; — queue growth beyond capacity triggers back pressure mechanisms&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../microservices-architecture&quot; class=&quot;internal alias&quot; data-slug=&quot;microservices-architecture&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Microservices Architecture&lt;/a&gt; — queues enable loose coupling between services&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../write-behind-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-behind-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Behind Cache&lt;/a&gt; — both use async processing patterns to decouple operations&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Message ordering&lt;/strong&gt;: Most queues do not guarantee strict FIFO ordering under high concurrency. Use a FIFO queue or sequence IDs if order matters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Duplicate messages&lt;/strong&gt;: At-least-once delivery guarantees can result in duplicate processing. Workers should be idempotent.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Poison pills&lt;/strong&gt;: Malformed messages that cause workers to fail repeatedly can block the queue. Implement dead-letter queues to isolate them.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>microservices-architecture</title>
    <link href="https://animishraa05.github.io/wiki/system-design/microservices-architecture" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/microservices-architecture.md" />
    <summary>The Problem Monolithic applications grow too large for teams to develop, test, deploy, and scale independently.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="architecture" label="architecture" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Monolithic applications grow too large for teams to develop, test, deploy, and scale independently. A single codebase creates coordination bottlenecks, long deployment cycles, and forces all parts of the system to use the same technology stack.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Microservices architecture decomposes an application into independently deployable, small, modular services — each running its own process and communicating via lightweight mechanisms (HTTP, RPC, or message queues). Each service is built around a specific business capability and can be developed, deployed, and scaled independently.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Analyze the application domain and identify bounded contexts (e.g., user profile, feed, search, payments).&lt;/li&gt;
&lt;li&gt;Create a separate service for each bounded context, each with its own codebase and data store.&lt;/li&gt;
&lt;li&gt;Define service APIs (REST, gRPC, or GraphQL) for inter-service communication.&lt;/li&gt;
&lt;li&gt;Deploy each service as an independent process — typically in containers.&lt;/li&gt;
&lt;li&gt;Each team owns one or more services end-to-end: development, testing, deployment, and operations.&lt;/li&gt;
&lt;li&gt;Services scale independently — the feed service can have 10 instances while payments runs on 2.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: Microservices Pages: 1 --&gt;
&lt;svg width=&quot;307pt&quot; height=&quot;329pt&quot; viewBox=&quot;0.00 0.00 307.00 329.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 324.8)&quot;&gt;
&lt;title&gt;Microservices&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-324.8 303.19,-324.8 303.19,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_services&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; points=&quot;8,-8 8,-184.8 246,-184.8 246,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127&quot; y=&quot;-168.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Microservices&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M270.92,-320.8C270.92,-320.8 217.08,-320.8 217.08,-320.8 211.08,-320.8 205.08,-314.8 205.08,-308.8 205.08,-308.8 205.08,-296.8 205.08,-296.8 205.08,-290.8 211.08,-284.8 217.08,-284.8 217.08,-284.8 270.92,-284.8 270.92,-284.8 276.92,-284.8 282.92,-290.8 282.92,-296.8 282.92,-296.8 282.92,-308.8 282.92,-308.8 282.92,-314.8 276.92,-320.8 270.92,-320.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;244&quot; y=&quot;-298.6&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;Client App&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Gateway --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Gateway&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M277.91,-247.8C277.91,-247.8 210.09,-247.8 210.09,-247.8 204.09,-247.8 198.09,-241.8 198.09,-235.8 198.09,-235.8 198.09,-223.8 198.09,-223.8 198.09,-217.8 204.09,-211.8 210.09,-211.8 210.09,-211.8 277.91,-211.8 277.91,-211.8 283.91,-211.8 289.91,-217.8 289.91,-223.8 289.91,-223.8 289.91,-235.8 289.91,-235.8 289.91,-241.8 283.91,-247.8 277.91,-247.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;244&quot; y=&quot;-225.6&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;API Gateway&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;Gateway --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;Gateway&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M244,-284.61C244,-277.03 244,-267.9 244,-259.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;247.5,-259.34 244,-249.34 240.5,-259.34 247.5,-259.34&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Users --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Users&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M107.96,-57.6C107.96,-57.6 44.04,-57.6 44.04,-57.6 38.04,-57.6 32.04,-51.6 32.04,-45.6 32.04,-45.6 32.04,-28 32.04,-28 32.04,-22 38.04,-16 44.04,-16 44.04,-16 107.96,-16 107.96,-16 113.96,-16 119.96,-22 119.96,-28 119.96,-28 119.96,-45.6 119.96,-45.6 119.96,-51.6 113.96,-57.6 107.96,-57.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;76&quot; y=&quot;-41&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;User Service&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;76&quot; y=&quot;-24.2&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;(Own DB)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Gateway&amp;#45;&amp;gt;Users --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Gateway-&gt;Users&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M249.69,-211.39C256.54,-187.05 265.03,-142.25 247,-110.4 220.35,-63.33 187.56,-74.33 131.25,-58.03&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;132.49,-54.75 121.9,-55.1 130.4,-61.43 132.49,-54.75&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Feed --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Feed&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M92.35,-152C92.35,-152 27.65,-152 27.65,-152 21.65,-152 15.65,-146 15.65,-140 15.65,-140 15.65,-122.4 15.65,-122.4 15.65,-116.4 21.65,-110.4 27.65,-110.4 27.65,-110.4 92.35,-110.4 92.35,-110.4 98.35,-110.4 104.35,-116.4 104.35,-122.4 104.35,-122.4 104.35,-140 104.35,-140 104.35,-146 98.35,-152 92.35,-152&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60&quot; y=&quot;-135.4&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;Feed Service&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60&quot; y=&quot;-118.6&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;(Own DB)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Gateway&amp;#45;&amp;gt;Feed --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Gateway-&gt;Feed&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M197.79,-218.81C171.63,-211.84 139.03,-200.86 113,-184.8 102.47,-178.3 92.42,-169.33 83.96,-160.64&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;86.77,-158.53 77.4,-153.59 81.65,-163.3 86.77,-158.53&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Search --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Search&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M225.78,-57.6C225.78,-57.6 150.22,-57.6 150.22,-57.6 144.22,-57.6 138.22,-51.6 138.22,-45.6 138.22,-45.6 138.22,-28 138.22,-28 138.22,-22 144.22,-16 150.22,-16 150.22,-16 225.78,-16 225.78,-16 231.78,-16 237.78,-22 237.78,-28 237.78,-28 237.78,-45.6 237.78,-45.6 237.78,-51.6 231.78,-57.6 225.78,-57.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;188&quot; y=&quot;-41&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;Search Service&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;188&quot; y=&quot;-24.2&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;(Own DB)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Gateway&amp;#45;&amp;gt;Search --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Gateway-&gt;Search&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M267.43,-211.4C272.52,-206.34 277.22,-200.38 280,-193.8 300.44,-145.41 309.25,-119.24 280,-75.6 272.49,-64.39 260.99,-56.51 248.65,-50.96&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;250.14,-47.78 239.55,-47.38 247.57,-54.3 250.14,-47.78&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Payments --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Payments&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M225.96,-152C225.96,-152 134.04,-152 134.04,-152 128.04,-152 122.04,-146 122.04,-140 122.04,-140 122.04,-122.4 122.04,-122.4 122.04,-116.4 128.04,-110.4 134.04,-110.4 134.04,-110.4 225.96,-110.4 225.96,-110.4 231.96,-110.4 237.96,-116.4 237.96,-122.4 237.96,-122.4 237.96,-140 237.96,-140 237.96,-146 231.96,-152 225.96,-152&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180&quot; y=&quot;-135.4&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;Payments Service&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180&quot; y=&quot;-118.6&quot; font-family=&quot;monospace&quot; font-size=&quot;14.00&quot;&gt;(Own DB)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Gateway&amp;#45;&amp;gt;Payments --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Gateway-&gt;Payments&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M232.56,-211.53C223.36,-197.65 210.24,-177.84 199.4,-161.48&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;202.61,-159.99 194.17,-153.59 196.78,-163.86 202.61,-159.99&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Feed&amp;#45;&amp;gt;Users --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Feed-&gt;Users&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M61.79,-110.14C62.87,-99.78 64.44,-86.96 66.54,-75.6 66.93,-73.45 67.38,-71.25 67.86,-69.03&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;71.2,-70.11 70.07,-59.57 64.38,-68.51 71.2,-70.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;79.77&quot; y=&quot;-79.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RPC&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Feed&amp;#45;&amp;gt;Search --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Feed-&gt;Search&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M77.36,-109.96C87.48,-98.94 100.9,-85.55 114.54,-75.6 120.45,-71.28 126.93,-67.18 133.51,-63.39&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;134.79,-66.68 141.85,-58.78 131.4,-60.55 134.79,-66.68&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.77&quot; y=&quot;-79.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RPC&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Payments&amp;#45;&amp;gt;Users --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Payments-&gt;Users&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M170.26,-110.01C164.15,-98.87 155.45,-85.36 145,-75.6 140.33,-71.24 135.06,-67.21 129.58,-63.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;131.82,-60.81 121.48,-58.5 128.12,-66.76 131.82,-60.81&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;172.07&quot; y=&quot;-79.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RPC&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Independently deployable&lt;/strong&gt; — each service can be deployed without coordinating with other teams&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Single responsibility&lt;/strong&gt; — each service owns one business capability&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Polyglot technology&lt;/strong&gt; — services can use different languages, databases, and frameworks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Team autonomy&lt;/strong&gt; — teams own their services end-to-end&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Isolated failure&lt;/strong&gt; — a crash in one service doesn’t bring down the entire system&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; monolithic architecture — a single deployable unit vs many independent services&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../service-discovery&quot; class=&quot;internal alias&quot; data-slug=&quot;service-discovery&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Service Discovery&lt;/a&gt; — microservices need dynamic discovery to find each other’s network locations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — enable asynchronous, reliable communication between services&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — each service can be scaled independently based on its own load&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../rpc-remote-procedure-call&quot; class=&quot;internal alias&quot; data-slug=&quot;rpc-remote-procedure-call&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;RPC&lt;/a&gt; — a common communication mechanism between microservices&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Distributed monolith anti-pattern&lt;/strong&gt; — services that are tightly coupled via shared databases or chatty APIs defeat the purpose of microservices.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Operational complexity&lt;/strong&gt; — deploying 10 services is harder than deploying 1; requires container orchestration (Kubernetes), service mesh, and observability tooling.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data consistency&lt;/strong&gt; — transactions spanning multiple services require sagas or eventual consistency; no cross-service ACID.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>nosql-database-types</title>
    <link href="https://animishraa05.github.io/wiki/system-design/nosql-database-types" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/nosql-database-types.md" />
    <summary>The Problem Relational databases (RDBMS) enforce rigid schemas, require ACID transactions, and struggle with semi-structured data, massive scale, and flexible schemas.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Relational databases (RDBMS) enforce rigid schemas, require ACID transactions, and struggle with semi-structured data, massive scale, and flexible schemas. Many modern applications need faster writes, horizontal scalability, or specialized data models that SQL databases do not provide efficiently.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;NoSQL databases are categorized into four main types based on their data model: key-value stores (hash table), document stores (JSON/XML), wide column stores (nested maps of rows and columns), and graph databases (nodes and edges). Each type trades ACID guarantees for performance, scalability, or flexibility in a specific access pattern.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Key-value stores&lt;/strong&gt; (Redis, Memcached, DynamoDB): data is stored as opaque blobs keyed by a unique identifier. O(1) reads/writes, in-memory or SSD-backed. Best for caching, session storage, and leaderboards.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Document stores&lt;/strong&gt; (MongoDB, CouchDB): data is stored as self-describing documents (JSON, BSON, XML). Documents can have nested structures and varying schemas. Best for catalogs, content management, and event logging.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Wide column stores&lt;/strong&gt; (BigTable, HBase, Cassandra): data is organized as &lt;code class=&quot;notranslate&quot;&gt;ColumnFamily&amp;#x3C;RowKey, Columns&amp;#x3C;ColKey, Value, Timestamp&gt;&gt;&lt;/code&gt;. Rows can have different columns. Best for time-series data, IoT, and analytics.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Graph databases&lt;/strong&gt; (Neo4j, Amazon Neptune): data is stored as nodes (entities) and edges (relationships) with properties on both. Best for social graphs, recommendation engines, and fraud detection.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;digraph NoSQLTypes {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    rankdir=TB;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    node [shape=box, style=rounded];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    NoSQL [label=&quot;NoSQL Databases&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    KV [label=&quot;Key-Value Store\nRedis, Memcached\nO(1) lookups&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    Doc [label=&quot;Document Store\nMongoDB, CouchDB\nJSON documents&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    Wide [label=&quot;Wide Column Store\nCassandra, HBase\nColumn families&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    Graph [label=&quot;Graph Database\nNeo4j, Neptune\nNodes + Edges&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    UseKV [label=&quot;Caching\nSessions\nLeaderboards&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    UseDoc [label=&quot;Catalogs\nCMS\nEvent logs&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    UseWide [label=&quot;Time series\nIoT\nAnalytics&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    UseGraph [label=&quot;Social graphs\nRecommendations\nFraud&quot;];&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    NoSQL -&gt; KV;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    NoSQL -&gt; Doc;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    NoSQL -&gt; Wide;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    NoSQL -&gt; Graph;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    KV -&gt; UseKV;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    Doc -&gt; UseDoc;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    Wide -&gt; UseWide;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    Graph -&gt; UseGraph;&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;BASE semantics&lt;/strong&gt; — Basically Available, Soft state, Eventual consistency (instead of ACID)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Denormalized by nature&lt;/strong&gt; — data is stored in read-optimized shapes; joins happen in application code&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No true ACID transactions&lt;/strong&gt; — most NoSQL databases do not support multi-document/row transactions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Designed for horizontal scaling&lt;/strong&gt; — built-in sharding and replication for massive scale&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Each type optimized for specific access patterns&lt;/strong&gt; — choosing the wrong type leads to poor performance&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../sql-vs-nosql&quot; class=&quot;internal alias&quot; data-slug=&quot;sql-vs-nosql&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SQL vs NoSQL&lt;/a&gt; — a synthesis comparing relational and non-relational approaches&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cap-theorem&quot; class=&quot;internal alias&quot; data-slug=&quot;cap-theorem&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CAP Theorem&lt;/a&gt; — NoSQL databases typically prioritize Availability and Partition tolerance over Consistency&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../denormalization&quot; class=&quot;internal alias&quot; data-slug=&quot;denormalization&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Denormalization&lt;/a&gt; — NoSQL databases are inherently denormalized; data duplication is by design&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — most NoSQL databases have built-in sharding, making horizontal scaling straightforward&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — key-value stores (Redis, Memcached) are the most common caching layer&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Wrong tool for the job&lt;/strong&gt; — using a document store for deeply relational data (e.g., accounting systems) leads to application-level join spaghetti and data inconsistency.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NoSQL does not mean no schema&lt;/strong&gt; — while schemas are flexible at write time, the application code implicitly defines a schema that must be managed; schema drift is a real problem.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Eventual consistency surprises&lt;/strong&gt; — reading your own write may return stale data; this breaks user expectations in applications like social media or e-commerce.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>performance-vs-scalability</title>
    <link href="https://animishraa05.github.io/wiki/system-design/performance-vs-scalability" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/performance-vs-scalability.md" />
    <summary>The Problem Engineers often use “performance” and “scalability” interchangeably, leading to incorrect architectural decisions.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="system-design" label="system-design" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Engineers often use “performance” and “scalability” interchangeably, leading to incorrect architectural decisions. A system that performs well for a single user may collapse under load, while a scalable system may be individually slow.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Performance measures how fast a system handles a single unit of work (response time for one request). Scalability measures how well the system maintains that performance as load increases (throughput with added resources). A system can be performant but not scalable, or scalable but not performant.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Measure baseline&lt;/strong&gt;: Determine response time for a single request under minimal load (performance baseline).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Increase load&lt;/strong&gt;: Gradually ramp up concurrent requests while monitoring response time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Identify knee point&lt;/strong&gt;: Observe where response time degrades significantly — the system is no longer scaling.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add resources&lt;/strong&gt;: Increase nodes, memory, or connections. If response time returns to baseline, the system scales horizontally.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Re-evaluate&lt;/strong&gt;: Continue adding load until the next knee point. Diminishing returns indicate scaling limits.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;718pt&quot; height=&quot;330pt&quot; viewBox=&quot;0.00 0.00 718.00 330.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 326)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-326 713.68,-326 713.68,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_perf&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;16.57,-8 16.57,-85 462.42,-85 462.42,-8 16.57,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;239.49&quot; y=&quot;-68.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Performance&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_scalability&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;12.29,-93 12.29,-278 701.68,-278 701.68,-93 12.29,-93&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;356.98&quot; y=&quot;-261.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Scalability&lt;/text&gt;
&lt;/g&gt;
&lt;!-- req --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;req&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.17,-52C84.17,-52 36.57,-52 36.57,-52 30.57,-52 24.57,-46 24.57,-40 24.57,-40 24.57,-28 24.57,-28 24.57,-22 30.57,-16 36.57,-16 36.57,-16 84.17,-16 84.17,-16 90.17,-16 96.17,-22 96.17,-28 96.17,-28 96.17,-40 96.17,-40 96.17,-46 90.17,-52 84.17,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.37&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1 Request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- server --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;server&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M283.58,-52C283.58,-52 253.58,-52 253.58,-52 247.58,-52 241.58,-46 241.58,-40 241.58,-40 241.58,-28 241.58,-28 241.58,-22 247.58,-16 253.58,-16 253.58,-16 283.58,-16 283.58,-16 289.58,-16 295.58,-22 295.58,-28 295.58,-28 295.58,-40 295.58,-40 295.58,-46 289.58,-52 283.58,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;268.58&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Server&lt;/text&gt;
&lt;/g&gt;
&lt;!-- req&amp;#45;&amp;gt;server --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;req-&gt;server&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M96.35,-34C133.53,-34 192.09,-34 230.17,-34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;229.77,-37.5 239.77,-34 229.77,-30.5 229.77,-37.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- resp --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;resp&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M442.42,-52C442.42,-52 369.92,-52 369.92,-52 363.92,-52 357.92,-46 357.92,-40 357.92,-40 357.92,-28 357.92,-28 357.92,-22 363.92,-16 369.92,-16 369.92,-16 442.42,-16 442.42,-16 448.42,-16 454.42,-22 454.42,-28 454.42,-28 454.42,-40 454.42,-40 454.42,-46 448.42,-52 442.42,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;406.17&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Fast Response&lt;/text&gt;
&lt;/g&gt;
&lt;!-- server&amp;#45;&amp;gt;resp --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;server-&gt;resp&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M296.05,-34C310.4,-34 328.74,-34 346.28,-34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;346.12,-37.5 356.12,-34 346.12,-30.5 346.12,-37.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- many_req --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;many_req&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M88.45,-191C88.45,-191 32.29,-191 32.29,-191 26.29,-191 20.29,-185 20.29,-179 20.29,-179 20.29,-167 20.29,-167 20.29,-161 26.29,-155 32.29,-155 32.29,-155 88.45,-155 88.45,-155 94.45,-155 100.45,-161 100.45,-167 100.45,-167 100.45,-179 100.45,-179 100.45,-185 94.45,-191 88.45,-191&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.37&quot; y=&quot;-168.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;N Requests&lt;/text&gt;
&lt;/g&gt;
&lt;!-- load_balancer --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;load_balancer&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M305.59,-191C305.59,-191 231.58,-191 231.58,-191 225.58,-191 219.58,-185 219.58,-179 219.58,-179 219.58,-167 219.58,-167 219.58,-161 225.58,-155 231.58,-155 231.58,-155 305.59,-155 305.59,-155 311.59,-155 317.59,-161 317.59,-167 317.59,-167 317.59,-179 317.59,-179 317.59,-185 311.59,-191 305.59,-191&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;268.58&quot; y=&quot;-168.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Load Balancer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- many_req&amp;#45;&amp;gt;load_balancer --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;many_req-&gt;load_balancer&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M100.64,-173C130.98,-173 173.48,-173 208.01,-173&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;207.87,-176.5 217.87,-173 207.87,-169.5 207.87,-176.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- s1 --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;s1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M425.69,-137C425.69,-137 386.65,-137 386.65,-137 380.65,-137 374.65,-131 374.65,-125 374.65,-125 374.65,-113 374.65,-113 374.65,-107 380.65,-101 386.65,-101 386.65,-101 425.69,-101 425.69,-101 431.69,-101 437.69,-107 437.69,-113 437.69,-113 437.69,-125 437.69,-125 437.69,-131 431.69,-137 425.69,-137&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;406.17&quot; y=&quot;-114.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Server 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- load_balancer&amp;#45;&amp;gt;s1 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;load_balancer-&gt;s1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M315.86,-154.57C331.42,-148.37 348.66,-141.5 363.82,-135.47&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;365.02,-138.76 373.02,-131.8 362.43,-132.25 365.02,-138.76&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- s2 --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;s2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M425.69,-191C425.69,-191 386.65,-191 386.65,-191 380.65,-191 374.65,-185 374.65,-179 374.65,-179 374.65,-167 374.65,-167 374.65,-161 380.65,-155 386.65,-155 386.65,-155 425.69,-155 425.69,-155 431.69,-155 437.69,-161 437.69,-167 437.69,-167 437.69,-179 437.69,-179 437.69,-185 431.69,-191 425.69,-191&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;406.17&quot; y=&quot;-168.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Server 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- load_balancer&amp;#45;&amp;gt;s2 --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;load_balancer-&gt;s2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M317.77,-173C332.66,-173 348.94,-173 363.36,-173&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;362.96,-176.5 372.96,-173 362.96,-169.5 362.96,-176.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- sn --&gt;
&lt;g id=&quot;node8&quot; class=&quot;node&quot;&gt;
&lt;title&gt;sn&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M427.24,-245C427.24,-245 385.09,-245 385.09,-245 379.09,-245 373.09,-239 373.09,-233 373.09,-233 373.09,-221 373.09,-221 373.09,-215 379.09,-209 385.09,-209 385.09,-209 427.24,-209 427.24,-209 433.24,-209 439.24,-215 439.24,-221 439.24,-221 439.24,-233 439.24,-233 439.24,-239 433.24,-245 427.24,-245&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;406.17&quot; y=&quot;-222.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Server N&lt;/text&gt;
&lt;/g&gt;
&lt;!-- load_balancer&amp;#45;&amp;gt;sn --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;load_balancer-&gt;sn&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M315.86,-191.43C330.93,-197.43 347.57,-204.06 362.37,-209.95&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;360.77,-213.09 371.36,-213.53 363.36,-206.58 360.77,-213.09&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- collective --&gt;
&lt;g id=&quot;node9&quot; class=&quot;node&quot;&gt;
&lt;title&gt;collective&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M681.68,-191C681.68,-191 503.42,-191 503.42,-191 497.42,-191 491.42,-185 491.42,-179 491.42,-179 491.42,-167 491.42,-167 491.42,-161 497.42,-155 503.42,-155 503.42,-155 681.68,-155 681.68,-155 687.68,-155 693.68,-161 693.68,-167 693.68,-167 693.68,-179 693.68,-179 693.68,-185 687.68,-191 681.68,-191&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;592.55&quot; y=&quot;-168.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Consistent Response per Request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- s1&amp;#45;&amp;gt;collective --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;s1-&gt;collective&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M438.03,-128.04C459.75,-134.4 489.78,-143.2 517.53,-151.32&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;516.4,-154.64 526.98,-154.09 518.37,-147.92 516.4,-154.64&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- s2&amp;#45;&amp;gt;collective --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;s2-&gt;collective&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M438.03,-173C450.07,-173 464.67,-173 480.02,-173&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;479.79,-176.5 489.79,-173 479.79,-169.5 479.79,-176.5&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- sn&amp;#45;&amp;gt;collective --&gt;
&lt;g id=&quot;edge9&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;sn-&gt;collective&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M439.71,-217.47C461.24,-211.16 490.39,-202.63 517.38,-194.72&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;518.33,-198.09 526.94,-191.92 516.36,-191.37 518.33,-198.09&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- performance --&gt;
&lt;g id=&quot;node10&quot; class=&quot;node&quot;&gt;
&lt;title&gt;performance&lt;/title&gt;
&lt;ellipse fill=&quot;lightblue&quot; stroke=&quot;black&quot; cx=&quot;60.37&quot; cy=&quot;-304&quot; rx=&quot;60.37&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.37&quot; y=&quot;-299.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Performance&lt;/text&gt;
&lt;/g&gt;
&lt;!-- scalability --&gt;
&lt;g id=&quot;node11&quot; class=&quot;node&quot;&gt;
&lt;title&gt;scalability&lt;/title&gt;
&lt;ellipse fill=&quot;lightgreen&quot; stroke=&quot;black&quot; cx=&quot;268.58&quot; cy=&quot;-304&quot; rx=&quot;52.34&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;268.58&quot; y=&quot;-299.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Scalability&lt;/text&gt;
&lt;/g&gt;
&lt;!-- performance&amp;#45;&amp;gt;scalability --&gt;
&lt;g id=&quot;edge10&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;performance-&gt;scalability&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M121.01,-304C147.12,-304 177.79,-304 204.3,-304&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;204.26,-307.5 214.26,-304 204.26,-300.5 204.26,-307.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;168.49&quot; y=&quot;-308.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt; = speed measured for a single user or request (latency and throughput)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scalability&lt;/strong&gt; = ability to maintain performance proportionally as resources are added&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linear scalability&lt;/strong&gt; means doubling resources doubles capacity with no performance loss&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not interchangeable&lt;/strong&gt;: a Ferrari is performant (fast for one), a bus fleet is scalable (many passengers), a bus is neither&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../latency-vs-throughput&quot; class=&quot;internal alias&quot; data-slug=&quot;latency-vs-throughput&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Latency vs Throughput&lt;/a&gt; — both are dimensions of performance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — adding resources to improve scalability&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cap-theorem&quot; class=&quot;internal alias&quot; data-slug=&quot;cap-theorem&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CAP Theorem&lt;/a&gt; — system design trade-offs affect both performance and scalability&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../back-of-envelope-estimates&quot; class=&quot;internal alias&quot; data-slug=&quot;back-of-envelope-estimates&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Back-of-Envelope Estimates&lt;/a&gt; — quantifying performance expectations&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Superlinear scaling&lt;/strong&gt;: Some systems scale better than linearly (e.g., caching clusters where more nodes reduce cache contention). This is rare and often transient.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance hides poor scalability&lt;/strong&gt;: A fast single node can mask the need to scale until load spikes reveal the bottleneck.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Amdahl’s Law applies&lt;/strong&gt;: The serial portion of any workload caps maximum speedup, no matter how many resources are added.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>refresh-ahead-cache</title>
    <link href="https://animishraa05.github.io/wiki/system-design/refresh-ahead-cache" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/refresh-ahead-cache.md" />
    <summary>The Problem Cache entries expire at TTL boundaries, causing latency spikes as data must be re-fetched from the database.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="caching" label="caching" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Cache entries expire at TTL boundaries, causing latency spikes as data must be re-fetched from the database. These spikes degrade user experience for popular entries.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Refresh-ahead proactively refreshes recently accessed cache entries before they expire. By predicting which entries will be needed next, it reduces latency while keeping hot data fresh, at the cost of potentially wasting resources on incorrectly predicted entries.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Track recently accessed cache entries and their access frequency.&lt;/li&gt;
&lt;li&gt;Before an entry’s TTL expires, predict whether it will be accessed again.&lt;/li&gt;
&lt;li&gt;If predicted to be needed, proactively re-fetch the data from the database.&lt;/li&gt;
&lt;li&gt;Update the cache entry with fresh data and a new TTL, transparent to the application.&lt;/li&gt;
&lt;li&gt;Result: the application almost never encounters a cold miss for popular data.&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;Incorrect predictions hurt performance by wasting I/O on entries that will never be accessed again.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: RefreshAhead Pages: 1 --&gt;
&lt;svg width=&quot;554pt&quot; height=&quot;171pt&quot; viewBox=&quot;0.00 0.00 554.00 171.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 166.67)&quot;&gt;
&lt;title&gt;RefreshAhead&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-166.67 550.44,-166.67 550.44,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M70.1,-73.47C70.1,-73.47 12,-73.47 12,-73.47 6,-73.47 0,-67.47 0,-61.47 0,-61.47 0,-49.47 0,-49.47 0,-43.47 6,-37.47 12,-37.47 12,-37.47 70.1,-37.47 70.1,-37.47 76.1,-37.47 82.1,-43.47 82.1,-49.47 82.1,-49.47 82.1,-61.47 82.1,-61.47 82.1,-67.47 76.1,-73.47 70.1,-73.47&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.05&quot; y=&quot;-51.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Application&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M321.9,-76.27C321.9,-76.27 235.84,-76.27 235.84,-76.27 229.84,-76.27 223.84,-70.27 223.84,-64.27 223.84,-64.27 223.84,-46.67 223.84,-46.67 223.84,-40.67 229.84,-34.67 235.84,-34.67 235.84,-34.67 321.9,-34.67 321.9,-34.67 327.9,-34.67 333.9,-40.67 333.9,-46.67 333.9,-46.67 333.9,-64.27 333.9,-64.27 333.9,-70.27 327.9,-76.27 321.9,-76.27&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;278.87&quot; y=&quot;-59.67&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Cache&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;278.87&quot; y=&quot;-42.87&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Refresh-Ahead)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M63.67,-73.95C73.99,-81.58 86.94,-89.55 100.1,-93.47 145.13,-106.9 160.22,-104.77 205.84,-93.47 216.02,-90.95 226.35,-86.7 235.88,-81.93&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;237.36,-85.12 244.54,-77.33 234.07,-78.94 237.36,-85.12&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;152.97&quot; y=&quot;-106.96&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Read(key)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M82.59,-55.47C118.22,-55.47 170.73,-55.47 212.32,-55.47&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;212.23,-58.97 222.23,-55.47 212.23,-51.97 212.23,-58.97&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;152.97&quot; y=&quot;-59.67&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;7. Read(key) later&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M223.49,-39.72C217.58,-38.47 211.61,-37.41 205.84,-36.67 159.23,-30.69 146.52,-29.34 100.1,-36.67 97.94,-37.01 95.75,-37.42 93.55,-37.88&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.91,-34.43 84.04,-40.22 94.58,-41.23 92.91,-34.43&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;152.97&quot; y=&quot;-40.87&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Data (fresh)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M251.88,-34.37C238.88,-25.17 222.41,-15.4 205.84,-10.67 160.65,2.24 144.58,4.5 100.1,-10.67 88.53,-14.61 77.48,-21.9 68.17,-29.47&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;65.89,-26.81 60.65,-36.02 70.49,-32.09 65.89,-26.81&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;152.97&quot; y=&quot;-14.87&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;8. Data (still fresh)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M267.25,-76.62C266.15,-86.09 270.02,-94.27 278.87,-94.27 283.85,-94.27 287.26,-91.68 289.09,-87.73&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;292.52,-88.48 290.3,-78.12 285.57,-87.6 292.52,-88.48&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;278.87&quot; y=&quot;-115.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. TTL approaching&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;278.87&quot; y=&quot;-98.47&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;detected hot key&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M260.28,-76.58C249.68,-99.34 255.88,-127.87 278.87,-127.87 298.36,-127.87 305.78,-107.37 301.14,-87.26&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;304.52,-86.33 297.96,-78.01 297.9,-88.61 304.52,-86.33&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;278.87&quot; y=&quot;-132.07&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Update entry + TTL&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M534.44,-73.47C534.44,-73.47 491.14,-73.47 491.14,-73.47 485.14,-73.47 479.14,-67.47 479.14,-61.47 479.14,-61.47 479.14,-49.47 479.14,-49.47 479.14,-43.47 485.14,-37.47 491.14,-37.47 491.14,-37.47 534.44,-37.47 534.44,-37.47 540.44,-37.47 546.44,-43.47 546.44,-49.47 546.44,-49.47 546.44,-61.47 546.44,-61.47 546.44,-67.47 540.44,-73.47 534.44,-73.47&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;512.79&quot; y=&quot;-51.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Database&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;DB --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M334.25,-55.47C374.89,-55.47 429.76,-55.47 467.69,-55.47&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;467.37,-58.97 477.37,-55.47 467.37,-51.97 467.37,-58.97&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;406.52&quot; y=&quot;-59.67&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Proactive refresh&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DB-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M478.85,-39.81C473.06,-37.68 467.01,-35.83 461.14,-34.67 413.51,-25.27 399.97,-27.87 351.9,-34.67 349.73,-34.98 347.53,-35.34 345.31,-35.73&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;344.75,-32.28 335.67,-37.74 346.17,-39.13 344.75,-32.28&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;406.52&quot; y=&quot;-38.87&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Fresh data&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Proactive refresh before TTL expiry reduces access latency&lt;/li&gt;
&lt;li&gt;Requires accurate prediction heuristics to avoid wasted refreshes&lt;/li&gt;
&lt;li&gt;Can hurt performance if predictions are wrong (wasted I/O, cache churn)&lt;/li&gt;
&lt;li&gt;Works well with predictable, recurring access patterns&lt;/li&gt;
&lt;li&gt;Transparent to the application — no code changes needed on the read path&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — proactive vs reactive caching&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../write-through-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-through-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Through Cache&lt;/a&gt; — both proactively keep cache fresh&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../cdn-pull&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-pull&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Pull CDN&lt;/a&gt; — CDN pull is reactive; refresh-ahead is proactive&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../eventual-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;eventual-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Eventual Consistency&lt;/a&gt; — refresh-ahead minimizes the window of inconsistency by keeping hot entries fresh&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Wasted refreshes&lt;/strong&gt;: Predictions for entries that are never accessed again waste CPU and database I/O. This can degrade overall system throughput if prediction accuracy is low.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cold start&lt;/strong&gt;: Refresh-ahead has no access history for new entries, so it cannot predict them — they will still experience a cold miss on first access.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Oscillation risk&lt;/strong&gt;: If prediction logic is too aggressive, the cache may constantly refresh entries, reducing effective TTL and increasing database load without benefit.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>rest-architectural-style</title>
    <link href="https://animishraa05.github.io/wiki/system-design/rest-architectural-style" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/rest-architectural-style.md" />
    <summary>The Problem Tight coupling between client and server (as in RPC) makes API evolution difficult, prevents independent deployment, and complicates horizontal scaling.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="communication" label="communication" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Tight coupling between client and server (as in RPC) makes API evolution difficult, prevents independent deployment, and complicates horizontal scaling.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;REST is an architectural style that enforces a client/server model where clients interact with resources through a uniform interface — URIs identify resources, HTTP verbs define actions, status codes communicate results, and HATEOAS links enable navigation. Each request is stateless and self-contained.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Resources are identified by URIs (e.g., &lt;code class=&quot;notranslate&quot;&gt;/users/42&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Clients manipulate resources using standard HTTP verbs: GET (read), POST (create), PUT (replace), PATCH (partial update), DELETE (remove).&lt;/li&gt;
&lt;li&gt;Errors are self-descriptive via HTTP status codes (200 OK, 201 Created, 400 Bad Request, 404 Not Found, 500 Internal Server Error).&lt;/li&gt;
&lt;li&gt;HATEOAS (Hypermedia As The Engine Of Application State): responses include links to navigate related resources.&lt;/li&gt;
&lt;li&gt;Each request is stateless — the server does not store client session context between requests.&lt;/li&gt;
&lt;li&gt;Responses are cacheable via HTTP cache headers (Cache-Control, ETag).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: REST Pages: 1 --&gt;
&lt;svg width=&quot;713pt&quot; height=&quot;118pt&quot; viewBox=&quot;0.00 0.00 713.00 118.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 114.01)&quot;&gt;
&lt;title&gt;REST&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-114.01 708.52,-114.01 708.52,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M42,-72.66C42,-72.66 12,-72.66 12,-72.66 6,-72.66 0,-66.66 0,-60.66 0,-60.66 0,-48.66 0,-48.66 0,-42.66 6,-36.66 12,-36.66 12,-36.66 42,-36.66 42,-36.66 48,-36.66 54,-42.66 54,-48.66 54,-48.66 54,-60.66 54,-60.66 54,-66.66 48,-72.66 42,-72.66&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-50.46&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- API --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;API&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M290.75,-72.66C290.75,-72.66 238.46,-72.66 238.46,-72.66 232.46,-72.66 226.46,-66.66 226.46,-60.66 226.46,-60.66 226.46,-48.66 226.46,-48.66 226.46,-42.66 232.46,-36.66 238.46,-36.66 238.46,-36.66 290.75,-36.66 290.75,-36.66 296.75,-36.66 302.75,-42.66 302.75,-48.66 302.75,-48.66 302.75,-60.66 302.75,-60.66 302.75,-66.66 296.75,-72.66 290.75,-72.66&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;264.6&quot; y=&quot;-50.46&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;REST API&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;API --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;API&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.16,-65.14C59.95,-67.02 66.11,-68.68 72,-69.66 131.83,-79.58 148.34,-77.69 208.46,-69.66 210.63,-69.37 212.85,-69.02 215.07,-68.62&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;215.66,-72.07 224.72,-66.57 214.21,-65.22 215.66,-72.07&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;140.23&quot; y=&quot;-97.41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;GET /users/42&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;140.23&quot; y=&quot;-80.61&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Accept: application/json&lt;/text&gt;
&lt;/g&gt;
&lt;!-- API&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;API-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M244.33,-36.35C234.43,-28.2 221.68,-19.5 208.46,-15.26 150.71,3.25 128.65,6.4 72,-15.26 64.23,-18.23 56.97,-23.27 50.67,-28.78&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;48.59,-25.92 43.81,-35.37 53.45,-30.97 48.59,-25.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;140.23&quot; y=&quot;-53.06&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;200 OK&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;140.23&quot; y=&quot;-36.26&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;{id:42, name:...}&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;140.23&quot; y=&quot;-19.46&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;links: [...]&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Resource --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Resource&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M531.29,-75.46C531.29,-75.46 452.2,-75.46 452.2,-75.46 446.2,-75.46 440.2,-69.46 440.2,-63.46 440.2,-63.46 440.2,-45.86 440.2,-45.86 440.2,-39.86 446.2,-33.86 452.2,-33.86 452.2,-33.86 531.29,-33.86 531.29,-33.86 537.29,-33.86 543.29,-39.86 543.29,-45.86 543.29,-45.86 543.29,-63.46 543.29,-63.46 543.29,-69.46 537.29,-75.46 531.29,-75.46&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;491.75&quot; y=&quot;-58.86&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Resource&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;491.75&quot; y=&quot;-42.06&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(e.g., /users/42)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- API&amp;#45;&amp;gt;Resource --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;API-&gt;Resource&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M303.03,-54.66C337.13,-54.66 388.17,-54.66 428.42,-54.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;428.21,-58.16 438.21,-54.66 428.21,-51.16 428.21,-58.16&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;371.47&quot; y=&quot;-58.86&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Identify resource&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Resource&amp;#45;&amp;gt;API --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Resource-&gt;API&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M439.85,-37.42C433.95,-35.96 427.99,-34.72 422.2,-33.86 377.6,-27.24 365.11,-25.77 320.75,-33.86 318.46,-34.28 316.16,-34.78 313.84,-35.36&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;313.14,-31.92 304.51,-38.07 315.09,-38.64 313.14,-31.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;371.47&quot; y=&quot;-38.06&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Serialize response&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M692.52,-72.66C692.52,-72.66 649.21,-72.66 649.21,-72.66 643.21,-72.66 637.21,-66.66 637.21,-60.66 637.21,-60.66 637.21,-48.66 637.21,-48.66 637.21,-42.66 643.21,-36.66 649.21,-36.66 649.21,-36.66 692.52,-36.66 692.52,-36.66 698.52,-36.66 704.52,-42.66 704.52,-48.66 704.52,-48.66 704.52,-60.66 704.52,-60.66 704.52,-66.66 698.52,-72.66 692.52,-72.66&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;670.87&quot; y=&quot;-50.46&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Database&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Resource&amp;#45;&amp;gt;DB --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Resource-&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M543.5,-54.66C569.36,-54.66 600.51,-54.66 625.41,-54.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;625.21,-58.16 635.21,-54.66 625.21,-51.16 625.21,-58.16&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;590.25&quot; y=&quot;-58.86&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Fetch data&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB&amp;#45;&amp;gt;Resource --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DB-&gt;Resource&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M636.93,-39C631.14,-36.87 625.09,-35.02 619.21,-33.86 593.96,-28.88 586.76,-30.08 561.29,-33.86 559.13,-34.18 556.93,-34.56 554.72,-34.98&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;554.14,-31.52 545.13,-37.1 555.65,-38.36 554.14,-31.52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;590.25&quot; y=&quot;-38.06&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Result&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;URI-based resource identification — everything is a resource (noun)&lt;/li&gt;
&lt;li&gt;HTTP verb-based actions define the uniform interface&lt;/li&gt;
&lt;li&gt;Stateless — each request contains all context needed to process it&lt;/li&gt;
&lt;li&gt;Cacheable responses reduce server load and improve latency&lt;/li&gt;
&lt;li&gt;Uniform interface minimizes client-server coupling&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../rpc-remote-procedure-call&quot; class=&quot;internal alias&quot; data-slug=&quot;rpc-remote-procedure-call&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;RPC&lt;/a&gt; — REST exposes data/resources (nouns); RPC exposes behaviors (verbs)&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../microservices-architecture&quot; class=&quot;internal alias&quot; data-slug=&quot;microservices-architecture&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Microservices Architecture&lt;/a&gt; — REST APIs are a primary communication mechanism between services&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — REST supports caching via HTTP cache headers (Cache-Control, ETag)&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt; — L7 load balancers can inspect and route RESTful requests based on URI paths and HTTP methods&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Over-fetching / under-fetching&lt;/strong&gt;: REST responses return fixed resource representations, which may include unnecessary fields (over-fetching) or miss needed data (under-fetching). GraphQL or sparse fieldsets address this.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No standard for partial updates&lt;/strong&gt;: PUT replaces the entire resource; PATCH semantics vary. Clients must understand which verb and representation to use.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Statelessness shifts complexity&lt;/strong&gt;: Session state must be stored client-side or in an external store (e.g., Redis), pushing complexity out of the server.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>reverse-proxy-pattern</title>
    <link href="https://animishraa05.github.io/wiki/system-design/reverse-proxy-pattern" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/reverse-proxy-pattern.md" />
    <summary>The Problem Backend servers should not be directly exposed to the internet for security and scalability reasons.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="infrastructure" label="infrastructure" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Backend servers should not be directly exposed to the internet for security and scalability reasons. Clients should not have to know about internal server topology, and managing SSL certificates, caching, and compression at every backend is wasteful.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A reverse proxy centralizes internal services and provides a unified public interface. It forwards incoming client requests to the appropriate backend server and returns the response, acting as a single gatekeeper that handles cross-cutting concerns like SSL termination, caching, compression, and static content serving.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Client sends a request to the reverse proxy’s public address (e.g., &lt;code class=&quot;notranslate&quot;&gt;https://api.example.com&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Reverse proxy terminates the TLS connection (SSL termination), decrypting the request.&lt;/li&gt;
&lt;li&gt;Proxy checks its cache — if a fresh response exists, returns it immediately.&lt;/li&gt;
&lt;li&gt;If not cached, proxy forwards the request to the appropriate backend server based on URL path or host header.&lt;/li&gt;
&lt;li&gt;Backend processes the request and returns the response to the proxy.&lt;/li&gt;
&lt;li&gt;Proxy can compress the response (gzip), cache it, and add security headers before returning to the client.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: ReverseProxy Pages: 1 --&gt;
&lt;svg width=&quot;566pt&quot; height=&quot;215pt&quot; viewBox=&quot;0.00 0.00 566.00 215.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 210.67)&quot;&gt;
&lt;title&gt;ReverseProxy&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-210.67 562.05,-210.67 562.05,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M42,-118.8C42,-118.8 12,-118.8 12,-118.8 6,-118.8 0,-112.8 0,-106.8 0,-106.8 0,-94.8 0,-94.8 0,-88.8 6,-82.8 12,-82.8 12,-82.8 42,-82.8 42,-82.8 48,-82.8 54,-88.8 54,-94.8 54,-94.8 54,-106.8 54,-106.8 54,-112.8 48,-118.8 42,-118.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-96.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RP --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;RP&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M355.98,-124.2C355.98,-127.07 328,-129.4 293.54,-129.4 259.09,-129.4 231.1,-127.07 231.1,-124.2 231.1,-124.2 231.1,-77.4 231.1,-77.4 231.1,-74.53 259.09,-72.2 293.54,-72.2 328,-72.2 355.98,-74.53 355.98,-77.4 355.98,-77.4 355.98,-124.2 355.98,-124.2&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M355.98,-124.2C355.98,-121.33 328,-119 293.54,-119 259.09,-119 231.1,-121.33 231.1,-124.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;293.54&quot; y=&quot;-105&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Reverse Proxy&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;293.54&quot; y=&quot;-88.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Nginx / HAProxy)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;RP --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;RP&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.33,-100.8C92.46,-100.8 164.48,-100.8 219.39,-100.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;219.32,-104.3 229.32,-100.8 219.32,-97.3 219.32,-104.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;142.55&quot; y=&quot;-105&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;HTTPS request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RP&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RP-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M230.83,-83.01C224.88,-81.79 218.9,-80.75 213.1,-80 150.9,-71.99 133.19,-66.27 72,-80 69.68,-80.52 67.34,-81.18 65.01,-81.94&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;63.79,-78.65 55.73,-85.53 66.32,-85.18 63.79,-78.65&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;142.55&quot; y=&quot;-84.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;cached/compressed reply&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Backend1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Backend1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M545.27,-201.6C545.27,-201.6 481.35,-201.6 481.35,-201.6 475.35,-201.6 469.35,-195.6 469.35,-189.6 469.35,-189.6 469.35,-172 469.35,-172 469.35,-166 475.35,-160 481.35,-160 481.35,-160 545.27,-160 545.27,-160 551.27,-160 557.27,-166 557.27,-172 557.27,-172 557.27,-189.6 557.27,-189.6 557.27,-195.6 551.27,-201.6 545.27,-201.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513.31&quot; y=&quot;-185&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Backend 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513.31&quot; y=&quot;-168.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(API Server)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RP&amp;#45;&amp;gt;Backend1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RP-&gt;Backend1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M314.87,-129.87C329.13,-147.61 349.9,-168.75 373.98,-178.8 400.05,-189.68 431.36,-190.98 457.59,-189.22&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;457.7,-192.72 467.36,-188.38 457.1,-185.75 457.7,-192.72&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;412.28&quot; y=&quot;-194.07&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;route /api/*&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Backend2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Backend2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M546.05,-111.6C546.05,-111.6 480.57,-111.6 480.57,-111.6 474.57,-111.6 468.57,-105.6 468.57,-99.6 468.57,-99.6 468.57,-82 468.57,-82 468.57,-76 474.57,-70 480.57,-70 480.57,-70 546.05,-70 546.05,-70 552.05,-70 558.05,-76 558.05,-82 558.05,-82 558.05,-99.6 558.05,-99.6 558.05,-105.6 552.05,-111.6 546.05,-111.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513.31&quot; y=&quot;-95&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Backend 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513.31&quot; y=&quot;-78.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(App Server)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RP&amp;#45;&amp;gt;Backend2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RP-&gt;Backend2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M356.12,-101.66C384.85,-101.63 419.5,-101.01 450.57,-98.8 452.63,-98.65 454.72,-98.49 456.83,-98.3&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;457.09,-101.79 466.69,-97.3 456.39,-94.83 457.09,-101.79&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;412.28&quot; y=&quot;-105.72&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;route /app/*&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Backend3 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Backend3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M545.28,-41.6C545.28,-41.6 481.34,-41.6 481.34,-41.6 475.34,-41.6 469.34,-35.6 469.34,-29.6 469.34,-29.6 469.34,-12 469.34,-12 469.34,-6 475.34,0 481.34,0 481.34,0 545.28,0 545.28,0 551.28,0 557.28,-6 557.28,-12 557.28,-12 557.28,-29.6 557.28,-29.6 557.28,-35.6 551.28,-41.6 545.28,-41.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513.31&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Backend 3&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513.31&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Static Files)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RP&amp;#45;&amp;gt;Backend3 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RP-&gt;Backend3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M337.05,-72.63C348.68,-65.81 361.52,-59.04 373.98,-54 400.71,-43.2 431.82,-35.35 457.77,-30&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;458.3,-33.46 467.43,-28.08 456.94,-26.59 458.3,-33.46&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;412.28&quot; y=&quot;-58.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;route /static/*&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Backend1&amp;#45;&amp;gt;RP --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Backend1-&gt;RP&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M469.14,-164.84C462.91,-162.54 456.58,-160.21 450.57,-158 423.32,-147.97 393.39,-136.99 367.09,-127.35&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;368.45,-124.13 357.86,-123.97 366.05,-130.7 368.45,-124.13&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;412.28&quot; y=&quot;-162.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;response&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Backend2&amp;#45;&amp;gt;RP --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Backend2-&gt;RP&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M468.3,-80.54C462.37,-79.49 456.34,-78.59 450.57,-78 416.71,-74.53 407.69,-73.26 373.98,-78 371.8,-78.31 369.59,-78.66 367.37,-79.05&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;366.79,-75.6 357.68,-81 368.17,-82.46 366.79,-75.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;412.28&quot; y=&quot;-82.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;response&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Backend3&amp;#45;&amp;gt;RP --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Backend3-&gt;RP&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M468.99,-7.42C440.74,-1.13 403.73,2.4 373.98,-11 350.44,-21.61 331.06,-43.02 317.34,-62.27&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;314.45,-60.29 311.73,-70.53 320.24,-64.23 314.45,-60.29&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;412.28&quot; y=&quot;-15.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;response&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Single public-facing endpoint&lt;/strong&gt; — all traffic arrives at one address&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hides backend topology&lt;/strong&gt; — internal server layout is never exposed to clients&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SSL termination&lt;/strong&gt; — offloads certificate management and decryption from backends&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Response caching&lt;/strong&gt; — serves repeated requests without contacting backends&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Response compression&lt;/strong&gt; — reduces bandwidth for text-based responses&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../load-balancer&quot; class=&quot;internal alias&quot; data-slug=&quot;load-balancer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Load Balancer&lt;/a&gt; — reverse proxy often incorporates load balancing logic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../layer4-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer4-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 4 Load Balancing&lt;/a&gt; — L4 LB distributes traffic at transport layer without inspecting content; RP operates at application layer&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt; — tools like Nginx and HAProxy support both reverse proxy and L7 load balancing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cdn-push&quot; class=&quot;internal alias&quot; data-slug=&quot;cdn-push&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Push CDN&lt;/a&gt; — both cache and serve static content; CDN is geographically distributed while RP is centralized&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../dns-system-design&quot; class=&quot;internal alias&quot; data-slug=&quot;dns-system-design&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DNS in System Design&lt;/a&gt; — DNS resolves the domain name to the reverse proxy’s IP address&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Single point of failure&lt;/strong&gt; — if the reverse proxy goes down, the entire service is unreachable; always deploy at least two in an active-passive or active-active configuration.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Request buffering&lt;/strong&gt; — large uploads can exhaust proxy memory; configure request size limits or stream directly to backends.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Latency overhead&lt;/strong&gt; — every request passes through an extra hop; this is negligible in most cases but matters for ultra-low-latency systems.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>rpc-remote-procedure-call</title>
    <link href="https://animishraa05.github.io/wiki/system-design/rpc-remote-procedure-call" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/rpc-remote-procedure-call.md" />
    <summary>The Problem Network communication between services requires manual serialization, addressing, protocol handling, and error management — this is complex, error-prone, and obscures business logic.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="communication" label="communication" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Network communication between services requires manual serialization, addressing, protocol handling, and error management — this is complex, error-prone, and obscures business logic.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;RPC makes a remote procedure call look indistinguishable from a local call. The client calls a local stub that marshals the function name and arguments into a network message, sends it to the server, which unmarshals and executes the function, and returns the result — all transparent to the application code.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Client calls a local stub function as if it were a local procedure.&lt;/li&gt;
&lt;li&gt;The client stub marshals the procedure ID and arguments into a binary or structured message.&lt;/li&gt;
&lt;li&gt;The client OS sends the message over the network to the server.&lt;/li&gt;
&lt;li&gt;The server OS passes the message to the server stub.&lt;/li&gt;
&lt;li&gt;The server stub unmarshals the message, locates and calls the actual procedure.&lt;/li&gt;
&lt;li&gt;The procedure executes and returns a result to the server stub.&lt;/li&gt;
&lt;li&gt;The response follows the reverse path back to the client.&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;Popular RPC frameworks include Protocol Buffers (gRPC), Apache Thrift, and Apache Avro.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: RPC Pages: 1 --&gt;
&lt;svg width=&quot;769pt&quot; height=&quot;89pt&quot; viewBox=&quot;0.00 0.00 769.00 89.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 84.96)&quot;&gt;
&lt;title&gt;RPC&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-84.96 765.32,-84.96 765.32,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M42,-46.16C42,-46.16 12,-46.16 12,-46.16 6,-46.16 0,-40.16 0,-34.16 0,-34.16 0,-22.16 0,-22.16 0,-16.16 6,-10.16 12,-10.16 12,-10.16 42,-10.16 42,-10.16 48,-10.16 54,-16.16 54,-22.16 54,-22.16 54,-34.16 54,-34.16 54,-40.16 48,-46.16 42,-46.16&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-23.96&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ClientStub --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ClientStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M267.43,-46.16C267.43,-46.16 212.03,-46.16 212.03,-46.16 206.03,-46.16 200.03,-40.16 200.03,-34.16 200.03,-34.16 200.03,-22.16 200.03,-22.16 200.03,-16.16 206.03,-10.16 212.03,-10.16 212.03,-10.16 267.43,-10.16 267.43,-10.16 273.43,-10.16 279.43,-16.16 279.43,-22.16 279.43,-22.16 279.43,-34.16 279.43,-34.16 279.43,-40.16 273.43,-46.16 267.43,-46.16&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;239.73&quot; y=&quot;-23.96&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client Stub&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;ClientStub --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;ClientStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.26,-28.16C87.64,-28.16 145.99,-28.16 188.14,-28.16&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;188.05,-31.66 198.05,-28.16 188.05,-24.66 188.05,-31.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.02&quot; y=&quot;-32.36&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Call local func&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ClientStub&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ClientStub-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M199.57,-11.79C193.78,-9.96 187.81,-8.39 182.03,-7.36 133.88,1.19 119.72,3.35 72,-7.36 69.68,-7.88 67.34,-8.54 65.01,-9.29&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;63.79,-6.01 55.73,-12.89 66.32,-12.54 63.79,-6.01&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.02&quot; y=&quot;-11.56&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;8. Unmarshal result&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ClientStub&amp;#45;&amp;gt;ClientStub --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ClientStub-&gt;ClientStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M219.34,-46.31C216.2,-55.7 223,-64.16 239.73,-64.16 249.14,-64.16 255.41,-61.48 258.53,-57.47&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;261.96,-58.2 259.91,-47.81 255.03,-57.22 261.96,-58.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;239.73&quot; y=&quot;-68.36&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Marshal args&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ServerStub --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ServerStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M503.73,-46.16C503.73,-46.16 446.02,-46.16 446.02,-46.16 440.02,-46.16 434.02,-40.16 434.02,-34.16 434.02,-34.16 434.02,-22.16 434.02,-22.16 434.02,-16.16 440.02,-10.16 446.02,-10.16 446.02,-10.16 503.73,-10.16 503.73,-10.16 509.73,-10.16 515.73,-16.16 515.73,-22.16 515.73,-22.16 515.73,-34.16 515.73,-34.16 515.73,-40.16 509.73,-46.16 503.73,-46.16&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;474.87&quot; y=&quot;-23.96&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Server Stub&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ClientStub&amp;#45;&amp;gt;ServerStub --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ClientStub-&gt;ServerStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M279.75,-28.16C318.82,-28.16 379.15,-28.16 422.18,-28.16&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;422.04,-31.66 432.04,-28.16 422.04,-24.66 422.04,-31.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;356.72&quot; y=&quot;-32.36&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Network message&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ServerStub&amp;#45;&amp;gt;ClientStub --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ServerStub-&gt;ClientStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M433.58,-11.69C427.77,-9.9 421.8,-8.37 416.02,-7.36 364.09,1.69 349.32,1.86 297.43,-7.36 295.26,-7.74 293.07,-8.21 290.87,-8.73&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;290.04,-5.33 281.35,-11.38 291.92,-12.07 290.04,-5.33&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;356.72&quot; y=&quot;-11.56&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;7. Response message&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ServerStub&amp;#45;&amp;gt;ServerStub --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ServerStub-&gt;ServerStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M455.47,-46.31C452.49,-55.7 458.95,-64.16 474.87,-64.16 483.83,-64.16 489.79,-61.48 492.77,-57.47&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;496.2,-58.19 494.07,-47.81 489.27,-57.25 496.2,-58.19&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;474.87&quot; y=&quot;-68.36&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Unmarshal&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Server --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Server&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M749.32,-46.16C749.32,-46.16 660.53,-46.16 660.53,-46.16 654.53,-46.16 648.53,-40.16 648.53,-34.16 648.53,-34.16 648.53,-22.16 648.53,-22.16 648.53,-16.16 654.53,-10.16 660.53,-10.16 660.53,-10.16 749.32,-10.16 749.32,-10.16 755.32,-10.16 761.32,-16.16 761.32,-22.16 761.32,-22.16 761.32,-34.16 761.32,-34.16 761.32,-40.16 755.32,-46.16 749.32,-46.16&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;704.92&quot; y=&quot;-23.96&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Server Procedure&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ServerStub&amp;#45;&amp;gt;Server --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ServerStub-&gt;Server&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M516.12,-28.16C549.52,-28.16 597.72,-28.16 636.93,-28.16&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;636.74,-31.66 646.74,-28.16 636.74,-24.66 636.74,-31.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;582.13&quot; y=&quot;-32.36&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Call procedure&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Server&amp;#45;&amp;gt;ServerStub --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Server-&gt;ServerStub&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M648.16,-10.64C642.26,-9.3 636.3,-8.16 630.53,-7.36 587.92,-1.44 576.11,0.03 533.73,-7.36 531.56,-7.74 529.37,-8.19 527.17,-8.7&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;526.36,-5.29 517.63,-11.29 528.2,-12.05 526.36,-5.29&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;582.13&quot; y=&quot;-11.56&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Return result&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Hides network complexity behind a familiar local-call abstraction&lt;/li&gt;
&lt;li&gt;Request-response protocol — synchronous by default&lt;/li&gt;
&lt;li&gt;Automatically marshals/unmarshals parameters and return values&lt;/li&gt;
&lt;li&gt;Tight client-server coupling (interface contract is shared)&lt;/li&gt;
&lt;li&gt;Better suited for internal service-to-service communication than public APIs&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../rest-architectural-style&quot; class=&quot;internal alias&quot; data-slug=&quot;rest-architectural-style&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;REST&lt;/a&gt; — RPC exposes behaviors (functions); REST exposes resources (nouns)&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../microservices-architecture&quot; class=&quot;internal alias&quot; data-slug=&quot;microservices-architecture&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Microservices Architecture&lt;/a&gt; — RPC is a common inter-service communication pattern&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../service-discovery&quot; class=&quot;internal alias&quot; data-slug=&quot;service-discovery&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Service Discovery&lt;/a&gt; — RPC clients need to locate server instances dynamically&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — RPC is synchronous; message queues enable async communication&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Network failures are invisible&lt;/strong&gt;: The local-call abstraction hides network partitions, timeouts, and partial failures. RPC calls can fail silently or hang.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Versioning hell&lt;/strong&gt;: Evolving the interface contract requires coordinated deployment of both client and server. Use schema evolution features (e.g., Protobuf field tags) to mitigate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance overhead&lt;/strong&gt;: Marshaling, network round-trips, and connection management add latency compared to in-process calls. Batch calls or use streaming for high-throughput scenarios.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>service-discovery</title>
    <link href="https://animishraa05.github.io/wiki/system-design/service-discovery" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/service-discovery.md" />
    <summary>The Problem In dynamic microservice environments, IP addresses and ports change frequently as instances are created, destroyed, or moved during scaling events and failures.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="architecture" label="architecture" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;In dynamic microservice environments, IP addresses and ports change frequently as instances are created, destroyed, or moved during scaling events and failures. Hard-coding addresses makes the system brittle and unmanageable.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Service discovery tools (Consul, Etcd, Zookeeper) maintain a registry of service names mapped to their current network locations (IP + port). Services register themselves on startup and the registry performs health checks to remove unhealthy instances, allowing clients to always find live services.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;On startup, each service instance registers its name, IP address, and port with the discovery service.&lt;/li&gt;
&lt;li&gt;The discovery service runs periodic health checks (e.g., HTTP &lt;code class=&quot;notranslate&quot;&gt;/health&lt;/code&gt; endpoint) against registered instances.&lt;/li&gt;
&lt;li&gt;Unhealthy instances that fail health checks are automatically deregistered.&lt;/li&gt;
&lt;li&gt;When a service (or API gateway) needs to call another service, it queries the registry for the service name.&lt;/li&gt;
&lt;li&gt;The registry returns the list of healthy instances, and the client picks one (round-robin, random, or least-loaded).&lt;/li&gt;
&lt;li&gt;The key-value store in the registry can hold shared configuration values (feature flags, DB URLs).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: ServiceDiscovery Pages: 1 --&gt;
&lt;svg width=&quot;399pt&quot; height=&quot;343pt&quot; viewBox=&quot;0.00 0.00 399.00 343.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 338.8)&quot;&gt;
&lt;title&gt;ServiceDiscovery&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-338.8 394.9,-338.8 394.9,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- ServiceA --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ServiceA&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M203.95,-334.8C203.95,-334.8 130.71,-334.8 130.71,-334.8 124.71,-334.8 118.71,-328.8 118.71,-322.8 118.71,-322.8 118.71,-305.2 118.71,-305.2 118.71,-299.2 124.71,-293.2 130.71,-293.2 130.71,-293.2 203.95,-293.2 203.95,-293.2 209.95,-293.2 215.95,-299.2 215.95,-305.2 215.95,-305.2 215.95,-322.8 215.95,-322.8 215.95,-328.8 209.95,-334.8 203.95,-334.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;167.33&quot; y=&quot;-318.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Service A&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;167.33&quot; y=&quot;-301.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(User Service)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Registry --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Registry&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M221.79,-235.2C221.79,-238.07 197.38,-240.4 167.33,-240.4 137.28,-240.4 112.87,-238.07 112.87,-235.2 112.87,-235.2 112.87,-188.4 112.87,-188.4 112.87,-185.53 137.28,-183.2 167.33,-183.2 197.38,-183.2 221.79,-185.53 221.79,-188.4 221.79,-188.4 221.79,-235.2 221.79,-235.2&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M221.79,-235.2C221.79,-232.33 197.38,-230 167.33,-230 137.28,-230 112.87,-232.33 112.87,-235.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;167.33&quot; y=&quot;-216&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Service Registry&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;167.33&quot; y=&quot;-199.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Consul / Etcd)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ServiceA&amp;#45;&amp;gt;Registry --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ServiceA-&gt;Registry&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M118.29,-296.65C109.05,-291.29 100.57,-284.28 95.07,-275.2 87.82,-263.22 93.22,-252.36 103.71,-243.17&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;105.51,-246.2 111.4,-237.39 101.3,-240.61 105.51,-246.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.7&quot; y=&quot;-262.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Register: user:8080&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ServiceB --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ServiceB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M172.34,-41.6C172.34,-41.6 98.32,-41.6 98.32,-41.6 92.32,-41.6 86.32,-35.6 86.32,-29.6 86.32,-29.6 86.32,-12 86.32,-12 86.32,-6 92.32,0 98.32,0 98.32,0 172.34,0 172.34,0 178.34,0 184.34,-6 184.34,-12 184.34,-12 184.34,-29.6 184.34,-29.6 184.34,-35.6 178.34,-41.6 172.34,-41.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;135.33&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Service B&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;135.33&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Feed Service)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ServiceB&amp;#45;&amp;gt;Registry --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ServiceB-&gt;Registry&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M135.81,-41.97C136.62,-63.89 138.73,-99.88 144.31,-130.4 146.81,-144.1 150.67,-158.82 154.52,-171.87&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;151.15,-172.85 157.42,-181.39 157.85,-170.81 151.15,-172.85&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;206.32&quot; y=&quot;-108.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Register: feed:8081&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Registry&amp;#45;&amp;gt;ServiceA --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Registry-&gt;ServiceA&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M205.62,-240.09C210.78,-245.54 215.32,-251.68 218.33,-258.4 222.69,-268.15 218.97,-277.29 211.91,-285.18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;209.6,-282.55 204.65,-291.91 214.36,-287.68 209.6,-282.55&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;284.73&quot; y=&quot;-262.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Health check /health&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Registry&amp;#45;&amp;gt;ServiceB --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Registry-&gt;ServiceB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M112.67,-199.27C75.63,-188.31 29.37,-167.74 6.27,-130.4 -16.9,-92.93 31.73,-62 75.78,-42.86&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;76.97,-46.15 84.85,-39.07 74.27,-39.69 76.97,-46.15&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;70.8&quot; y=&quot;-108.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Health check /health&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M357.24,-130.4C357.24,-130.4 289.43,-130.4 289.43,-130.4 283.43,-130.4 277.43,-124.4 277.43,-118.4 277.43,-118.4 277.43,-106.4 277.43,-106.4 277.43,-100.4 283.43,-94.4 289.43,-94.4 289.43,-94.4 357.24,-94.4 357.24,-94.4 363.24,-94.4 369.24,-100.4 369.24,-106.4 369.24,-106.4 369.24,-118.4 369.24,-118.4 369.24,-124.4 363.24,-130.4 357.24,-130.4&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;323.33&quot; y=&quot;-108.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;API Gateway&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Registry&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Registry-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M175.91,-182.93C180.95,-170.76 188.51,-157.26 199.35,-148.4 222.22,-129.7 234.9,-138.43 263.33,-130.4 264.31,-130.12 265.3,-129.84 266.3,-129.56&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;267.02,-133 275.69,-126.91 265.11,-126.26 267.02,-133&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;234.34&quot; y=&quot;-152.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. feed:8081&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;ServiceB --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;ServiceB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M286.64,-93.91C258.6,-80.55 219.57,-61.95 188.18,-46.99&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;189.75,-43.86 179.21,-42.71 186.74,-50.18 189.75,-43.86&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;298.85&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Forward request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;Registry --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;Registry&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M309.89,-130.5C300.55,-141.52 287.32,-155.54 273.33,-165.2 260.8,-173.86 246.36,-181.4 232.25,-187.72&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;231.26,-184.34 223.46,-191.5 234.03,-190.76 231.26,-184.34&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;341.93&quot; y=&quot;-152.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Where is feed?&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Dynamic registration/deregistration&lt;/strong&gt; — instances automatically register on startup and deregister on shutdown&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Health checks&lt;/strong&gt; — continuous verification that instances are alive and ready&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Key-value store&lt;/strong&gt; — shared configuration storage alongside the registry&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Consistent naming&lt;/strong&gt; — services are found by logical name, not physical address&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../microservices-architecture&quot; class=&quot;internal alias&quot; data-slug=&quot;microservices-architecture&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Microservices Architecture&lt;/a&gt; — dynamic microservice environments create the need for discovery&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../layer7-load-balancing&quot; class=&quot;internal alias&quot; data-slug=&quot;layer7-load-balancing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Layer 7 Load Balancing&lt;/a&gt; — L7 load balancers use the service registry to discover healthy backends&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — scaling up/down changes instance counts, and discovery tracks the current set&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — an alternative async communication pattern that decouples services without direct discovery&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../reverse-proxy-pattern&quot; class=&quot;internal alias&quot; data-slug=&quot;reverse-proxy-pattern&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reverse Proxy Pattern&lt;/a&gt; — reverse proxy can use service discovery to route to backends&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Cached stale entries&lt;/strong&gt; — if a service crashes without deregistering, the registry may return a dead instance until the next health check.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Thundering herd on registry&lt;/strong&gt; — if every client aggressively re-queries on failure, the registry can be overwhelmed; client-side caching with TTL is essential.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Consistency vs. availability tradeoff&lt;/strong&gt; — highly available registries (eventually consistent) may return stale data; strongly consistent registries (Paxos/Raft based) add write latency.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>sharding</title>
    <link href="https://animishraa05.github.io/wiki/system-design/sharding" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/sharding.md" />
    <summary>The Problem As data grows, a single database becomes too slow — indexes grow too large to fit in memory, write throughput plateaus, and backup/recovery times become dangerously long.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;As data grows, a single database becomes too slow — indexes grow too large to fit in memory, write throughput plateaus, and backup/recovery times become dangerously long.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Sharding distributes data across multiple databases such that each database (shard) manages a subset of the data, reducing per-shard read/write traffic, shrinking index sizes, and allowing the system to scale horizontally by adding more shards.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Choose a shard key — an attribute that determines data placement (e.g., user ID, geographic region, last name initial).&lt;/li&gt;
&lt;li&gt;Define a sharding strategy: range-based (A–M on shard 1, N–Z on shard 2), hash-based (hash(user_id) % N), or directory-based (lookup table).&lt;/li&gt;
&lt;li&gt;Each shard is an independent database with its own subset of data.&lt;/li&gt;
&lt;li&gt;Queries include the shard key so the application or proxy routes them to the correct shard.&lt;/li&gt;
&lt;li&gt;Add more shards as data grows — consistent hashing minimizes data movement during rebalancing.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: Sharding Pages: 1 --&gt;
&lt;svg width=&quot;386pt&quot; height=&quot;321pt&quot; viewBox=&quot;0.00 0.00 386.00 321.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 317.4)&quot;&gt;
&lt;title&gt;Sharding&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-317.4 381.95,-317.4 381.95,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M209.31,-313.4C209.31,-313.4 151.22,-313.4 151.22,-313.4 145.22,-313.4 139.22,-307.4 139.22,-301.4 139.22,-301.4 139.22,-289.4 139.22,-289.4 139.22,-283.4 145.22,-277.4 151.22,-277.4 151.22,-277.4 209.31,-277.4 209.31,-277.4 215.31,-277.4 221.31,-283.4 221.31,-289.4 221.31,-289.4 221.31,-301.4 221.31,-301.4 221.31,-307.4 215.31,-313.4 209.31,-313.4&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.27&quot; y=&quot;-291.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Application&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Router --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Router&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M235.57,-240.4C235.57,-240.4 124.96,-240.4 124.96,-240.4 118.96,-240.4 112.96,-234.4 112.96,-228.4 112.96,-228.4 112.96,-210.8 112.96,-210.8 112.96,-204.8 118.96,-198.8 124.96,-198.8 124.96,-198.8 235.57,-198.8 235.57,-198.8 241.57,-198.8 247.57,-204.8 247.57,-210.8 247.57,-210.8 247.57,-228.4 247.57,-228.4 247.57,-234.4 241.57,-240.4 235.57,-240.4&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.27&quot; y=&quot;-223.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Shard Router&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.27&quot; y=&quot;-207&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Consistent Hashing)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Router --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Router&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M180.27,-276.91C180.27,-269.55 180.27,-260.75 180.27,-252.32&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;183.77,-252.35 180.27,-242.35 176.77,-252.35 183.77,-252.35&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- ShardA --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ShardA&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M97.93,-140.8C97.93,-143.67 79.7,-146 57.27,-146 34.83,-146 16.6,-143.67 16.6,-140.8 16.6,-140.8 16.6,-94 16.6,-94 16.6,-91.13 34.83,-88.8 57.27,-88.8 79.7,-88.8 97.93,-91.13 97.93,-94 97.93,-94 97.93,-140.8 97.93,-140.8&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M97.93,-140.8C97.93,-137.93 79.7,-135.6 57.27,-135.6 34.83,-135.6 16.6,-137.93 16.6,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.27&quot; y=&quot;-121.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Shard 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.27&quot; y=&quot;-104.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;users A–M&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Router&amp;#45;&amp;gt;ShardA --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Router-&gt;ShardA&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M112.9,-199.51C102.8,-194.57 93.12,-188.42 85.17,-180.8 78.29,-174.2 72.98,-165.6 68.93,-156.9&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;72.21,-155.69 65.17,-147.77 65.74,-158.35 72.21,-155.69&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;130.72&quot; y=&quot;-168.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;hash(user_id)=1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardB --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ShardB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M218.98,-140.8C218.98,-143.67 201.63,-146 180.27,-146 158.9,-146 141.55,-143.67 141.55,-140.8 141.55,-140.8 141.55,-94 141.55,-94 141.55,-91.13 158.9,-88.8 180.27,-88.8 201.63,-88.8 218.98,-91.13 218.98,-94 218.98,-94 218.98,-140.8 218.98,-140.8&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M218.98,-140.8C218.98,-137.93 201.63,-135.6 180.27,-135.6 158.9,-135.6 141.55,-137.93 141.55,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.27&quot; y=&quot;-121.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Shard 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.27&quot; y=&quot;-104.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;users N–Z&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Router&amp;#45;&amp;gt;ShardB --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Router-&gt;ShardB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M180.27,-198.32C180.27,-186.62 180.27,-171.5 180.27,-157.56&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;183.77,-157.75 180.27,-147.75 176.77,-157.75 183.77,-157.75&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;225.81&quot; y=&quot;-168.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;hash(user_id)=2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardC --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ShardC&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M347.53,-140.8C347.53,-143.67 326.35,-146 300.27,-146 274.18,-146 253,-143.67 253,-140.8 253,-140.8 253,-94 253,-94 253,-91.13 274.18,-88.8 300.27,-88.8 326.35,-88.8 347.53,-91.13 347.53,-94 347.53,-94 347.53,-140.8 347.53,-140.8&quot;&gt;&lt;/path&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M347.53,-140.8C347.53,-137.93 326.35,-135.6 300.27,-135.6 274.18,-135.6 253,-137.93 253,-140.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;300.27&quot; y=&quot;-121.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Shard 3&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;300.27&quot; y=&quot;-104.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;users geo: EU&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Router&amp;#45;&amp;gt;ShardC --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Router-&gt;ShardC&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M247.83,-199.77C257.88,-194.8 267.47,-188.57 275.27,-180.8 281.9,-174.18 286.84,-165.57 290.48,-156.87&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;293.66,-158.36 293.8,-147.76 287.09,-155.96 293.66,-158.36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;332.4&quot; y=&quot;-168.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;hash(user_id)=3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardA_Replica --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ShardA_Replica&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M96.53,-36C96.53,-36 12,-36 12,-36 6,-36 0,-30 0,-24 0,-24 0,-12 0,-12 0,-6 6,0 12,0 12,0 96.53,0 96.53,0 102.53,0 108.53,-6 108.53,-12 108.53,-12 108.53,-24 108.53,-24 108.53,-30 102.53,-36 96.53,-36&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;54.27&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ShardA_Replica&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardA&amp;#45;&amp;gt;ShardA_Replica --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ShardA-&gt;ShardA_Replica&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M56.41,-88.49C56.01,-75.79 55.55,-60.78 55.16,-47.96&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;58.66,-47.89 54.85,-38 51.66,-48.11 58.66,-47.89&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;85.79&quot; y=&quot;-58.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;replication&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardB_Replica --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ShardB_Replica&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M222.15,-36C222.15,-36 138.39,-36 138.39,-36 132.39,-36 126.39,-30 126.39,-24 126.39,-24 126.39,-12 126.39,-12 126.39,-6 132.39,0 138.39,0 138.39,0 222.15,0 222.15,0 228.15,0 234.15,-6 234.15,-12 234.15,-12 234.15,-24 234.15,-24 234.15,-30 228.15,-36 222.15,-36&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.27&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ShardB_Replica&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardB&amp;#45;&amp;gt;ShardB_Replica --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ShardB-&gt;ShardB_Replica&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M180.27,-88.49C180.27,-75.79 180.27,-60.78 180.27,-47.96&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;183.77,-48 180.27,-38 176.77,-48 183.77,-48&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;210.2&quot; y=&quot;-58.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;replication&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardC_Replica --&gt;
&lt;g id=&quot;node8&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ShardC_Replica&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M348.15,-36C348.15,-36 264.39,-36 264.39,-36 258.39,-36 252.39,-30 252.39,-24 252.39,-24 252.39,-12 252.39,-12 252.39,-6 258.39,0 264.39,0 264.39,0 348.15,0 348.15,0 354.15,0 360.15,-6 360.15,-12 360.15,-12 360.15,-24 360.15,-24 360.15,-30 354.15,-36 348.15,-36&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;306.27&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ShardC_Replica&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ShardC&amp;#45;&amp;gt;ShardC_Replica --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;ShardC-&gt;ShardC_Replica&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M301.98,-88.49C302.77,-75.79 303.69,-60.78 304.48,-47.96&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;307.97,-48.2 305.1,-38 300.99,-47.77 307.97,-48.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;333.91&quot; y=&quot;-58.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;replication&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Data distributed by key&lt;/strong&gt; — each shard holds a non-overlapping subset&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Less traffic per shard&lt;/strong&gt; — read/write load is divided by the number of shards&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Smaller indexes&lt;/strong&gt; — each shard’s index fits in memory, speeding queries&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Failure isolation&lt;/strong&gt; — a failure in one shard doesn’t affect other shards&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No single write serialization point&lt;/strong&gt; — multiple shards accept writes in parallel&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../database-federation&quot; class=&quot;internal alias&quot; data-slug=&quot;database-federation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Database Federation&lt;/a&gt; — federation splits by function, sharding splits by key (complementary strategies)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../denormalization&quot; class=&quot;internal alias&quot; data-slug=&quot;denormalization&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Denormalization&lt;/a&gt; — reduces need for cross-shard joins by duplicating data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../horizontal-scaling&quot; class=&quot;internal alias&quot; data-slug=&quot;horizontal-scaling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Horizontal Scaling&lt;/a&gt; — sharding is the database equivalent of horizontal scaling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — each shard can have its own replication topology for fault tolerance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../consistent-hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;consistent-hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Consistent Hashing&lt;/a&gt; — a key algorithm for minimizing data movement when adding/removing shards&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Resharding complexity&lt;/strong&gt; — adding a new shard with a naive hash(N) strategy requires reshuffling most data; consistent hashing reduces but doesn’t eliminate this.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Skewed shards&lt;/strong&gt; — if the shard key is poorly chosen, one shard may get 80% of traffic while others sit idle.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cross-shard queries&lt;/strong&gt; — operations that span multiple shards require scatter-gather (query all shards and merge results), which is slow and complex.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>sql-tuning</title>
    <link href="https://animishraa05.github.io/wiki/system-design/sql-tuning" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/sql-tuning.md" />
    <summary>The Problem Poorly written SQL queries can be 100–1000x slower than optimized alternatives.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Poorly written SQL queries can be 100–1000x slower than optimized alternatives. Without benchmarking and profiling, development teams deploy queries that waste database CPU, memory, and I/O — degrading system performance for all users.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;SQL tuning is the practice of optimizing schema design, indexing, and query structure to improve database performance. The process follows: benchmark (establish baseline), profile (identify slow queries with tools like the slow query log), and optimize (tighten schema, add indexes, rewrite queries).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Benchmark&lt;/strong&gt; — use tools like &lt;code class=&quot;notranslate&quot;&gt;ab&lt;/code&gt; or &lt;code class=&quot;notranslate&quot;&gt;sysbench&lt;/code&gt; to establish baseline query performance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Profile&lt;/strong&gt; — enable the slow query log to identify queries that exceed a threshold (e.g., 100ms).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tighten schema&lt;/strong&gt; — use &lt;code class=&quot;notranslate&quot;&gt;CHAR&lt;/code&gt; instead of &lt;code class=&quot;notranslate&quot;&gt;VARCHAR&lt;/code&gt; for fixed-length fields, &lt;code class=&quot;notranslate&quot;&gt;INT&lt;/code&gt; for numbers, &lt;code class=&quot;notranslate&quot;&gt;DECIMAL&lt;/code&gt; for currency, &lt;code class=&quot;notranslate&quot;&gt;TEXT&lt;/code&gt; for large blobs, and add &lt;code class=&quot;notranslate&quot;&gt;NOT NULL&lt;/code&gt; where possible to improve search performance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add indexes&lt;/strong&gt; — index columns used in &lt;code class=&quot;notranslate&quot;&gt;WHERE&lt;/code&gt;, &lt;code class=&quot;notranslate&quot;&gt;ORDER BY&lt;/code&gt;, &lt;code class=&quot;notranslate&quot;&gt;GROUP BY&lt;/code&gt;, and &lt;code class=&quot;notranslate&quot;&gt;JOIN&lt;/code&gt; clauses; use B-tree indexes for sorted access.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Avoid expensive joins&lt;/strong&gt; — denormalize hot paths; partition very large tables; use query cache for repeated reads.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Monitor&lt;/strong&gt; — continuously profile to catch regressions after schema or code changes.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: SQLTuning Pages: 1 --&gt;
&lt;svg width=&quot;628pt&quot; height=&quot;285pt&quot; viewBox=&quot;0.00 0.00 628.00 285.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 281.4)&quot;&gt;
&lt;title&gt;SQLTuning&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-281.4 624.33,-281.4 624.33,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Benchmark --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Benchmark&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M491.27,-277.4C491.27,-277.4 391.58,-277.4 391.58,-277.4 385.58,-277.4 379.58,-271.4 379.58,-265.4 379.58,-265.4 379.58,-247.8 379.58,-247.8 379.58,-241.8 385.58,-235.8 391.58,-235.8 391.58,-235.8 491.27,-235.8 491.27,-235.8 497.27,-235.8 503.27,-241.8 503.27,-247.8 503.27,-247.8 503.27,-265.4 503.27,-265.4 503.27,-271.4 497.27,-277.4 491.27,-277.4&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;441.42&quot; y=&quot;-260.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Benchmark&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;441.42&quot; y=&quot;-244&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(establish baseline)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Profile --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Profile&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M483.69,-198.8C483.69,-198.8 399.15,-198.8 399.15,-198.8 393.15,-198.8 387.15,-192.8 387.15,-186.8 387.15,-186.8 387.15,-169.2 387.15,-169.2 387.15,-163.2 393.15,-157.2 399.15,-157.2 399.15,-157.2 483.69,-157.2 483.69,-157.2 489.69,-157.2 495.69,-163.2 495.69,-169.2 495.69,-169.2 495.69,-186.8 495.69,-186.8 495.69,-192.8 489.69,-198.8 483.69,-198.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;441.42&quot; y=&quot;-182.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Profile&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;441.42&quot; y=&quot;-165.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(slow query log)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Benchmark&amp;#45;&amp;gt;Profile --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Benchmark-&gt;Profile&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M441.42,-235.47C441.42,-227.88 441.42,-219.05 441.42,-210.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;444.92,-210.77 441.42,-200.77 437.92,-210.77 444.92,-210.77&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Schema --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Schema&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M202.84,-120.2C202.84,-120.2 12,-120.2 12,-120.2 6,-120.2 0,-114.2 0,-108.2 0,-108.2 0,-90.6 0,-90.6 0,-84.6 6,-78.6 12,-78.6 12,-78.6 202.84,-78.6 202.84,-78.6 208.84,-78.6 214.84,-84.6 214.84,-90.6 214.84,-90.6 214.84,-108.2 214.84,-108.2 214.84,-114.2 208.84,-120.2 202.84,-120.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;107.42&quot; y=&quot;-103.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Tighten Schema&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;107.42&quot; y=&quot;-86.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CHAR &gt; VARCHAR, NOT NULL&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Profile&amp;#45;&amp;gt;Schema --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Profile-&gt;Schema&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M387.02,-164.52C338.29,-153.35 265.63,-136.68 206.59,-123.14&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;207.74,-119.82 197.21,-120.99 206.18,-126.64 207.74,-119.82&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Index --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Index&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M409.56,-120.2C409.56,-120.2 245.29,-120.2 245.29,-120.2 239.29,-120.2 233.29,-114.2 233.29,-108.2 233.29,-108.2 233.29,-90.6 233.29,-90.6 233.29,-84.6 239.29,-78.6 245.29,-78.6 245.29,-78.6 409.56,-78.6 409.56,-78.6 415.56,-78.6 421.56,-84.6 421.56,-90.6 421.56,-90.6 421.56,-108.2 421.56,-108.2 421.56,-114.2 415.56,-120.2 409.56,-120.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;327.42&quot; y=&quot;-103.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Add Indexes&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;327.42&quot; y=&quot;-86.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;WHERE / JOIN / ORDER BY&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Profile&amp;#45;&amp;gt;Index --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Profile-&gt;Index&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M411.47,-156.87C397.83,-147.71 381.51,-136.74 366.89,-126.92&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;369.08,-124.17 358.83,-121.5 365.17,-129.98 369.08,-124.17&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Rewrite --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Rewrite&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M566.85,-120.2C566.85,-120.2 452,-120.2 452,-120.2 446,-120.2 440,-114.2 440,-108.2 440,-108.2 440,-90.6 440,-90.6 440,-84.6 446,-78.6 452,-78.6 452,-78.6 566.85,-78.6 566.85,-78.6 572.85,-78.6 578.85,-84.6 578.85,-90.6 578.85,-90.6 578.85,-108.2 578.85,-108.2 578.85,-114.2 572.85,-120.2 566.85,-120.2&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;509.42&quot; y=&quot;-103.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Rewrite Queries&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;509.42&quot; y=&quot;-86.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;avoid joins, use cache&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Profile&amp;#45;&amp;gt;Rewrite --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Profile-&gt;Rewrite&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M459.29,-156.87C466.8,-148.41 475.69,-138.4 483.87,-129.18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;486.41,-131.59 490.43,-121.79 481.18,-126.94 486.41,-131.59&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Monitor --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Monitor&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M458.39,-41.6C458.39,-41.6 352.45,-41.6 352.45,-41.6 346.45,-41.6 340.45,-35.6 340.45,-29.6 340.45,-29.6 340.45,-12 340.45,-12 340.45,-6 346.45,0 352.45,0 352.45,0 458.39,0 458.39,0 464.39,0 470.39,-6 470.39,-12 470.39,-12 470.39,-29.6 470.39,-29.6 470.39,-35.6 464.39,-41.6 458.39,-41.6&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;405.42&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Monitor&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;405.42&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;continuous profiling&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Schema&amp;#45;&amp;gt;Monitor --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Schema-&gt;Monitor&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M186.11,-78.17C230.46,-66.77 285.6,-52.6 329.49,-41.32&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;330.11,-44.77 338.93,-38.89 328.37,-37.99 330.11,-44.77&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Index&amp;#45;&amp;gt;Monitor --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Index-&gt;Monitor&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M347.92,-78.27C356.71,-69.63 367.15,-59.39 376.69,-50.01&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;379.03,-52.62 383.71,-43.12 374.13,-47.63 379.03,-52.62&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Rewrite&amp;#45;&amp;gt;Monitor --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Rewrite-&gt;Monitor&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M482.1,-78.27C469.89,-69.29 455.33,-58.56 442.19,-48.88&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;444.27,-46.07 434.14,-42.95 440.12,-51.7 444.27,-46.07&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Monitor&amp;#45;&amp;gt;Profile --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Monitor-&gt;Profile&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M470.77,-23.69C511.42,-28.67 560.85,-42.47 587.42,-78.6 598.38,-93.49 597.86,-104.94 587.42,-120.2 569.31,-146.68 536.9,-160.81 507.21,-168.36&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;506.44,-164.95 497.48,-170.6 508.01,-171.77 506.44,-164.95&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;607.89&quot; y=&quot;-95.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;loop&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Benchmark then profile&lt;/strong&gt; — always measure before optimizing; don’t guess at bottlenecks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Index WHERE/GROUP BY/ORDER BY/JOIN columns&lt;/strong&gt; — these are the primary targets for index optimization&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CHAR is faster than VARCHAR&lt;/strong&gt; — fixed-width fields avoid length-prefix overhead; use for codes, enums, fixed identifiers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NOT NULL improves search performance&lt;/strong&gt; — nullable columns require extra checks per row&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Index updates slow writes&lt;/strong&gt; — each index must be updated on INSERT/UPDATE; balance read vs write needs&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../denormalization&quot; class=&quot;internal alias&quot; data-slug=&quot;denormalization&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Denormalization&lt;/a&gt; — a specific SQL tuning technique that trades write speed for read speed&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — tuning benefits both masters (write-heavy) and slaves (read-heavy) differently&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../nosql-database-types&quot; class=&quot;internal alias&quot; data-slug=&quot;nosql-database-types&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;NoSQL Database Types&lt;/a&gt; — some tuning concerns (schema design, joins) are avoided by moving to NoSQL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — caching reduces database load, complementing SQL tuning efforts&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — sharding reduces per-node data volume, which directly improves query performance&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Premature optimization&lt;/strong&gt; — tuning queries that run once a day for 200ms is a waste of effort; profile first to find the real bottlenecks.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Index overkill&lt;/strong&gt; — too many indexes slow down writes significantly and increase disk usage; a table with 10 indexes on 1M rows can see 3x slower inserts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Query cache invalidation&lt;/strong&gt; — MySQL query cache is invalidated on every write to the table; on write-heavy tables, the cache does more harm than good.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>SQL vs NoSQL — Database Paradigm Comparison</title>
    <link href="https://animishraa05.github.io/wiki/system-design/sql-vs-nosql" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/sql-vs-nosql.md" />
    <summary>What’s Being Compared SQL (relational) and NoSQL (non-relational) databases represent fundamentally different approaches to data storage.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="database" label="database" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;whats-being-compared&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;What’s Being Compared&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#whats-being-compared&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;SQL (relational) and NoSQL (non-relational) databases represent fundamentally different approaches to data storage. SQL databases enforce rigid schemas and support ACID transactions; NoSQL databases offer flexible schemas and horizontal scalability at the cost of consistency guarantees. The choice is not about which is better — it’s about which fits the data and access patterns.&lt;/p&gt;
&lt;h2 id=&quot;the-core-tension&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Core Tension&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-core-tension&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;SQL optimizes for &lt;strong&gt;data integrity and complex relationships&lt;/strong&gt; through normalization, joins, and transactions. NoSQL optimizes for &lt;strong&gt;scale and flexibility&lt;/strong&gt; through denormalization, horizontal partitioning, and relaxed consistency. You trade relational power for operational simplicity at scale.&lt;/p&gt;
&lt;h2 id=&quot;comparison&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparison&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparison&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;SQL (RDBMS)&lt;/th&gt;
&lt;th&gt;NoSQL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Data structure&lt;/td&gt;
&lt;td&gt;Tables with rows and columns&lt;/td&gt;
&lt;td&gt;Key-value, documents, wide columns, graphs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Schema&lt;/td&gt;
&lt;td&gt;Strict, predefined&lt;/td&gt;
&lt;td&gt;Dynamic, flexible&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relationships&lt;/td&gt;
&lt;td&gt;Foreign keys + JOINs&lt;/td&gt;
&lt;td&gt;Embedded documents or app-level joins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transactions&lt;/td&gt;
&lt;td&gt;ACID (Atomic, Consistent, Isolated, Durable)&lt;/td&gt;
&lt;td&gt;BASE (Basically Available, Soft state, Eventual consistency)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scaling&lt;/td&gt;
&lt;td&gt;Vertical primarily (with replication/sharding)&lt;/td&gt;
&lt;td&gt;Horizontal by design&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Consistency&lt;/td&gt;
&lt;td&gt;Strong consistency&lt;/td&gt;
&lt;td&gt;Eventual consistency typical&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Structured data, complex queries, transactions&lt;/td&gt;
&lt;td&gt;Semi-structured data, massive scale, flexible schema&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Examples&lt;/td&gt;
&lt;td&gt;MySQL, PostgreSQL, Oracle&lt;/td&gt;
&lt;td&gt;MongoDB, Cassandra, Redis, Neo4j&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;when-to-choose-sql&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;When to Choose SQL&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#when-to-choose-sql&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Data is highly structured with clear relationships&lt;/li&gt;
&lt;li&gt;You need complex JOINs and multi-row transactions&lt;/li&gt;
&lt;li&gt;Your workload has more reads than writes (typical 100:1 or 1000:1)&lt;/li&gt;
&lt;li&gt;You need strong consistency guarantees&lt;/li&gt;
&lt;li&gt;Your team is familiar with relational modeling&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;when-to-choose-nosql&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;When to Choose NoSQL&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#when-to-choose-nosql&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Data is semi-structured or unstructured&lt;/li&gt;
&lt;li&gt;You need to store terabytes or petabytes of data&lt;/li&gt;
&lt;li&gt;Your schema changes frequently&lt;/li&gt;
&lt;li&gt;You need very high write throughput&lt;/li&gt;
&lt;li&gt;You’re handling clickstreams, logs, leaderboards, or temporary data (shopping carts)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-insight&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Insight&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-insight&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Many production systems use &lt;strong&gt;both&lt;/strong&gt; (polyglot persistence). The relational database holds core business entities with transactional integrity, while NoSQL stores handle high-volume, flexible data like clickstream logs, session data, and user feeds. The question isn’t which one, but which one for which part of the system.&lt;/p&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../nosql-database-types&quot; class=&quot;internal alias&quot; data-slug=&quot;nosql-database-types&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;NoSQL Database Types&lt;/a&gt; — the four categories of NoSQL databases&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../cap-theorem&quot; class=&quot;internal alias&quot; data-slug=&quot;cap-theorem&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CAP Theorem&lt;/a&gt; — explains the consistency trade-offs in NoSQL&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../sharding&quot; class=&quot;internal alias&quot; data-slug=&quot;sharding&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sharding&lt;/a&gt; — horizontal scaling technique used by NoSQL&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../denormalization&quot; class=&quot;internal alias&quot; data-slug=&quot;denormalization&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Denormalization&lt;/a&gt; — SQL technique that mirrors NoSQL’s approach&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — SQL scaling technique&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>strong-consistency</title>
    <link href="https://animishraa05.github.io/wiki/system-design/strong-consistency" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/strong-consistency.md" />
    <summary>The Problem Many applications — banking, inventory management, distributed locking — cannot tolerate reading stale data.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="distributed-systems" label="distributed-systems" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Many applications — banking, inventory management, distributed locking — cannot tolerate reading stale data. A user who transfers money should see the updated balance on refresh.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Strong consistency guarantees that after a write completes, all subsequent reads (from any node) will return that write’s value. This is achieved through synchronous replication: a write is not acknowledged to the client until a quorum of nodes confirms they have persisted it. The system behaves as if there is a single copy of the data, regardless of replication factor.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Client issues write&lt;/strong&gt;: The write request is sent to a coordinator node.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Synchronous replication&lt;/strong&gt;: The coordinator sends the write to all replicas and waits for acknowledgment from a quorum (e.g., majority).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Acknowledge to client&lt;/strong&gt;: Once the quorum acknowledges, the client receives confirmation. All future reads, regardless of which node they hit, will see this value.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Read follows same path&lt;/strong&gt;: Reads may also require quorum to ensure they see the latest value, or they may go through the primary node (which always has the latest write).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;765pt&quot; height=&quot;382pt&quot; viewBox=&quot;0.00 0.00 765.00 382.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 377.8)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-377.8 760.56,-377.8 760.56,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_strong&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;84.18,-8 84.18,-324 748.56,-324 748.56,-8 84.18,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;416.37&quot; y=&quot;-307.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Strong Consistency (Synchronous Replication)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M134.18,-192C134.18,-192 104.18,-192 104.18,-192 98.18,-192 92.18,-186 92.18,-180 92.18,-180 92.18,-168 92.18,-168 92.18,-162 98.18,-156 104.18,-156 104.18,-156 134.18,-156 134.18,-156 140.18,-156 146.18,-162 146.18,-168 146.18,-168 146.18,-180 146.18,-180 146.18,-186 140.18,-192 134.18,-192&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;119.18&quot; y=&quot;-169.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- coord --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;coord&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M444.75,-192C444.75,-192 385.1,-192 385.1,-192 379.1,-192 373.1,-186 373.1,-180 373.1,-180 373.1,-168 373.1,-168 373.1,-162 379.1,-156 385.1,-156 385.1,-156 444.75,-156 444.75,-156 450.75,-156 456.75,-162 456.75,-168 456.75,-168 456.75,-180 456.75,-180 456.75,-186 450.75,-192 444.75,-192&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;414.93&quot; y=&quot;-169.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Coordinator&lt;/text&gt;
&lt;/g&gt;
&lt;!-- client&amp;#45;&amp;gt;coord --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;client-&gt;coord&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M146.4,-167.92C189.96,-158.71 279.9,-143.48 355.1,-155.2 357.28,-155.54 359.5,-155.95 361.72,-156.41&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;360.84,-159.8 371.38,-158.75 362.49,-152.99 360.84,-159.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;305.73&quot; y=&quot;-159.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Write X=7&lt;/text&gt;
&lt;/g&gt;
&lt;!-- coord&amp;#45;&amp;gt;client --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;coord-&gt;client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M372.66,-174C315.5,-174 213.04,-174 157.85,-174&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;158.02,-170.5 148.02,-174 158.02,-177.5 158.02,-170.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;305.73&quot; y=&quot;-178.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt; Write committed&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M728.56,-271C728.56,-271 651.04,-271 651.04,-271 645.04,-271 639.04,-265 639.04,-259 639.04,-259 639.04,-247 639.04,-247 639.04,-241 645.04,-235 651.04,-235 651.04,-235 728.56,-235 728.56,-235 734.56,-235 740.56,-241 740.56,-247 740.56,-247 740.56,-259 740.56,-259 740.56,-265 734.56,-271 728.56,-271&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;689.8&quot; y=&quot;-248.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 1 (saved)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- coord&amp;#45;&amp;gt;n1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;coord-&gt;n1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M457.25,-189.21C463.1,-191.23 469.06,-193.22 474.75,-195 489.49,-199.62 569.8,-221.22 627.72,-236.71&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;626.59,-240.03 637.15,-239.23 628.4,-233.27 626.59,-240.03&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;547.89&quot; y=&quot;-238.91&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;sync write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M728.56,-92C728.56,-92 651.04,-92 651.04,-92 645.04,-92 639.04,-86 639.04,-80 639.04,-80 639.04,-68 639.04,-68 639.04,-62 645.04,-56 651.04,-56 651.04,-56 728.56,-56 728.56,-56 734.56,-56 740.56,-62 740.56,-68 740.56,-68 740.56,-80 740.56,-80 740.56,-86 734.56,-92 728.56,-92&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;689.8&quot; y=&quot;-69.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 2 (saved)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- coord&amp;#45;&amp;gt;n2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;coord-&gt;n2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M420.76,-155.8C428.07,-132.35 444.43,-92.55 474.75,-75.2 520.99,-48.75 582.56,-51.54 627.8,-59.13&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;626.97,-62.53 637.43,-60.87 628.22,-55.65 626.97,-62.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;547.89&quot; y=&quot;-79.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;sync write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n3 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;n3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M728.56,-185C728.56,-185 651.04,-185 651.04,-185 645.04,-185 639.04,-179 639.04,-173 639.04,-173 639.04,-161 639.04,-161 639.04,-155 645.04,-149 651.04,-149 651.04,-149 728.56,-149 728.56,-149 734.56,-149 740.56,-155 740.56,-161 740.56,-161 740.56,-173 740.56,-173 740.56,-179 734.56,-185 728.56,-185&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;689.8&quot; y=&quot;-162.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node 3 (saved)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- coord&amp;#45;&amp;gt;n3 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;coord-&gt;n3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M457,-159.11C462.89,-157.49 468.93,-156.11 474.75,-155.2 538.99,-145.18 556.26,-149.6 621.04,-155.2 623.09,-155.38 625.17,-155.58 627.27,-155.82&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;626.73,-159.28 637.1,-157.07 627.62,-152.33 626.73,-159.28&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;547.89&quot; y=&quot;-159.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;sync write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n1&amp;#45;&amp;gt;coord --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n1-&gt;coord&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M638.74,-264.79C593.42,-272.77 526.08,-277.73 474.75,-252 454.09,-241.64 438.76,-220.21 428.94,-202.43&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;432.19,-201.11 424.49,-193.84 425.98,-204.33 432.19,-201.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;547.89&quot; y=&quot;-275.41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ack&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n2&amp;#45;&amp;gt;coord --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n2-&gt;coord&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M638.86,-87.37C632.86,-88.94 626.81,-90.52 621.04,-92 556.16,-108.64 535,-98.94 474.75,-128.2 463.92,-133.46 453.2,-140.94 443.93,-148.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;441.8,-145.56 436.36,-154.65 446.29,-150.93 441.8,-145.56&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;547.89&quot; y=&quot;-132.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ack&lt;/text&gt;
&lt;/g&gt;
&lt;!-- n3&amp;#45;&amp;gt;coord --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;n3-&gt;coord&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M638.86,-171.05C632.86,-171.43 626.81,-171.76 621.04,-172 569.27,-174.16 510.1,-174.51 468.66,-174.41&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;468.72,-170.91 458.71,-174.38 468.7,-177.91 468.72,-170.91&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;547.89&quot; y=&quot;-178.63&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;ack&lt;/text&gt;
&lt;/g&gt;
&lt;!-- reader --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;reader&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M444.17,-52C444.17,-52 385.68,-52 385.68,-52 379.68,-52 373.68,-46 373.68,-40 373.68,-40 373.68,-28 373.68,-28 373.68,-22 379.68,-16 385.68,-16 385.68,-16 444.17,-16 444.17,-16 450.17,-16 456.17,-22 456.17,-28 456.17,-28 456.17,-40 456.17,-40 456.17,-46 450.17,-52 444.17,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;414.93&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client Read&lt;/text&gt;
&lt;/g&gt;
&lt;!-- reader&amp;#45;&amp;gt;n2 --&gt;
&lt;g id=&quot;edge9&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;reader-&gt;n2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M456.44,-28.26C498.41,-23.69 565.5,-20.25 621.04,-35.2 632.42,-38.27 643.9,-43.73 654.08,-49.61&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;652.14,-52.52 662.5,-54.76 655.8,-46.55 652.14,-52.52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;547.89&quot; y=&quot;-39.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;→ X=7 (guaranteed latest)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- note --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;note&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;232.35,-373.8 0,-373.8 0,-332.2 238.35,-332.2 238.35,-367.8 232.35,-373.8&quot;&gt;&lt;/polygon&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;232.35,-373.8 232.35,-367.8&quot;&gt;&lt;/polyline&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;238.35,-367.8 232.35,-367.8&quot;&gt;&lt;/polyline&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;119.18&quot; y=&quot;-357.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;All nodes hold the same value&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;119.18&quot; y=&quot;-340.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;before client is told the write succeeded&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;All reads see the latest write&lt;/strong&gt; — behaves like a single-node system&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Synchronous replication&lt;/strong&gt; — writes are committed to a quorum before acknowledgment&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Higher latency&lt;/strong&gt; than weak or eventual consistency (waiting for slowest quorum member)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Used in RDBMS (primary reads), ZooKeeper (atomic broadcast), and file systems (NFS, GFS metadata)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../eventual-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;eventual-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Eventual Consistency&lt;/a&gt; — sync vs async replication, immediate guarantees vs eventual convergence&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../weak-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;weak-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Weak Consistency&lt;/a&gt; — deterministic guarantees vs no guarantees at all&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cp-consistency-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;cp-consistency-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CP — Consistency and Partition Tolerance&lt;/a&gt; — CP systems guarantee strong consistency during normal operation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../master-slave-replication&quot; class=&quot;internal alias&quot; data-slug=&quot;master-slave-replication&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Master-Slave Replication&lt;/a&gt; — reading from the master provides strong consistency; slaves may lag&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Performance cliff under contention&lt;/strong&gt;: Strong consistency requires global ordering of writes. Under high contention, this serialization becomes a bottleneck and throughput collapses.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not truly linearizable in practice&lt;/strong&gt;: Many systems advertise strong consistency but use clock-based ordering, which can fail under clock skew. True linearizability (e.g., Spanner’s TrueTime) is rare and expensive.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-region cost&lt;/strong&gt;: Synchronous replication across geographic regions is extremely slow (speed of light latency). Global strong consistency is impractical for most systems — multi-master or eventual consistency is preferred.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>task-queues</title>
    <link href="https://animishraa05.github.io/wiki/system-design/task-queues" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/task-queues.md" />
    <summary>The Problem Computationally intensive or time-based background jobs (image processing, report generation, batch operations) need scheduling, execution management, and result delivery that message queues alone do not provide.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="messaging" label="messaging" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Computationally intensive or time-based background jobs (image processing, report generation, batch operations) need scheduling, execution management, and result delivery that message queues alone do not provide.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Task queues receive tasks with their related data, schedule and execute them on worker processes, and deliver results back to the caller. They extend message queue concepts with scheduling, retries, and result tracking for compute-heavy workloads.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Client submits a task (function + parameters) to the queue.&lt;/li&gt;
&lt;li&gt;Queue schedules the task for execution (immediately or at a future time).&lt;/li&gt;
&lt;li&gt;A worker picks up the task and executes the computation.&lt;/li&gt;
&lt;li&gt;Worker stores the result or delivers it back to the client.&lt;/li&gt;
&lt;li&gt;If the task fails, the queue can retry according to configured policies.&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;Celery (Python) is a popular task queue framework with support for periodic scheduling, result backends, and multiple message broker backends (Redis, RabbitMQ).&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: TaskQueues Pages: 1 --&gt;
&lt;svg width=&quot;679pt&quot; height=&quot;125pt&quot; viewBox=&quot;0.00 0.00 679.00 125.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 120.8)&quot;&gt;
&lt;title&gt;TaskQueues&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-120.8 674.85,-120.8 674.85,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Client --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M42,-52C42,-52 12,-52 12,-52 6,-52 0,-46 0,-40 0,-40 0,-28 0,-28 0,-22 6,-16 12,-16 12,-16 42,-16 42,-16 48,-16 54,-22 54,-28 54,-28 54,-40 54,-40 54,-46 48,-52 42,-52&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Client&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Queue&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M246.12,-82C246.12,-82 186.87,-82 186.87,-82 180.87,-82 174.87,-76 174.87,-70 174.87,-70 174.87,-58 174.87,-58 174.87,-52 180.87,-46 186.87,-46 186.87,-46 246.12,-46 246.12,-46 252.12,-46 258.12,-52 258.12,-58 258.12,-58 258.12,-70 258.12,-70 258.12,-76 252.12,-82 246.12,-82&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;216.49&quot; y=&quot;-59.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Task Queue&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;Queue --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;Queue&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M45.56,-52.45C53.01,-59 62.23,-65.59 72,-69 101.06,-79.15 135.47,-78.34 163.31,-74.79&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;163.52,-78.3 172.92,-73.4 162.52,-71.37 163.52,-78.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;114.43&quot; y=&quot;-98.21&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Submit task&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;114.43&quot; y=&quot;-81.41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;data + function&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Store --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Store&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M658.85,-36C658.85,-36 598.02,-36 598.02,-36 592.02,-36 586.02,-30 586.02,-24 586.02,-24 586.02,-12 586.02,-12 586.02,-6 592.02,0 598.02,0 598.02,0 658.85,0 658.85,0 664.85,0 670.85,-6 670.85,-12 670.85,-12 670.85,-24 670.85,-24 670.85,-30 664.85,-36 658.85,-36&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;628.44&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Result Store&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Client&amp;#45;&amp;gt;Store --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Client-&gt;Store&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.14,-33.3C145.28,-30.87 450.18,-22.73 574.24,-19.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;574.25,-22.92 584.16,-19.16 574.07,-15.92 574.25,-22.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;321.03&quot; y=&quot;-31.49&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Poll result&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M174.68,-52.14C168.74,-50.67 162.67,-49.29 156.87,-48.2 126.37,-42.45 91.34,-38.77 65.51,-36.6&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;66.09,-33.14 55.85,-35.83 65.54,-40.12 66.09,-33.14&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;114.43&quot; y=&quot;-52.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Task ID&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Worker --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Worker&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M459.87,-82C459.87,-82 395.94,-82 395.94,-82 389.94,-82 383.94,-76 383.94,-70 383.94,-70 383.94,-58 383.94,-58 383.94,-52 389.94,-46 395.94,-46 395.94,-46 459.87,-46 459.87,-46 465.87,-46 471.87,-52 471.87,-58 471.87,-58 471.87,-70 471.87,-70 471.87,-76 465.87,-82 459.87,-82&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;427.9&quot; y=&quot;-59.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Worker Pool&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Worker --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Worker&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M258.37,-64C290.91,-64 336.76,-64 372.42,-64&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;372.09,-67.5 382.09,-64 372.09,-60.5 372.09,-67.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;321.03&quot; y=&quot;-68.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Dispatch task&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Worker&amp;#45;&amp;gt;Worker --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Worker-&gt;Worker&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M409.62,-82.15C406.81,-91.54 412.9,-100 427.9,-100 436.34,-100 441.96,-97.32 444.76,-93.31&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;448.2,-94.02 445.99,-83.65 441.25,-93.13 448.2,-94.02&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;427.9&quot; y=&quot;-104.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Execute computation&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Worker&amp;#45;&amp;gt;Store --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Worker-&gt;Store&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M472.15,-54.11C499.62,-47.82 535.92,-39.47 568.02,-32 570.15,-31.5 572.32,-31 574.51,-30.49&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;575.16,-33.93 584.09,-28.24 573.56,-27.11 575.16,-33.93&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;528.94&quot; y=&quot;-53.68&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Store result&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Store&amp;#45;&amp;gt;Client --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Store-&gt;Client&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M585.8,-15.12C534.22,-11.72 443.65,-6.25 365.94,-4.2 234.95,-0.75 201.85,-9.43 72,-27 69.96,-27.28 67.87,-27.57 65.76,-27.88&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;65.36,-24.4 55.99,-29.35 66.4,-31.32 65.36,-24.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;321.03&quot; y=&quot;-8.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Return result&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Schedules and executes computational tasks (not just message passing)&lt;/li&gt;
&lt;li&gt;Supports scheduled/delayed execution (cron-like scheduling)&lt;/li&gt;
&lt;li&gt;Returns results to the caller via a result backend&lt;/li&gt;
&lt;li&gt;Built-in retry and error handling for failed tasks&lt;/li&gt;
&lt;li&gt;Well-suited for CPU-intensive or long-running background work&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — task queues extend message queue concepts with scheduling and result tracking&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../back-pressure&quot; class=&quot;internal alias&quot; data-slug=&quot;back-pressure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Back Pressure&lt;/a&gt; — prevents task queue overflow under heavy submission&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../microservices-architecture&quot; class=&quot;internal alias&quot; data-slug=&quot;microservices-architecture&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Microservices Architecture&lt;/a&gt; — background processing offloads work from request path&lt;/li&gt;
&lt;li&gt;Contrasts with: synchronous processing — async background computation vs inline blocking execution&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Task idempotency&lt;/strong&gt;: Retries can cause duplicate execution. Design tasks to be idempotent or use a deduplication mechanism.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Worker death&lt;/strong&gt;: If a worker dies mid-task, the task is lost or stuck. Use task acknowledgements and visibility timeouts to re-queue.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Task starvation&lt;/strong&gt;: Long-running tasks can block workers from picking up short tasks. Use separate queues or priority queues to mitigate.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>weak-consistency</title>
    <link href="https://animishraa05.github.io/wiki/system-design/weak-consistency" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/weak-consistency.md" />
    <summary>The Problem Strong consistency has performance costs that some real-time applications cannot afford.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="distributed-systems" label="distributed-systems" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Strong consistency has performance costs that some real-time applications cannot afford. Applications like VoIP, video chat, and multiplayer games need minimal latency above all else.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;After a write, subsequent reads may or may not see it — there is no guarantee whatsoever. Weak consistency is a best-effort approach that prioritizes low latency over any read-after-write guarantee. Unlike eventual consistency, there is no promise that replicas will ever converge to the same state.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Client writes&lt;/strong&gt;: The write is accepted by the nearest or fastest-responding node.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Best-effort propagation&lt;/strong&gt;: The write is broadcast to other nodes with no acknowledgment or ordering guarantees.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads return local state&lt;/strong&gt;: Each read returns whatever the responding node has locally — potentially stale, potentially newer, potentially conflicting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No convergence contract&lt;/strong&gt;: Unlike eventual consistency, there is no guarantee that all nodes will eventually hold the same value. If propagation is interrupted, divergence persists.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: G Pages: 1 --&gt;
&lt;svg width=&quot;555pt&quot; height=&quot;342pt&quot; viewBox=&quot;0.00 0.00 555.00 342.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 337.8)&quot;&gt;
&lt;title&gt;G&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-337.8 550.7,-337.8 550.7,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_weak&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;86.02,-8 86.02,-284 538.7,-284 538.7,-8 86.02,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;312.36&quot; y=&quot;-267.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Weak Consistency&lt;/text&gt;
&lt;/g&gt;
&lt;!-- writer --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;writer&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M162.28,-92C162.28,-92 106.02,-92 106.02,-92 100.02,-92 94.02,-86 94.02,-80 94.02,-80 94.02,-68 94.02,-68 94.02,-62 100.02,-56 106.02,-56 106.02,-56 162.28,-56 162.28,-56 168.28,-56 174.28,-62 174.28,-68 174.28,-68 174.28,-80 174.28,-80 174.28,-86 168.28,-92 162.28,-92&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.15&quot; y=&quot;-69.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Write: X=5&lt;/text&gt;
&lt;/g&gt;
&lt;!-- node_a --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;node_a&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M487.03,-93.8C487.03,-93.8 406.27,-93.8 406.27,-93.8 400.27,-93.8 394.27,-87.8 394.27,-81.8 394.27,-81.8 394.27,-64.2 394.27,-64.2 394.27,-58.2 400.27,-52.2 406.27,-52.2 406.27,-52.2 487.03,-52.2 487.03,-52.2 493.03,-52.2 499.03,-58.2 499.03,-64.2 499.03,-64.2 499.03,-81.8 499.03,-81.8 499.03,-87.8 493.03,-93.8 487.03,-93.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;446.65&quot; y=&quot;-77.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node A&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;446.65&quot; y=&quot;-60.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;X=5 (has write)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- writer&amp;#45;&amp;gt;node_a --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;writer-&gt;node_a&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M174.51,-58.11C216.59,-43.13 285.29,-24.47 344.6,-35.2 359.29,-37.86 374.63,-42.52 388.78,-47.69&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;387.34,-50.89 397.93,-51.17 389.83,-44.34 387.34,-50.89&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;315.45&quot; y=&quot;-39.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;accepted&lt;/text&gt;
&lt;/g&gt;
&lt;!-- node_b --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;node_b&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M518.7,-171.8C518.7,-171.8 374.6,-171.8 374.6,-171.8 368.6,-171.8 362.6,-165.8 362.6,-159.8 362.6,-159.8 362.6,-142.2 362.6,-142.2 362.6,-136.2 368.6,-130.2 374.6,-130.2 374.6,-130.2 518.7,-130.2 518.7,-130.2 524.7,-130.2 530.7,-136.2 530.7,-142.2 530.7,-142.2 530.7,-159.8 530.7,-159.8 530.7,-165.8 524.7,-171.8 518.7,-171.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;446.65&quot; y=&quot;-155.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node B&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;446.65&quot; y=&quot;-138.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;X=2 (never received write)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- writer&amp;#45;&amp;gt;node_b --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;writer-&gt;node_b&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;gray&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M174.58,-63.67C218.87,-54.36 291.5,-46.12 344.6,-75.2 357.52,-82.27 351.94,-92.86 362.6,-103 370.84,-110.83 380.59,-117.9 390.46,-124.05&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;gray&quot; stroke=&quot;gray&quot; points=&quot;388.62,-127.03 399.01,-129.12 392.19,-121.01 388.62,-127.03&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;315.45&quot; y=&quot;-79.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;best-effort&lt;/text&gt;
&lt;/g&gt;
&lt;!-- node_c --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;node_c&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M503.75,-240.8C503.75,-240.8 389.55,-240.8 389.55,-240.8 383.55,-240.8 377.55,-234.8 377.55,-228.8 377.55,-228.8 377.55,-211.2 377.55,-211.2 377.55,-205.2 383.55,-199.2 389.55,-199.2 389.55,-199.2 503.75,-199.2 503.75,-199.2 509.75,-199.2 515.75,-205.2 515.75,-211.2 515.75,-211.2 515.75,-228.8 515.75,-228.8 515.75,-234.8 509.75,-240.8 503.75,-240.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;446.65&quot; y=&quot;-224.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Node C&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;446.65&quot; y=&quot;-207.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;X=3 (no propagation)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- writer&amp;#45;&amp;gt;node_c --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;writer-&gt;node_c&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;gray&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M174.74,-89.79C205.12,-101.76 248.17,-118.42 286.3,-132 312,-141.16 323.27,-134.2 344.6,-151.2 356.71,-160.84 351.11,-170.64 362.6,-181 367.53,-185.44 373.05,-189.47 378.85,-193.1&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;gray&quot; stroke=&quot;gray&quot; points=&quot;377.07,-196.11 387.48,-198.08 380.57,-190.05 377.07,-196.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;315.45&quot; y=&quot;-155.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;best-effort&lt;/text&gt;
&lt;/g&gt;
&lt;!-- reader --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;reader&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M157.17,-212C157.17,-212 111.13,-212 111.13,-212 105.13,-212 99.13,-206 99.13,-200 99.13,-200 99.13,-188 99.13,-188 99.13,-182 105.13,-176 111.13,-176 111.13,-176 157.17,-176 157.17,-176 163.17,-176 169.17,-182 169.17,-188 169.17,-188 169.17,-200 169.17,-200 169.17,-206 163.17,-212 157.17,-212&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.15&quot; y=&quot;-189.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Reads X?&lt;/text&gt;
&lt;/g&gt;
&lt;!-- reader&amp;#45;&amp;gt;node_a --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;reader-&gt;node_a&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M165.48,-175.63C195.34,-158.15 242.7,-132.1 286.3,-115.2 317.3,-103.19 352.97,-93.39 382.7,-86.27&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;383.37,-89.7 392.31,-84.01 381.77,-82.89 383.37,-89.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;315.45&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;→ 5&lt;/text&gt;
&lt;/g&gt;
&lt;!-- reader&amp;#45;&amp;gt;node_b --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;reader-&gt;node_b&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M169.39,-191.46C210.98,-188.14 283.19,-181.58 344.6,-172 346.76,-171.66 348.94,-171.31 351.14,-170.95&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;351.49,-174.44 360.74,-169.28 350.29,-167.54 351.49,-174.44&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;315.45&quot; y=&quot;-184.03&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;→ 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- reader&amp;#45;&amp;gt;node_c --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;reader-&gt;node_c&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M169.6,-198.78C200.19,-202.87 246.14,-208.6 286.3,-212 312.15,-214.19 340.41,-215.84 365.87,-217.07&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;365.68,-220.56 375.83,-217.53 366,-213.57 365.68,-220.56&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;315.45&quot; y=&quot;-220.09&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;→ 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- note --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;note&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;262.3,-333.8 0,-333.8 0,-292.2 268.3,-292.2 268.3,-327.8 262.3,-333.8&quot;&gt;&lt;/polygon&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;262.3,-333.8 262.3,-327.8&quot;&gt;&lt;/polyline&gt;
&lt;polyline fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;268.3,-327.8 262.3,-327.8&quot;&gt;&lt;/polyline&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.15&quot; y=&quot;-317.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;No convergence guarantee&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.15&quot; y=&quot;-300.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Nodes may have different values indefinitely&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;No guarantee&lt;/strong&gt; that a write will ever be visible to a subsequent read&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lowest latency&lt;/strong&gt; of any consistency model — no coordination overhead&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Best-effort approach&lt;/strong&gt; — propagation happens but is not enforced&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Common in VoIP, video chat, realtime multiplayer games&lt;/strong&gt; where timing matters more than data accuracy&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../strong-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;strong-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Strong Consistency&lt;/a&gt; — weak gives no guarantees, strong guarantees the latest write is always visible&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../eventual-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;eventual-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Eventual Consistency&lt;/a&gt; — weak may never converge, eventual guarantees convergence given enough time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../ap-availability-partition-tolerance&quot; class=&quot;internal alias&quot; data-slug=&quot;ap-availability-partition-tolerance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;AP — Availability and Partition Tolerance&lt;/a&gt; — weak consistency prioritizes availability above all&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — cache-aside exhibits weak consistency between cache and database by design&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Write loss&lt;/strong&gt;: If a node accepts a write and crashes before propagating it, that write may be lost entirely.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not a good default&lt;/strong&gt;: Weak consistency is a deliberate trade-off for extreme performance requirements. Using it accidentally (e.g., misconfigured replication) leads to data loss and hard-to-debug heisenbugs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hard to test&lt;/strong&gt;: Since behavior is non-deterministic, weak consistency bugs are notoriously difficult to reproduce in test environments.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>write-behind-cache</title>
    <link href="https://animishraa05.github.io/wiki/system-design/write-behind-cache" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/write-behind-cache.md" />
    <summary>The Problem Synchronous writes (write-through) add database write latency to every write operation, reducing throughput for write-heavy workloads.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="caching" label="caching" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Synchronous writes (write-through) add database write latency to every write operation, reducing throughput for write-heavy workloads.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Write-behind (write-back) cache acknowledges the write to the application immediately and asynchronously persists the data to the database. This decouples write latency from database performance, dramatically improving throughput at the cost of potential data loss if the cache fails before the DB write completes.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Application adds or updates an entry in the cache.&lt;/li&gt;
&lt;li&gt;Cache immediately acknowledges success to the application.&lt;/li&gt;
&lt;li&gt;Cache asynchronously batches and writes data to the database in the background.&lt;/li&gt;
&lt;li&gt;The cache may coalesce multiple updates to the same key into a single DB write.&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;Write performance is greatly improved, but the window between cache acknowledgement and DB persistence creates a risk of data loss.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: WriteBehind Pages: 1 --&gt;
&lt;svg width=&quot;592pt&quot; height=&quot;132pt&quot; viewBox=&quot;0.00 0.00 592.00 132.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 128.23)&quot;&gt;
&lt;title&gt;WriteBehind&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-128.23 588.15,-128.23 588.15,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M70.1,-76.53C70.1,-76.53 12,-76.53 12,-76.53 6,-76.53 0,-70.53 0,-64.53 0,-64.53 0,-52.53 0,-52.53 0,-46.53 6,-40.53 12,-40.53 12,-40.53 70.1,-40.53 70.1,-40.53 76.1,-40.53 82.1,-46.53 82.1,-52.53 82.1,-52.53 82.1,-64.53 82.1,-64.53 82.1,-70.53 76.1,-76.53 70.1,-76.53&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.05&quot; y=&quot;-54.33&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Application&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M339.78,-79.33C339.78,-79.33 254.11,-79.33 254.11,-79.33 248.11,-79.33 242.11,-73.33 242.11,-67.33 242.11,-67.33 242.11,-49.73 242.11,-49.73 242.11,-43.73 248.11,-37.73 254.11,-37.73 254.11,-37.73 339.78,-37.73 339.78,-37.73 345.78,-37.73 351.78,-43.73 351.78,-49.73 351.78,-49.73 351.78,-67.33 351.78,-67.33 351.78,-73.33 345.78,-79.33 339.78,-79.33&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;296.94&quot; y=&quot;-62.73&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Cache&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;296.94&quot; y=&quot;-45.93&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Writes batched)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M63.67,-77.01C73.99,-84.64 86.94,-92.6 100.1,-96.53 152.91,-112.28 170.61,-109.8 224.11,-96.53 234.26,-94.01 244.57,-89.76 254.08,-84.99&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;255.53,-88.18 262.7,-80.39 252.23,-82.01 255.53,-88.18&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;162.1&quot; y=&quot;-111.63&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Write(key, data)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M82.56,-58.53C122.4,-58.53 183.86,-58.53 230.61,-58.53&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;230.34,-62.03 240.34,-58.53 230.34,-55.03 230.34,-62.03&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;162.1&quot; y=&quot;-62.73&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Read(key)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M241.71,-42.77C235.81,-41.53 229.86,-40.47 224.11,-39.73 169.44,-32.69 154.54,-31.13 100.1,-39.73 97.94,-40.07 95.75,-40.48 93.55,-40.94&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.91,-37.49 84.04,-43.28 94.58,-44.29 92.91,-37.49&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;162.1&quot; y=&quot;-43.93&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Immediate ACK&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M270.76,-37.45C257.71,-27.9 241,-17.66 224.11,-12.73 171.2,2.7 152.17,5.34 100.1,-12.73 88.15,-16.87 76.8,-24.61 67.36,-32.56&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;65.15,-29.84 60.06,-39.13 69.84,-35.04 65.15,-29.84&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;162.1&quot; y=&quot;-16.93&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Data (may be dirty)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M572.15,-76.53C572.15,-76.53 528.85,-76.53 528.85,-76.53 522.85,-76.53 516.85,-70.53 516.85,-64.53 516.85,-64.53 516.85,-52.53 516.85,-52.53 516.85,-46.53 522.85,-40.53 528.85,-40.53 528.85,-40.53 572.15,-40.53 572.15,-40.53 578.15,-40.53 584.15,-46.53 584.15,-52.53 584.15,-52.53 584.15,-64.53 584.15,-64.53 584.15,-70.53 578.15,-76.53 572.15,-76.53&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;550.5&quot; y=&quot;-54.33&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Database&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;DB --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M352.22,-58.53C397.9,-58.53 462.42,-58.53 505.08,-58.53&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;504.98,-62.03 514.98,-58.53 504.98,-55.03 504.98,-62.03&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;434.31&quot; y=&quot;-62.73&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Async batched write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DB-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M516.56,-42.86C510.78,-40.74 504.73,-38.89 498.85,-37.73 442.57,-26.62 426.58,-29.67 369.78,-37.73 367.61,-38.04 365.42,-38.39 363.21,-38.79&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;362.67,-35.33 353.59,-40.79 364.1,-42.18 362.67,-35.33&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;434.31&quot; y=&quot;-41.93&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Write OK (async)&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Asynchronous writes decouple application latency from database performance&lt;/li&gt;
&lt;li&gt;Risk of data loss if the cache fails before the DB write completes&lt;/li&gt;
&lt;li&gt;More complex to implement than write-through (needs durability guarantees)&lt;/li&gt;
&lt;li&gt;Ideal for write-heavy workloads that can tolerate temporary inconsistency&lt;/li&gt;
&lt;li&gt;Can batch and coalesce writes for better DB efficiency&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — app initiates vs cache initiates DB write&lt;/li&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../write-through-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-through-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Through Cache&lt;/a&gt; — async vs sync DB write&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../message-queues&quot; class=&quot;internal alias&quot; data-slug=&quot;message-queues&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Message Queues&lt;/a&gt; — similar async processing and buffering pattern&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../eventual-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;eventual-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Eventual Consistency&lt;/a&gt; — write-behind creates a window of temporary inconsistency&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Data loss on cache failure&lt;/strong&gt;: If the cache node crashes before flushing writes to the database, unpersisted data is lost. Requires replication or persistent caching layers to mitigate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inconsistency window&lt;/strong&gt;: Readers may see data in the cache that hasn’t yet been written to the database. Downstream systems querying the DB directly will not see the update.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write ordering&lt;/strong&gt;: If the cache reorders or coalesces writes, the database may receive updates in a different order than the application issued them.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>write-through-cache</title>
    <link href="https://animishraa05.github.io/wiki/system-design/write-through-cache" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/system-design/write-through-cache.md" />
    <summary>The Problem Cache-aside can return stale data when the database is updated directly, bypassing the cache.</summary>
    <published>2026-05-15T00:00:00.000Z</published>
    <updated>2026-05-15T00:00:00.000Z</updated>
    <publishedTime>May 15, 2026</publishedTime>
    <updatedTime>May 15, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="caching" label="caching" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Cache-aside can return stale data when the database is updated directly, bypassing the cache. Applications must manually invalidate or update cached entries after DB writes.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Write-through cache treats the cache as the authoritative data store for writes — every write goes to the cache first, then the cache synchronously writes to the database. This ensures the cache always has the latest data at the cost of slower write operations.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Application writes or updates an entry in the cache.&lt;/li&gt;
&lt;li&gt;The cache synchronously writes the data to the database.&lt;/li&gt;
&lt;li&gt;Only after both writes complete does the cache return success.&lt;/li&gt;
&lt;li&gt;Reads of recently written data are fast (served from cache).&lt;/li&gt;
&lt;li&gt;Cache always has the latest data — no staleness window.&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;This pattern is often combined with cache-aside for reads on new cache nodes that haven’t been populated yet.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: WriteThrough Pages: 1 --&gt;
&lt;svg width=&quot;545pt&quot; height=&quot;143pt&quot; viewBox=&quot;0.00 0.00 545.00 143.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 139.38)&quot;&gt;
&lt;title&gt;WriteThrough&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-139.38 540.68,-139.38 540.68,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M70.1,-83.54C70.1,-83.54 12,-83.54 12,-83.54 6,-83.54 0,-77.54 0,-71.54 0,-71.54 0,-59.54 0,-59.54 0,-53.54 6,-47.54 12,-47.54 12,-47.54 70.1,-47.54 70.1,-47.54 76.1,-47.54 82.1,-53.54 82.1,-59.54 82.1,-59.54 82.1,-71.54 82.1,-71.54 82.1,-77.54 76.1,-83.54 70.1,-83.54&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.05&quot; y=&quot;-61.34&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Application&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M302,-83.54C302,-83.54 272,-83.54 272,-83.54 266,-83.54 260,-77.54 260,-71.54 260,-71.54 260,-59.54 260,-59.54 260,-53.54 266,-47.54 272,-47.54 272,-47.54 302,-47.54 302,-47.54 308,-47.54 314,-53.54 314,-59.54 314,-59.54 314,-71.54 314,-71.54 314,-77.54 308,-83.54 302,-83.54&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;287&quot; y=&quot;-61.34&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Cache&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M63.67,-84.02C73.99,-91.65 86.94,-99.62 100.1,-103.54 160.54,-121.56 182.89,-125.53 242,-103.54 249.25,-100.84 256.1,-96.36 262.14,-91.4&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;264.18,-94.27 269.24,-84.96 259.48,-89.08 264.18,-94.27&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;171.05&quot; y=&quot;-122.78&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Write(key, data)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M82.33,-65.54C128.42,-65.54 203.31,-65.54 248.29,-65.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;248.08,-69.04 258.08,-65.54 248.08,-62.04 248.08,-69.04&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;171.05&quot; y=&quot;-69.74&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Read(key)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M259.57,-52.22C253.91,-49.95 247.86,-47.94 242,-46.74 180.22,-34.09 162.39,-36.9 100.1,-46.74 97.94,-47.08 95.75,-47.49 93.55,-47.95&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.91,-44.5 84.04,-50.29 94.58,-51.3 92.91,-44.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;171.05&quot; y=&quot;-50.94&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Success&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M274.98,-47.46C267.25,-36.62 255.84,-23.81 242,-17.74 184.25,7.6 159.46,3.56 100.1,-17.74 87.49,-22.26 75.66,-30.84 66.02,-39.49&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;63.71,-36.85 58.91,-46.3 68.55,-41.91 63.71,-36.85&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;171.05&quot; y=&quot;-21.94&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Fresh data (always hit)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M524.68,-83.54C524.68,-83.54 481.38,-83.54 481.38,-83.54 475.38,-83.54 469.38,-77.54 469.38,-71.54 469.38,-71.54 469.38,-59.54 469.38,-59.54 469.38,-53.54 475.38,-47.54 481.38,-47.54 481.38,-47.54 524.68,-47.54 524.68,-47.54 530.68,-47.54 536.68,-53.54 536.68,-59.54 536.68,-59.54 536.68,-71.54 536.68,-71.54 536.68,-77.54 530.68,-83.54 524.68,-83.54&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;503.03&quot; y=&quot;-61.34&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Database&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cache&amp;#45;&amp;gt;DB --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Cache-&gt;DB&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M314.25,-65.54C349.93,-65.54 414.27,-65.54 457.56,-65.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;457.38,-69.04 467.38,-65.54 457.38,-62.04 457.38,-69.04&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;391.69&quot; y=&quot;-69.74&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. Synchronous write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DB&amp;#45;&amp;gt;Cache --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DB-&gt;Cache&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M469.09,-49.88C463.31,-47.75 457.26,-45.9 451.38,-44.74 399.33,-34.47 383.77,-33.12 332,-44.74 329.69,-45.26 327.34,-45.92 325.02,-46.67&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;323.79,-43.39 315.73,-50.27 326.32,-49.92 323.79,-43.39&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;391.69&quot; y=&quot;-48.94&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Write OK&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Cache writes are synchronous — the database write completes before returning&lt;/li&gt;
&lt;li&gt;Data in the cache is never stale (for entries updated through the cache)&lt;/li&gt;
&lt;li&gt;Write operations are slower than cache-aside (two sequential writes)&lt;/li&gt;
&lt;li&gt;Reads of recently written data are fast (always a cache hit)&lt;/li&gt;
&lt;li&gt;Often combined with cache-aside for populating new cache nodes&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../cache-aside&quot; class=&quot;internal alias&quot; data-slug=&quot;cache-aside&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cache-Aside&lt;/a&gt; — app manages cache vs cache manages DB writes&lt;/li&gt;
&lt;li&gt;Contrasts with: &lt;a href=&quot;../../write-behind-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;write-behind-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Write-Behind Cache&lt;/a&gt; — sync vs async DB write&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../refresh-ahead-cache&quot; class=&quot;internal alias&quot; data-slug=&quot;refresh-ahead-cache&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Refresh-Ahead Cache&lt;/a&gt; — both keep cache fresh but with different triggers&lt;/li&gt;
&lt;li&gt;Related: &lt;a href=&quot;../../strong-consistency&quot; class=&quot;internal alias&quot; data-slug=&quot;strong-consistency&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Strong Consistency&lt;/a&gt; — write-through ensures cache is consistent with the database&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Write amplification&lt;/strong&gt;: Every write hits both cache and DB, doubling write operations compared to a direct DB write.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No stale-data protection for direct DB writes&lt;/strong&gt;: If another process writes directly to the database (bypassing the cache), the cache still becomes stale.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Higher write latency&lt;/strong&gt;: The client blocks until both cache and DB acknowledge, making writes slower than write-behind or cache-aside.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
</feed>