<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gunalan Deivaganapathy on Medium]]></title>
        <description><![CDATA[Stories by Gunalan Deivaganapathy on Medium]]></description>
        <link>https://medium.com/@gunalan.d.official?source=rss-b2a20622af08------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3Ih90NaXlK6_GwPnzFH01Q.jpeg</url>
            <title>Stories by Gunalan Deivaganapathy on Medium</title>
            <link>https://medium.com/@gunalan.d.official?source=rss-b2a20622af08------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:03:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gunalan.d.official/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[System Design 75: Day 15 Cassandra: The Master of High Availability]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-15-cassandra-the-master-of-high-availability-585a85617159?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/585a85617159</guid>
            <category><![CDATA[cassandra]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Fri, 16 May 2025 15:47:08 GMT</pubDate>
            <atom:updated>2025-05-16T15:47:08.981Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kjc_pvCbmhWKNuF8ur7N0A.png" /><figcaption>SYSTEM-DESIGN-75-DAY15</figcaption></figure><p>DAY 15 OF SYSTEM-DESIGN-75</p><h3>Recap: Day 14 — Deep Dive into Publisher-Subscriber (Pub/Sub) Model &amp; Asynchronous Communication</h3><p>In our previous discussion on <a href="https://medium.com/@gunalan.d.official/system-design-75-day-14-deep-dive-into-publisher-subscriber-pub-sub-model-asynchronous-5141ebcf6cb3"><strong><em>Pub Sub Model</em></strong></a>, we explored how Pub/Sub model helps decouple communication between services, making interaction seamless across distributed systems .</p><h3>Cassandra</h3><p>In a world where <strong>availability is non-negotiable</strong> and even minor downtime is unacceptable, Cassandra stands tall as a <strong>battle-tested, wide-column NoSQL database</strong> optimized for: <strong>High Availability ,Write Scalability</strong> and <strong>Fault Tolerance</strong></p><p>It was originally developed at Facebook and later open-sourced under Apache, Cassandra powers critical infrastructure at giants like <strong>Netflix, Discord, Uber, and Apple</strong>.</p><h3>Core Concepts</h3><h4>Wide Column Store</h4><p>Unlike traditional RDBMS:</p><ul><li>Cassandra stores data in <strong>tables</strong>, but each <strong>row can have a different number of columns</strong>.</li><li>These are also known as <strong>column families</strong>, optimized for fast writes and scalable reads.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vK32aiJtDr5q0gwT__Aaqw.png" /><figcaption>EXAMPLE 1</figcaption></figure><h3>How Column Names Are Stored in Cassandra</h3><ul><li><strong>Row-level column names:</strong> In Cassandra, column names are stored with each row, not at the table level</li><li><strong>No fixed schema:</strong> Different rows can have entirely different sets of columns</li><li><strong>Sparse data efficiency:</strong> Empty values don’t consume storage since columns only exist where defined</li><li><strong>Internal structure:</strong> Data is stored as key-value pairs within each row</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJzNK7ATq9VkDkc-qrX-OQ.png" /><figcaption>EXAMPLE 2</figcaption></figure><h3>Leaderless Architecture</h3><p>Forget master-slave. Cassandra is <strong>masterless</strong>.</p><ul><li><strong>Any node</strong> can accept reads and writes.</li><li><strong>Configurable consistency model</strong>, letting you choose availability vs consistency.</li><li>Ideal for globally distributed systems.</li></ul><h3>Internal Mechanics</h3><h4><strong>Partition Key</strong></h4><ul><li>Determines <strong>which node</strong> stores the data.</li><li>Enables horizontal partitioning using <strong>consistent hashing</strong>.</li></ul><h4><strong>Clustering Key</strong></h4><ul><li>Used to <strong>sort order within a partition</strong>.</li><li>Enables efficient <strong>range queries</strong> and pagination.</li></ul><p>Example Table:</p><pre>CREATE TABLE messages (<br>    user_id UUID,            -- Partition Key<br>    message_time TIMESTAMP,  -- Clustering Key<br>    message_id UUID,<br>    content TEXT,<br>    PRIMARY KEY (user_id, message_time)<br>);</pre><p>This schema ensures:</p><ul><li>All messages from a user are colocated.</li><li>Sorted by message_time for quick recent message lookup.</li></ul><h3>Storage Engine: LSM Tree + SSTables</h3><ul><li>Writes go to <strong>MemTable</strong> and Append only <strong>Commit Log</strong>.</li><li>Periodically flushed to <strong>immutable SSTables</strong>.</li><li>Uses <strong>Bloom Filters</strong> and indexes to locate data fast.</li></ul><blockquote><em>🔸 </em><strong><em>Trade-off</em></strong><em>: More writes → more SSTables → higher read latency.</em></blockquote><blockquote><strong>Note:</strong> Check Day 13 — I did a deep dive on LSM trees here: <a href="https://medium.com/@gunalan.d.official/system-design-75-day-13-write-fast-read-smart-the-lsm-tree-advantage-in-system-design-a96ff059ab6a"><strong>Write Fast, Read Smart: The LSM Tree Advantage in System Design</strong></a><strong>.</strong></blockquote><h4>Cassandra Write Path</h4><pre>Client → Coordinator Node → Replicas<br>       ↳ Write to MemTable + Commit Log<br>       ↳ Eventually flushed to SSTable in Background</pre><h4>Cassandra Read Path</h4><pre>Client → Coordinator Node → Replica(s)<br>       ↳ Bloom Filter → SSTable Lookup<br>       ↳ Read Repair if inconsistency found in any of replicas</pre><h3>Gossip Protocol</h3><p>Cassandra uses <strong>Gossip</strong> for peer-to-peer metadata exchange.</p><ul><li>Nodes exchange its state info every second.</li><li>Used for <strong>failure detection</strong>, <strong>token awareness</strong>, and <strong>ring topology</strong>.</li></ul><figure><img alt="credits : Baeldung" src="https://cdn-images-1.medium.com/max/581/0*NToWH97vQIhXcUxo.jpg" /><figcaption>EXAMPLE 3</figcaption></figure><h3>Consistent Hashing &amp; Replication</h3><ul><li>Cassandra uses consistent hashing to determine which key is stored in which replica node .</li><li>Token ring divided using <strong>virtual nodes</strong></li><li><strong>Replication Factor (RF)</strong> defines how many copies are stored.</li></ul><p><strong>Write Behavior:</strong></p><ul><li>Written to RF replicas.</li><li>Configurable Consistency level (QUORUM, ONE, etc.) decides success.</li></ul><p><strong>Conflict Resolution:</strong><br> → <strong>Last Write Wins</strong> (based on timestamp , so clocks should be in sync with each other )</p><h3>Repair &amp; Recovery Mechanisms:</h3><ul><li><strong>Read Repair</strong>: Fixes inconsistent reads on the fly if any one of the replica return stale entry.</li><li><strong>Anti-Entropy Repair</strong>: Periodic sync between replicas.</li><li><strong>Hinted Handoff</strong>: Coordinator node will temporarily stores missed writes if write replica is down.</li></ul><h3>Why Use Cassandra?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2ECnaczuQnamOc1U9jmIQ.png" /></figure><p>Cassandra isn’t just another NoSQL database — it’s a <strong>battle-tested, high-availability system</strong> used by the largest tech companies on the planet.</p><p>If your application:</p><ul><li>Is write-heavy,</li><li>Must be always ready to take writes/reads ,</li><li>Needs global distribution</li></ul><p><strong>Cassandra is your database of choice</strong></p><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #LSMTree #DatabaseInternals #NoSQL #Bigtable #RocksDB #DatabaseIndexing #WriteOptimization #ReadEfficiency #Caching #ScalableSystems #DistributedSystems #PerformanceEngineering #LatencyOptimization #CloudArchitecture #SoftwareArchitecture #PubSub #SystemDesign75 #TechLearning #BackendEngineering #Cassandra #Redis #DynamoDB #Redis</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=585a85617159" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 14— Deep Dive into Publisher-Subscriber (Pub/Sub) Model & Asynchronous…]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-14-deep-dive-into-publisher-subscriber-pub-sub-model-asynchronous-5141ebcf6cb3?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/5141ebcf6cb3</guid>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[publisher-subscriber]]></category>
            <category><![CDATA[asynchronous]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Sat, 26 Apr 2025 04:51:49 GMT</pubDate>
            <atom:updated>2025-04-26T04:51:49.688Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C-ax5lgBTg0ZYKJo" /><figcaption>DAY 14 OF SYSTEM DESIGN 75</figcaption></figure><h3>System Design 75: Day 14— Deep Dive into Publisher-Subscriber (Pub/Sub) Model &amp; Asynchronous Communication</h3><h3>How Do Software Systems Communicate?</h3><p>In distributed systems, services or components need to communicate efficiently.</p><p>There are two primary modes of communication:</p><ol><li><strong>Synchronous Communication</strong></li><li><strong>Asynchronous Communication</strong></li></ol><h3>What is Synchronous Communication?</h3><p>Synchronous communication occurs in real-time, where a service directly communicates with another service and expects an immediate response.</p><h4>Example:</h4><ul><li>Calling a friend and having a direct conversation over the phone .</li><li>A client requests a file from a server and waits for a response before proceeding.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*76r2qA5QYmEm62ZD4f7Urw.png" /><figcaption>EXAMPLE FIG.1</figcaption></figure><h3>What is Asynchronous Communication?</h3><p>Asynchronous communication is not real-time. It decouples components, meaning they do not interact directly, and messages ( data ) are sent without requiring an immediate response .</p><h4>Example:</h4><ul><li>Sending a voice/text message instead of having a live conversation.</li><li>A user places an order on an e-commerce platform, and the system processes it in the background.</li></ul><h3>Publisher-Subscriber (Pub/Sub) Model</h3><p>The Pub/Sub model is an asynchronous messaging pattern widely used in distributed systems. It enables decoupled communication between services, making interactions more seamless and efficient .</p><h3>How It Works</h3><p>Key components of the Pub/Sub model:</p><ul><li><strong>Publisher</strong>: Sends messages (data) to a communication channel.</li><li><strong>Channel (Message Broker)</strong>: Temporarily holds and routes messages.</li><li><strong>Subscriber</strong>: Listens to and processes messages from the channel.</li></ul><h3>Real-World Analogies</h3><h4>1. YouTube Example</h4><ul><li>A YouTuber (Publisher) uploads a new video.</li><li>The video is stored on YouTube (Channel).</li><li>Subscribers receive a notification when the video is available.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*Ki-W04n2Pn6yVnw49amBfw.png" /></figure><h4>2. Device Commands in a Distributed System</h4><ul><li>A master service (Publisher) sends commands to multiple follower services.</li><li>The followers subscribe to a specific channel and wait for relevant commands.</li><li>When the master sends a message to the channel, all subscribers receive and process it as needed.</li></ul><h3>Pub/Sub Workflow</h3><ol><li><strong>Input Channel</strong>: The publisher sends messages to an input channel.</li><li><strong>Processing Services</strong>: Intermediate services process the input messages and send the results to an output channel.</li><li><strong>Output Channel</strong>: Subscribers listen to this channel and react when new messages arrive.</li></ol><h4>Example: Order Management System</h4><ul><li>When an order is marked “Out for Delivery” notifications (SMS, Email, App Push) need to be sent.</li><li>Instead of each notification service being directly linked, they subscribe to an “Order Status” channel and react when relevant messages are published.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g32w_RkaMUq06RERUQf4iA.png" /><figcaption>OUT FOR DELIVERY EXAMPLE</figcaption></figure><h3>When to Use Pub/Sub</h3><ul><li>When multiple services need to receive updates from a central source.</li><li>When applications can send information to consumers without requiring real-time responses from the consumers.</li><li>When scalability is a priority (decoupling services allows independent scaling).</li></ul><h3>Challenges and Trade-offs</h3><h3>Pros:</h3><ul><li><strong>Scalability</strong>: Multiple subscribers can process events in parallel.</li><li><strong>Decoupling</strong>: Publishers and subscribers are independent.</li></ul><h3>Cons:</h3><ul><li><strong>Message Ordering</strong>: Guarantees may vary depending on the implementation.</li><li><strong>Message Delivery</strong>: Some messages may be lost if not handled properly.</li><li><strong>Latency</strong>: Event propagation is not always immediate.</li></ul><h3>Use Cases</h3><ul><li><strong>Logging </strong>: Sending logs from multiple services to a central monitoring system.</li><li><strong>Notifications </strong>: Sending notifications to users based on system events.</li><li><strong>Microservices Communication</strong>: Enabling services to communicate asynchronously without tight coupling.</li></ul><p>The <strong>Publisher-Subscriber model</strong> is a core building block for <strong>scalable</strong>, <strong>decoupled</strong>, and <strong>asynchronous</strong> system design. Whether it’s a social app, an order processing system, or an IoT platform — Pub/Sub helps break tight coupling and unlock parallel processing.</p><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign #PubSub #NoSQL #RocksDB #Bigtable #DatabaseIndexing</strong> <strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitecture</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5141ebcf6cb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 13— Write Fast, Read Smart: The LSM Tree Advantage in System Design]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-13-write-fast-read-smart-the-lsm-tree-advantage-in-system-design-a96ff059ab6a?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/a96ff059ab6a</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[nosql]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Thu, 27 Feb 2025 16:42:35 GMT</pubDate>
            <atom:updated>2025-02-27T16:42:35.245Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1UBYu2f-0wd8yQua" /><figcaption>SYSTEM-DESIGN-75-DAY-13</figcaption></figure><p>DAY 13 OF SYSTEM-DESIGN-75</p><h3>Recap: Day 12 — Deep Dive into B/B+ Trees ( M way Search Tree )</h3><p>In our previous discussion on <a href="https://medium.com/@gunalan.d.official/system-design-75-day-12-deep-dive-into-b-b-trees-m-way-search-tree-f99ec529bc4d"><strong><em>B-Trees and B+ Trees</em></strong></a>, we explored how these <strong>disk-based indexing structures</strong> are optimized for minimizing random I/O during reads. However, these structures have a drawback: Frequent writes involve modifying multiple nodes (causing expensive disk I/O).</p><p>To <strong>overcome this write inefficiency,</strong> many modern databases like Scylladb,Apache Cassandra use <strong>Log-Structured Merge Trees (LSM Trees)</strong> instead.</p><h3>Understanding the Basics: Commit Log &amp; SSTables</h3><h3>1. Commit Log (Write-Ahead Log — WAL)</h3><p>A <strong>commit log</strong> (also called a <strong>write-ahead log</strong>) is an <strong>append-only file</strong> that records <strong>all write operations</strong> before applying them to the database.</p><p><strong>Example</strong>:<br>Imagine a Trading system where a user buys <strong>₹1000 worth of stock A</strong>. Before updating the database:</p><ul><li>The operation <strong>“User XXX boought ₹1000 : StockA”</strong> is <strong>written to the commit log</strong>.</li><li>If a crash occurs before the actual update, the system can <strong>replay the commit log</strong> to recover.</li></ul><p>🔹 <strong>Why commit logs?</strong><br>✅ Ensures <strong>durability</strong> (no data loss in case of failure) and auditing .<br>✅ Supports <strong>replay-based recovery</strong>.<br>✅ Write-heavy workloads become <strong>sequential (faster than random writes)</strong>.</p><h3>2. SSTables (Sorted String Table) — Immutable On-Disk Storage</h3><p>An <strong>SSTable</strong> is a <strong>read-optimized, immutable file</strong> where key-value pairs are stored <strong>in sorted order</strong> on disk.</p><p>🔹 <strong>Key Properties:</strong></p><ul><li>✅ <strong>Keys are always sorted</strong> (facilitating efficient range queries).</li><li>✅ <strong>Immutable</strong> (reduces fragmentation, avoids random writes).</li><li>✅ <strong>Indexes &amp; Bloom Filters</strong> (used to speed up lookups).</li></ul><p>🔹 <strong>Example of an SSTable (key-value pairs stored in sorted order):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMHPFVsbRzpxne3xTovSWw.png" /><figcaption>SSTABLE EXAMPLE</figcaption></figure><h3>Why are SSTables Immutable?</h3><p>Since SSTables <strong>never modify existing data</strong>, updates are written as <strong>new SSTables</strong> and old ones are periodically <strong>compacted (merged)</strong>.</p><p>❌ Requires <strong>compaction</strong> to remove stale data.<br>✅ <strong>Write operations are always sequential</strong>, which is <strong>fast</strong> on disk.</p><h3>MemTable: The In-Memory Write Buffer</h3><p>A <strong>MemTable</strong> is an <strong>in-memory data structure</strong> that holds recent writes before those are flushed to SSTables.</p><p>🔹 <strong>Key Properties:</strong></p><ul><li><strong>Stores recent key-value writes</strong> in memory.</li><li><strong>Uses Red-Black Tree (or Skip List) for sorting keys</strong>.</li><li><strong>Once Size is full, it is flushed to an SSTable</strong>.</li></ul><p>🔹 <strong>Example:</strong><br>Imagine <strong>a database receiving 100 writes per second</strong>. Instead of <strong>writing each write to disk</strong>, we:</p><ol><li><strong>Store them in MemTable</strong> (sorted).</li><li><strong>Once full (~64MB), we flush it as a new SSTable</strong>.</li></ol><p>✅ <strong>Advantage:</strong></p><ul><li>Keeps writes <strong>fast</strong> (since in-memory writes are fast).</li><li>Data remains <strong>sorted</strong> before flushing.</li><li>Data recovery</li></ul><p>❌ <strong>Downside:</strong></p><ul><li>If the system crashes before flushing, recent writes may be <strong>lost </strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*UJJO16lfN2Q-gftQsEMBWw.png" /></figure><h3>Log-Structured Merge Trees (LSM Trees) :</h3><p>An <strong>LSM Tree</strong> is a <strong>write-optimized data structure</strong> used in databases like <strong>Scylladb </strong>, <strong>Apache Cassandra</strong>, etc. It consists of:</p><ol><li><strong>In-memory MemTables</strong> (fast writes).</li><li><strong>On-disk SSTables</strong> (persistent storage).</li><li><strong>Compaction process</strong> (merging and organizing SSTables).</li></ol><h3>LSM Tree Workflow: How Data Flows</h3><ol><li><strong>Write request arrives</strong> → Stored in <strong>MemTable</strong> (sorted in memory).</li><li><strong>Commit Log (WAL) records the write</strong> → Ensures durability.</li><li><strong>MemTable fills up (~64MB)</strong> → Flushed as <strong>Level-0 SSTable</strong> (on disk).</li><li><strong>Multiple SSTables accumulate</strong> → Periodically <strong>merged</strong> into larger SSTables (Compaction).</li><li><strong>Older SSTables are discarded</strong> after merging.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jer2JA4MwgCrJhk4M_jsGA.png" /><figcaption>LSM WORKFLOW</figcaption></figure><h3>Read Operations in LSM Trees</h3><p>🔎 <strong>How does a read work?</strong></p><ol><li><strong>Check MemTable</strong> (since recent writes are there).</li><li><strong>If not found, check Level-0 SSTables</strong> (newest SSTables on disk).</li><li><strong>If still not found, search deeper levels</strong> (merged SSTables).</li><li><strong>Use Bloom Filters</strong> to quickly determine if a key is present in an SSTable.</li></ol><p>🔹 <strong>Optimized Lookups:</strong><br>✅ <strong>MemTable first</strong> (fastest, in-memory).<br>✅ <strong>Recent SSTables first</strong> (newer data is usually read more often).<br>✅ <strong>Bloom Filters avoid unnecessary disk reads</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*d9gc0MIBp5qI1BLmTYa_5g.png" /></figure><h3>Compaction — The Heart of LSM Trees</h3><p>Since <strong>LSM Trees continuously generate new SSTables</strong>, older data must be <strong>merged &amp; deleted</strong> periodically.</p><p>🔹 <strong>Compaction Process:</strong></p><ol><li><strong>Merge overlapping SSTables</strong> (e.g., Level-0 → Level-1-&gt;Level-2).</li><li><strong>Discard duplicate or deleted records</strong>.</li><li><strong>Rebuild indexes and Bloom Filters</strong>.</li></ol><p>✅ <strong>Advantages of Compaction:</strong></p><ul><li><strong>Reduces disk space usage</strong>.</li><li><strong>Optimizes read performance</strong>.</li><li><strong>Keeps query latency low</strong>.</li></ul><h3>Comparing LSM Trees vs. B-Trees</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*5FoJbFTgrIaSGubjDZ339Q.png" /></figure><h3>Links to Refer :</h3><p><a href="https://www.cs.umb.edu/~poneil/lsmtree.pdf">https://www.cs.umb.edu/~poneil/lsmtree.pdf</a></p><ul><li><a href="https://www.scylladb.com/glossary/sstable/">What is a SSTable? Definition &amp; FAQs | ScyllaDB</a></li><li><a href="https://www.scylladb.com/glossary/log-structured-merge-tree/">What is a Log Structured Merge Tree? Definition &amp; FAQs | ScyllaDB</a></li></ul><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign #LSMTrees #NoSQL #RocksDB #Bigtable #DatabaseIndexing</strong> <strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitecture</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a96ff059ab6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 12 — Deep Dive into B/B+ Trees ( M way Search Tree )]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-12-deep-dive-into-b-b-trees-m-way-search-tree-f99ec529bc4d?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/f99ec529bc4d</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Sat, 22 Feb 2025 16:53:40 GMT</pubDate>
            <atom:updated>2025-02-22T16:53:40.330Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9oRUiJpiaGI6NCAt" /></figure><h3>System Design 75: Day 12 — <strong>Deep Dive into B/B+ Trees ( M way Search Tree )</strong></h3><p>SYSTEM DESIGN 75 — DAY 12</p><figure><img alt="I WANTED GOJOOO" src="https://cdn-images-1.medium.com/max/1024/0*0qoDkAcBoM3Hp4V6" /></figure><h3>Recap: Day 11 — Database Indexing &amp; Query Optimization</h3><p>In our previous discussion on <a href="https://medium.com/@gunalan.d.official/system-design-75-day-11-deep-dive-into-database-indexing-query-optimization-1eb77ea52096">Indexing &amp; Query Optimization</a>, we explored how databases uses indexing for optimizing performance and its different types and also we talked about different strategies for optimizing database queries .</p><h3>Disk Structure</h3><figure><img alt="https://www.cs.jhu.edu/~yairamir/cs418/os8/sld019.htm" src="https://cdn-images-1.medium.com/max/600/0*5zL5sIKHlVtqiFcc.gif" /></figure><ul><li>Typically, block size is <strong>512 bytes</strong>, but this can vary.</li><li>A block can hold <strong>multiple records</strong> (determined by offset sizes).</li><li>Main memory <strong>fetches data from the disk in blocks</strong>, not individual bytes.</li></ul><h3>Indexing in Depth</h3><p>Consider a <strong>Profile</strong> table with the following schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*tZj9kU-JV7Rn3BoSbJ-nzg.png" /><figcaption>Profiles Table</figcaption></figure><p>Each row takes <strong>160 bytes</strong>.</p><ul><li><strong>Number of records per block</strong> = 512 / 160 = 3</li><li>To store <strong>200 records</strong>, we need <strong>67 blocks</strong>.</li></ul><p>Now, if we <strong>search</strong> for a record (name == &quot;Gojo&quot;), we must scan <strong>67 blocks</strong> → <strong>O(N) time complexity</strong>.</p><h3>Using an Index</h3><p>To optimize, we create an <strong>index</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*oIJro-vIn6v64f38d2f_KQ.png" /><figcaption>Index Table</figcaption></figure><p><strong>Number of records per index block</strong> = 512 / 16 = 32</p><ul><li>To store <strong>200 records</strong>, we need only <strong>6 blocks</strong>.</li><li>Instead of scanning <strong>67 blocks</strong>, we now scan <strong>only 6+1 blocks</strong>.</li></ul><p>To further optimize, we can use <strong>multi-level indexing</strong> (index on top of an index).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*Rw_E1itvKoKtaY1adWTfsw.png" /></figure><h3>M-Way Search Tree</h3><p>Multi-level indexing helps, but updating indexes manually is inefficient.<br>This is where <strong>M-Way Search Trees</strong> come in:</p><ul><li><strong>Recall Binary Search Tree (BST):</strong> Left for smaller values, right for larger values.</li><li><strong>M-Way Search Tree:</strong> Instead of <strong>2 children</strong>, each node can have <strong>M children and M-1 Keys </strong>.</li><li><strong>If M = 3</strong>, the node structure:</li></ul><pre>[ Child | Key1 | Record Pointer | Child | Key2 | Record Pointer | Child ]</pre><h3>Problem with M-Way Search Trees?</h3><ul><li>Can become <strong>skewed</strong> due to insertions.</li><li>Tree <strong>height may grow</strong>, making it inefficient.</li></ul><h3>B-Trees: Self-Balancing M-Way Search Trees</h3><p>A <strong>B-Tree</strong> solves the skew problem with <strong>self-balancing rules</strong>:</p><ol><li>Each node has at least <strong>M/2 children</strong>.</li><li>The <strong>root must have at least 2 children</strong>.</li><li><strong>All leaf nodes must be at the same level</strong>.</li></ol><h3>Example: B-Tree of Degree 3 (M = 3)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*AIFPAFzdD72DD0AwF8GF7w.png" /><figcaption>B-TREE EXAMPLE</figcaption></figure><h3>Why are B-Trees Useful in Databases?</h3><ul><li>Each node has a <strong>pointer to child nodes</strong> and a <strong>record pointer</strong>.</li><li>Balanced structure ensures <strong>efficient searches, insertions, and deletions</strong>.</li></ul><h3>B+ Trees: Optimized for Databases</h3><p>B+ Trees refine B-Trees further:</p><ol><li><strong>Internal nodes</strong> store <strong>only keys, no record pointers</strong>.</li><li><strong>Leaf nodes</strong> contain <strong>all record pointers</strong>.</li><li><strong>Leaf nodes are linked like a Linked List</strong> → <strong>Faster range queries!</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AOtx8w2jF-sidW5TuH87w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70ONdMH98P-D3x-CQytd0A.png" /></figure><h3>Why B+ Trees?</h3><ul><li><strong>Efficient range queries</strong> (thanks to linked leaf nodes).</li><li><strong>Better disk utilization</strong> (fewer block reads).</li><li><strong>Used in most databases (MySQL, PostgreSQL, etc.)</strong> for indexing.</li></ul><h3>Conclusion</h3><ul><li><strong>M-Way Trees</strong> → Generalizing BST for better search.</li><li><strong>B-Trees</strong> → Balanced indexing, efficient updates.</li><li><strong>B+ Trees</strong> → Optimized indexing with linked leaf nodes for fast range queries.</li></ul><p>Understanding <strong>B+ Trees</strong> is crucial for system design interviews, especially for database optimizations!</p><h3>Next: Day 13</h3><p>Tomorrow, we’ll explore <strong>LSM Trees &amp; Write-Optimized Indexing</strong>. Stay tuned!</p><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitec</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g_BeHDAeNn1JTsGy" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f99ec529bc4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 11 — Deep Dive into Database Indexing & Query Optimization]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-11-deep-dive-into-database-indexing-query-optimization-1eb77ea52096?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eb77ea52096</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[database-design]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[sharding]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 15:44:18 GMT</pubDate>
            <atom:updated>2025-02-19T15:44:18.027Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T_Pf2iNm76NiOjO_" /><figcaption>DAY 11 OF SYSTEM DESIGN 75</figcaption></figure><h3>System Design 75: Day 11 — Deep Dive into Database Indexing &amp; Query Optimization</h3><p>SYSTEM DESIGN 75 — DAY 11</p><h3>Recap: Day 10 — Database Sharding &amp; Partitioning</h3><p>In our previous discussion on <a href="https://medium.com/@gunalan.d.official/system-design-75-day-10-deep-dive-into-database-sharding-partitioning-93decaef6c25">Database Sharding &amp; Partitioning</a>, we explored how databases distribute data across multiple nodes to improve scalability and performance. However, For efficient data retrieval in these distributed systems requires <strong>indexing and query optimization</strong>, which we will deep dive into today.</p><h3>Introduction: Why Does Query Speed Matter?</h3><p>In <strong>modern distributed systems</strong>, data is <strong>sharded</strong> across multiple databases, making it impossible to rely on a single machine for storage and retrieval. <strong>Fetching data efficiently</strong> is critical because:</p><ul><li><strong>Latency kills user experience</strong> → Imagine Google taking <strong>10 seconds</strong> to return a search result!</li><li><strong>High-volume systems</strong> (e.g., social media, banking) process <strong>millions of queries per second</strong>, making query optimization <strong>mandatory</strong> for scalability.</li></ul><p>This is where <strong>indexing and query optimization</strong> come into play.</p><h3>What is Indexing?</h3><p>Indexing is like creating a <strong>table of contents</strong> for your database records . Instead of scanning the <strong>entire database records</strong>, the database uses an <strong>index</strong> to jump directly to the relevant rows.</p><p>💡 <strong>Real Life</strong> <strong>Analogy:</strong> Think of a <strong>textbook</strong> — if you want to find a chapter, would you read every page? No, you’d use the <strong>index</strong> at the beginning.</p><blockquote>Note : having indexes can optimize read queries but also increases latency for write query since the database needs to update the index while writing .</blockquote><h3>How Indexing Works (With and Without Indexes)</h3><p>Consider a table users with <strong>millions</strong> of rows:</p><h4>Without Index (Full Table Scan 🚨 — Slow)</h4><pre>SELECT * FROM users WHERE username = &#39;gunalan&#39;;</pre><ul><li>The database <strong>checks every row</strong> to find &#39;gunalan&#39;.</li><li><strong>O(n) complexity</strong> → Slow for large datasets</li></ul><h4><strong>With an Index (B-tree as example )</strong></h4><pre>CREATE INDEX idx_username ON users(username);<br>SELECT * FROM users WHERE username = &#39;gunalan&#39;;</pre><ul><li>The <strong>index is like a sorted lookup table</strong>, allowing the query to <strong>jump directly</strong> to the correct row.</li><li><strong>O(log n) complexity</strong> → MUCH faster!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*N2reqXtICbG0YOFcTCKXrw.png" /><figcaption>example : without index search query</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*RihvQCFpifP0dMmLD-TGlw.png" /><figcaption>example: with index search query</figcaption></figure><h3>Types of Indexes (Most Common in SQL Databases)</h3><p>Different indexing strategies are used depending on the workload, query pattern, and storage constraints.</p><h4>Primary Index (Clustered Index)</h4><ul><li>Data is <strong>physically ordered</strong> based on the indexed column.</li><li>Only one clustered indexes can exist per table.</li><li><strong>Efficient for range queries</strong> but slow for updates.</li></ul><h4>Secondary Index (Non Clustered Index)</h4><ul><li>Stores pointers to data instead of physically ordering it.</li><li>Multiple non-clustered indexes can exist per table.</li></ul><h4>Hash Index</h4><ul><li>Uses a <strong>hash function</strong> to map keys to values.</li><li>O(1) lookup time but inefficient for <strong>range queries</strong>.</li></ul><h3>Disk-Based Indexing</h3><p>When indexes <strong>cannot fit in memory</strong>, databases use <strong>disk-based indexes</strong> to store and retrieve indexed data efficiently.</p><h4>B+ Tree Indexing</h4><ul><li>Stores <strong>data in sorted order</strong> and supports fast range queries.</li><li>Used in <strong>MySQL, PostgreSQL, MongoDB</strong>.</li><li>Leaf nodes are <strong>linked</strong> for sequential access.</li></ul><h4>Log-Structured Merge Trees (LSM-Trees)</h4><ul><li>Used in <strong>high-write workloads</strong> (e.g., Cassandra ).</li><li>Writes first go to memory (Memtable) and are <strong>flushed</strong> to disk in sorted segments.</li></ul><h3>Query Optimization Techniques</h3><p>Indexing is just one part of query optimization. Additional techniques include:</p><ul><li>Avoiding <strong>SELECT * </strong>for every query — Fetch only necessary columns.</li><li><strong>Denormalization</strong> — Store redundant data to reduce joins or querying multiple tables .</li><li><strong>Partitioning</strong> — Split large tables to improve query speed.</li><li><strong>Sharding </strong>— Distribute indexed data across multiple databases.</li></ul><p>We have introduced indexing concepts and query optimization strategies. In the upcoming days, we will take a <strong>deeper dive</strong> into <strong>SSTable &amp; B-Tree Indexing</strong> (Deep Dive) , <strong>LSM-Trees &amp; Write-Optimized Indexing</strong> and <strong>Indexing Strategies in Distributed Databases</strong></p><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitec</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*TrEvX4UZv8Ti8OPO.png" /><figcaption>GOJO CODING</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eb77ea52096" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 10— Deep Dive into Database Sharding & Partitioning]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-10-deep-dive-into-database-sharding-partitioning-93decaef6c25?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/93decaef6c25</guid>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[sharding]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Fri, 14 Feb 2025 02:27:20 GMT</pubDate>
            <atom:updated>2025-02-14T02:27:20.874Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1PjkHOx4diQxjvvN" /><figcaption>DAY 10 OF SYSTEMDESIGN75</figcaption></figure><p>SYSTEM DESIGN 75 — DAY 10</p><h3>Revisiting Day 9 Concepts :</h3><p>Before diving into today’s topic, let’s quickly recap what we covered in <strong>Day 9</strong>:</p><p>✅ <strong>ACID Properties</strong><br>✅ <strong>Choosing Between NoSQL vs SQL</strong><br>✅ <strong>Scaling SQL &amp; NoSQL Databases</strong></p><p>If you missed Day 9, <a href="https://medium.com/@gunalan.d.official/system-design-75-day-9-when-to-sql-and-no-sql-part-2-d8ffa657f9ac"><strong>check out here</strong></a><strong> .</strong></p><h3>What is Database Sharding ?</h3><p>Sharding is a <strong>scaling technique</strong> used in modern software architecture. It involves splitting a <strong>large database</strong> into smaller, more manageable pieces called <strong>shards</strong>, which are stored across multiple instances or nodes.</p><h3>Why Sharding was necessary ?</h3><ul><li>Traditional databases could handle limited amounts of data, but with the <strong>rise of Big Data &amp; cloud applications</strong>, storing billions of records on a single database instance became impractical.</li><li>Instead of <strong>vertically scaling</strong> (adding more CPU/RAM to a single machine ), we <strong>horizontally scale</strong> by splitting data across multiple instances / commodity machines</li></ul><p>Example : Facebook has <strong>3 billion users</strong>. If all user data were stored in a <strong>single database</strong>, it would be impossible to scale efficiently. By <strong>sharding</strong>, Facebook splits user data across multiple smaller databases.</p><h3><strong>Sharding Keys</strong></h3><p>So we talked about <strong>sharding , </strong>Sharding alone isn’t enough. To <strong>efficiently retrieve data</strong>, we need a <strong>sharding key</strong> — a specific field that determines how data is distributed across shards for accessing it ( ie.. for an application server to know where exactly a specific data is stored in which shard )</p><h4>How the Application Server Finds the Right Shard?</h4><p>When a request comes in, the application <strong>hashes the sharding key</strong> and determines <strong>which shard contains the data</strong>.</p><p>✅ <strong>Example:</strong> Suppose we are designing a IRCTC.</p><ul><li><strong>Good Sharding Key:</strong> Train_ID → Ensures <strong>all ticket bookings for a train stay in the same shard</strong>.</li><li><strong>Bad Sharding Key:</strong> Booking_ID → Data will be randomly distributed, making queries inefficient.</li></ul><h4>Example Code from Services to Shard Nodes :</h4><pre>import hashlib<br><br>DB_SHARDS = {<br>    0: &quot;gojo_db_shard_0&quot;,<br>    1: &quot;gojo_db_shard_1&quot;,<br>    2: &quot;gojo_db_shard_2&quot;,<br>    3: &quot;gojo_db_shard_3&quot;<br>}<br><br>def get_shard_for_user(user_id):<br>    shard_index = int(hashlib.md5(str(user_id).encode()).hexdigest(), 16) % len(DB_SHARDS)<br>    return DB_SHARDS[shard_index]<br><br>user_id = 123<br>shard = get_shard_for_user(user_id)<br>print(f&quot;User {user_id} data is stored in: {shard}&quot;)<br><br>user_id = 897<br>shard = get_shard_for_user(user_id)<br>print(f&quot;User {user_id} data is stored in: {shard}&quot;)<br><br>#OUTPUT:<br>#User 123 data is stored in: gojo_db_shard_0<br>#User 897 data is stored in: gojo_db_shard_3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*UM6CcKsgpYXI_lrMSKX2aA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*eOSDzvUx9jXZlkvGAnbnjg.png" /></figure><h3>Choosing right sharding key:</h3><p>A good sharding key should <strong>evenly distribute</strong> data across shards to avoid <strong>hotspots</strong> (some shards overloading). Queries should be <strong>optimized for intra-shard access</strong>, minimizing <strong>cross-shard queries</strong> (which can slow down performance)</p><h3><strong>How Sharding helps in modern systems :</strong></h3><ul><li><strong>Improve performance</strong> : by reducing query response time.</li><li><strong>Store More Data : </strong>enable horizontal scaling (adding more nodes instead of upgrading a single machine).</li><li><strong>Prevent bottlenecks</strong> caused by massive datasets.</li></ul><h3>Real-World Examples</h3><ul><li>Twitter: Shards user tweets by User_ID.</li><li>Youtube: Shards videos based on Video_ID.</li></ul><h3>What is Database Partitioning?</h3><p>Partitioning is <strong>similar to sharding</strong>, but with one key difference:</p><ul><li><strong>Sharding</strong> distributes data <strong>across multiple databases (or servers)</strong>.</li><li><strong>Partitioning</strong> divides data <strong>within a single database</strong>.</li></ul><h3>Types of Partitioning</h3><ul><li><strong>Horizontal Partitioning:</strong> Rows are split across partitions. (Example: Users with User_ID &lt; 10M in one partition, User_ID &gt; 10M in another.)</li><li><strong>Vertical Partitioning:</strong> Columns are split into different tables for better performance.</li></ul><p>Sharding is necessary for scaling massive datasets but comes with complexity (<em>resharding, inter-shard queries</em>). Choosing the right sharding key is critical to avoid hotspots and inefficient queries.</p><p><strong><em>Links to refer :</em></strong></p><p><a href="https://www.researchgate.net/publication/276122639_Database_Sharding_To_Provide_Fault_Tolerance_and_Scalability_of_Big_Data_on_the_Cloud">https://www.researchgate.net/publication/276122639_Database_Sharding_To_Provide_Fault_Tolerance_and_Scalability_of_Big_Data_on_the_Cloud</a></p><p><a href="https://aws.amazon.com/what-is/database-sharding/">https://aws.amazon.com/what-is/database-sharding/</a></p><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitec</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*EP9JUnrv27pdkNNEnpdrGg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93decaef6c25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 9— When to SQL and No SQL (Part 2)]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-9-when-to-sql-and-no-sql-part-2-d8ffa657f9ac?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8ffa657f9ac</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 15:19:30 GMT</pubDate>
            <atom:updated>2025-02-10T15:46:38.992Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q95UXkOP9D5uWv1r" /></figure><h3>System Design 75: Day 9— When to Choose SQL and No SQL (Part 2)</h3><p>SYSTEM DESIGN 75 — DAY 9</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*gnwtp_8C50Ot7Kva36Bn1w.png" /></figure><h3>Revisiting Day 8Concepts :</h3><p>Before diving into today’s topic, let’s quickly recap what we covered in <strong>Day 8</strong>:</p><ul><li><strong>What is a Database ? </strong>.</li><li>What is a SQL Database and its types .</li><li>What is a No SQL Database and its types .</li></ul><p>If you missed Day 8, <a href="https://medium.com/@gunalan.d.official/system-design-75-day-8-sql-vs-nosql-part-1-8f378eb739c0"><strong>check out here</strong></a><strong> .</strong></p><h3>ACID Properties :</h3><p>Before we talk about when to choose which database, let’s understand one of the important properties in DBMS, which is <strong>ACID</strong>. Each property ensures database reliability:</p><blockquote>A <strong>transaction </strong>can be defined as a group of tasks. A single task is the minimum processing unit which cannot be divided further.</blockquote><h4><strong>(A)tomicity ( All or Nothing ):</strong></h4><p>A transaction must be treated as a single unit. Either all operations are executed or none.</p><p>Example: Bank money transfer.</p><h4><strong>(C)onsistency :</strong></h4><p>The database must remain in consistent state even after a transaction , meaning no transaction should leave the database in inconsistent state . If the database was in a <strong><em>consistent state before the execution </em></strong>of a transaction, it must remain <strong><em>consistent after the execution</em></strong> of the transaction as well.</p><p>Example : Bank account balance becomes negative due to transaction ( inconsistent state )</p><h4><strong>(I)solation </strong>:</h4><p>This property states that , In a database where there are one or more transaction executed simultaneously and in parallel , The property of isolation states that all the transactions will be carried out and executed as if it is the <strong><em>only transaction in the system</em></strong> ( independent transaction ). , The property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system.</p><p>Example : Two withdrawals from the same account should not cause incorrect balances</p><h4>(D)urability:</h4><p>The database should be durable enough to hold its latest updates , Once a transaction is completed all the transaction changes should be present in database (ie. no data loss should happen ) .</p><h3>Inter/Intra Shard Queries:</h3><ul><li>Intra Shard : A query that operates <strong>within a single shard</strong>.</li><li>Inter Shard : A query that operates <strong>across multiple shards</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*DY3rckX7kz_-tHj6H6PqSg.png" /></figure><h3><strong>Choosing between SQL and NoSQL</strong></h3><p>Choosing between SQL and NoSQL databases depends on various trade-offs such as data structure, scalability requirements, transaction needs, and specific application use cases.</p><h4>When to Choose SQL :</h4><ul><li><strong>Structured Schema</strong> : your system schema is structured and has relationship between data entities.</li><li><strong>ACID Compliance</strong> : When you need strong transactional integrity and compliance with ACID properties.</li><li><strong>Complex Queries:</strong> When you need JOINs and aggregations across multiple tables.</li><li><strong>Vertical Scaling:</strong> SQL databases traditionally scale by adding more resources to a single machine.</li><li><strong>Sharding Challenges:</strong> Inter-shard queries in SQL are complex and slow since JOINs across shards require additional processing.</li></ul><p><strong>Real-Life Examples:</strong></p><ul><li>Banking transactions</li><li>E-commerce order management</li></ul><h4>When to Choose NoSQL :</h4><ul><li><strong>Unstructured or Semi-structured Data:</strong> When data doesn’t fit into rows and columns.</li><li><strong>Horizontal Scaling:</strong> NoSQL is designed to distribute data across multiple nodes to handle large datasets and high traffic.</li><li><strong>Flexible Data Models:</strong> When the schema needs to evolve dynamically.</li><li><strong>Optimized for Intra-shard Queries:</strong> NoSQL databases minimize cross-shard (inter-shard) queries through denormalization.</li></ul><p><strong>Real-Life Examples:</strong></p><ul><li>Logs and analytics</li><li>E-commerce product details</li><li>Social media platforms</li></ul><h3>Scaling SQL vs NoSQL:</h3><ul><li><strong>SQL Scaling:</strong> Typically <strong>vertical scaling</strong> (adding CPU, RAM, etc.), but some support <strong>sharding</strong>. However, cross-shard queries (inter-shard) are complex and slow. So this is why its important to design proper schema and choosing the right sharding key is important for good performance .</li><li><strong>NoSQL Scaling:</strong> Designed for <strong>horizontal scaling</strong> (adding more machines). Queries are optimized for intra-shard access, reducing inter-shard overhead.</li></ul><p>Choosing between SQL and NoSQL depends on your specific system requirements. SQL excels in structured data and complex transactions, while NoSQL shines in scalability and flexible schemas. The best approach often involves strategically combining both database types.</p><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitec</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8ffa657f9ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 8 — SQL vs NoSQL (Part 1)]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-8-sql-vs-nosql-part-1-8f378eb739c0?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f378eb739c0</guid>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Wed, 05 Feb 2025 03:20:37 GMT</pubDate>
            <atom:updated>2025-02-05T05:17:23.982Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*trlDXfwhvMsXBuDd" /></figure><h3>System Design 75: Day 8 — SQL vs NoSQL (Part 1)</h3><p>SYSTEM DESIGN 75 — DAY 8</p><h3>Revisiting Day 7 Concepts :</h3><p>Before diving into today’s topic, let’s quickly recap what we covered in <strong>Day 7</strong>:</p><ul><li><strong>What is Software Architecture ? </strong>.</li><li>Monolith vs Microservice Architecture .</li></ul><p>if you missed Day7, <a href="https://medium.com/@gunalan.d.official/system-design-75-day-7-microservices-vs-monolithic-architecture-in-detail-26aa6978ab77"><strong>check out here</strong></a><strong> .</strong></p><h3>What is a Database?</h3><p>A <strong>database</strong> is a structured system designed to store, retrieve, and manage data efficiently. It offers <strong>CRUD (Create, Read, Update, Delete)</strong> operations and plays a critical role in modern software applicationos.</p><p>There are two types of databases :</p><ul><li>SQL Database (Relational Databases)</li><li>No SQL Database (Non-Relational Databases)</li></ul><h3><strong>What is a SQL Database?</strong></h3><p>SQL databases, also known as <strong>Relational Databases (RDBMS)</strong>, store data in a structured manner using <strong>tables (rows and columns).</strong> Each <strong>row</strong> represents a record, and each <strong>column</strong> represents a field (attribute).</p><p><strong>Key Characteristics:</strong></p><ul><li><strong>Structured Schema</strong> : SQL databases require a predefined schema, meaning the structure of the data is fixed.</li><li><strong>ACID Support </strong>: They ensure Atomicity, Consistency, Isolation, and Durability, which are crucial for transactional reliability.</li><li><strong>Relationships</strong>: Tables can be related to each other using foreign keys, enabling complex queries and joins .</li></ul><p><strong>Common SQL Databases:</strong></p><ul><li>MySQL</li><li>PostgreSQL</li><li>Oracle Database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*bMi_21H8-Am2q5vTz1ksBQ.png" /><figcaption>EXAMPLE TABLE</figcaption></figure><p><strong>Properties of a Relational Database:</strong></p><ul><li>Each row should be <strong>unique </strong>(at least one attribute should be )</li><li>Each cell must contain <strong>atomic values</strong> (no multiple values in a single cell).</li><li>The <strong>order of columns</strong> does not affect queries.</li><li>The <strong>order of rows</strong> does not affect queries.</li></ul><h3>What is a NO SQL Database?</h3><p>NoSQL databases, also known as <strong>Non-Relational Databases</strong>, store data in a more <strong>flexible, schema-less</strong> format. They are designed to handle <strong>semi-structured or unstructured data</strong> and are optimized for <strong>scalability</strong> and <strong>high-performance</strong> use cases and its widely adopted in today’s modern application.</p><p><strong>Key Characteristics:</strong></p><ul><li><strong>No Fixed Schema</strong> : NoSQL databases are <strong>schema-less</strong>, allowing dynamic changes to data structures.</li><li><strong>Horizontal Scalability : </strong>Designed for <strong>distributed systems</strong>, making them highly scalable.</li><li>NoSQL databases doesn’t store record in a form of rows and cols , it offers <strong>diverse ways</strong> of storing a record.</li></ul><p><strong>Common NO SQL Databases:</strong></p><ul><li><strong>Document-Based Databases</strong> → Store JSON-like documents ( <strong>MongoDB</strong>, <strong>Elasticsearch )</strong></li><li><strong>Key-Value Stores</strong> → Store data as key-value pairs. (<strong>Redis</strong>, <strong>Memcached)</strong></li><li><strong>Column family</strong> based databases ( <strong>Cassandra </strong>, <strong>Hbase</strong>)</li><li><strong>Graph database</strong> ( Neo4j )</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*NDpd_4up_CppMYGANS-Nbw.png" /></figure><p>In <strong>Part 2</strong>, we’ll dive into <strong>how to choose between SQL and NoSQL</strong> for different use cases, along with a <strong>detailed comparison</strong> based on performance, scalability, consistency, and real-world examples.</p><p>Stay tuned!</p><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitec</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpBqHBQ2I2yAmnQ5h6_L8A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f378eb739c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 7 — Microservices vs Monolithic Architecture in Detail]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-7-microservices-vs-monolithic-architecture-in-detail-26aa6978ab77?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/26aa6978ab77</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[monolithic-architecture]]></category>
            <category><![CDATA[scalability]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 14:49:40 GMT</pubDate>
            <atom:updated>2025-01-31T15:14:06.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*d2XX2zKSLkJOG65M.jpg" /></figure><h3>System Design 75: Day 7 — Microservices vs Monolithic Architecture in Detail</h3><p>SYSTEM DESIGN 75 — DAY 7</p><h3>Revisiting Day 6 Concepts :</h3><p>Before diving into today’s topic, let’s quickly recap what we covered in <strong>Day 6:</strong></p><ul><li><strong>What is Cache Invalidation ?</strong></li><li><strong>Types of Cache Invalidation :</strong> Write-through, Write-around, Write-Back , TTL</li><li><strong>Cache Eviction Policies :</strong> LRU , LFU , FIFO .</li></ul><p><em>If you missed </em><strong><em>Day 6</em></strong><em>, </em><a href="https://medium.com/@gunalan.d.official/system-design-75-day-6-cache-management-invalidation-eviction-strategies-4cde811e7eb0"><em>check it out here</em></a><em>.</em></p><h3>What is Software Architecture?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*S0c5-puLmuUbw19pT2wlGQ.png" /><figcaption><a href="https://www.reddit.com/r/softwarearchitecture/comments/1fj4khu/can_someone_explain_what_is_software_architecture/">Reddit Comment</a></figcaption></figure><p>There will lot of definitions of software architecture, but at its core, it refers to <strong>how you structure and build a product</strong>. Different architectures define how components within a system interact to deliver functionality.</p><p>Most widely used architectures is</p><ul><li>Monolith Architecture</li><li>Microservices Architecture</li></ul><h3>What is a Monolithic Architecture?</h3><p>A <strong>Monolithic Architecture</strong> is a single codebase or application that handles all responsibilities for the system. Components such as <strong>user registration, notifications, ticket booking, movie searching, logging, and admin control</strong> are tightly integrated within one application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jGo6hhi-4y1sdHfWmXxeyg.png" /><figcaption><strong>FIG.1 MONOLITH ARC EXAMPLE</strong></figcaption></figure><p><strong>Pros :</strong></p><ul><li>✅ <strong>Simplicity : </strong>Simpler development and deployment</li><li>✅ <strong>Cost Effective : </strong>Lower cost / cogs</li><li>✅ <strong>Faster Development</strong> — Easier debugging and a single deployment pipeline.</li></ul><p><strong>Cons:</strong></p><ul><li>❌ <strong>Single Point of Failure (SPOF)</strong> — A failure in one module can bring down the entire system.</li><li>❌ <strong>Hard to Scale</strong> — Scaling requires redeploying the entire application.</li><li>❌ <strong>Tightly Coupled Components</strong> — Changes in one module can impact others.</li></ul><h3>What is a Microservices architecture?</h3><p>Microservices architecture is a <strong>software design pattern</strong> where your application is divided into <strong>small, independent services</strong>, each handling a specific part of business function. These services communicate with each other using <strong>APIs</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w9J4slNo-VDb0RepCXF2RQ.png" /><figcaption><strong>FIG.2 MICOSERVICE ARC EXAMPLE</strong></figcaption></figure><p><strong>Pros :</strong></p><ul><li>✅ <strong>Independence</strong> — Each service runs separately and can be developed, deployed, and scaled independently.</li><li>✅ <strong>Scalability</strong> — Services can be scaled based on demand without affecting the entire system.</li><li>✅ <strong>Technology Flexibility</strong> — Different services can use different programming languages, databases, and frameworks.</li><li>✅ <strong>NO SPOF</strong> : Failure in one service doesn’t bring down the whole application</li></ul><p><strong>Cons:</strong></p><ul><li>❌ <strong>More services = More complexity</strong> → Managing multiple services, databases, and communication channels can be difficult.</li><li>❌ <strong>Deployment becomes complex</strong> : each service may needs its own pipeline as it can be different tech.</li><li>❌ <strong>Inter-service communication issues</strong></li><li>❌<strong> Debugging</strong> requires more effort</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*WkDvH18Uw96X9j9sP66-yA.png" /></figure><p><strong>Use Monolithic Architecture if:</strong></p><ul><li>You are building a <strong>small or early-stage project</strong>.</li><li>You want a <strong>simple deployment</strong> with fewer moving parts.</li></ul><p><strong>Use Microservices if:</strong></p><ul><li>You have a <strong>large-scale</strong> system needing independent scaling.</li><li>You need <strong>different technologies</strong> for different services.</li><li>Your <strong>team is large</strong> and can manage independent services.</li><li>Your customer doesn’t tolerate downtime.</li></ul><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitec</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*9w_dE5Q5L9aklFQNF_xTFg.png" /></figure><p><strong><em>Links to Refer</em></strong>:</p><ul><li><a href="https://www.atlassian.com/microservices/microservices-architecture/microservices-vs-monolith">Microservices vs. monolithic architecture | Atlassian</a></li><li><a href="https://microservices.io/patterns/monolithic.html">Microservices Pattern: Pattern: Monolithic Architecture</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26aa6978ab77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design 75: Day 6— Cache Management: Invalidation & Eviction Strategies]]></title>
            <link>https://medium.com/@gunalan.d.official/system-design-75-day-6-cache-management-invalidation-eviction-strategies-4cde811e7eb0?source=rss-b2a20622af08------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cde811e7eb0</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Gunalan Deivaganapathy]]></dc:creator>
            <pubDate>Thu, 30 Jan 2025 16:23:33 GMT</pubDate>
            <atom:updated>2025-01-30T16:23:33.217Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*Mx3cQQ5sqdu__DgEJ60JDA.png" /><figcaption>DAY 6 OF SYSTEM DESIGN 75</figcaption></figure><p>SYSTEM DESIGN 75 — DAY 6</p><h3>Revisiting Day 5 Concepts :</h3><p>Before diving into caching, let’s quickly recap what we covered in <strong>Day 5:</strong></p><ul><li><strong>What is Caching?</strong></li><li><strong>Types of Caching:</strong> Client-Side Caching, Server-Side Caching</li><li><strong>Caching Strategies:</strong> CDN Use Case, Cache Placement Strategies</li></ul><p>If you missed <strong>Day 5</strong>, <a href="https://medium.com/@gunalan.d.official/system-design-75-day-5-caching-simplified-e1fb12183528">check it out here</a>.</p><h3>What is Cache Invalidation ?</h3><p>When data is stored in cache for faster access, it remains until it either expires or is evicted to make room for new data. <strong>Cache invalidation</strong> is the process of removing stale or outdated data from the cache to ensure users get fresh and accurate data.</p><p>Using HTTP headers, we can control cache expiration times. However, sometimes we need to <strong>forcefully</strong> remove data from cache before its expiry time — this is where cache invalidation comes into play.</p><h3><strong>Types of Cache Invalidation :</strong></h3><p>There are different strategies for cache invalidation:</p><ul><li>Write-through</li><li>Write-around</li><li>Write-Back</li><li>TTL ( Time-to-live )</li><li>Event based invalidation</li></ul><h4>Write Through Cache:</h4><ul><li>Data is <strong>simultaneously</strong> written to both the cache and the database.</li><li>Ensures data consistency but adds <strong>write latency</strong>.</li><li>Best for <strong>read-heavy workloads</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*4D64cs5MNo2gKdbO8dJlNA.png" /></figure><h4>Write Around Cache:</h4><ul><li>Data is <strong>directly written</strong> to the database, bypassing the cache.</li><li>Cache is only updated when data is read.</li><li>Reduces cache pollution but increases <strong>cache misses</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*qwvH1qmibeczBmTT_g_YPQ.png" /></figure><h4>Write Back Cache:</h4><ul><li>Data is written to <strong>cache first</strong>, then asynchronously written to the database.</li><li>Improves write performance , but <strong>risk of lose of data</strong> ( if cache goes down before updating to source).</li><li>Best for <strong>write-heavy workloads</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*uurfGlqEC-NbGF6CWLHxGQ.png" /></figure><h4>Time To Live:</h4><ul><li>Cache entries expire after a set time period. Ensures data is not stale and manages memory.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*EcS9ztP8zMOAtjlJuOpOYw.png" /></figure><h4>Event Based Cache:</h4><ul><li>Cache is updated or invalidated based on specific events or triggers in the application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*XUlbl9DcuYlotUvmMTnU5w.png" /></figure><h3>Cache Eviction Policies</h3><p>A cache eviction policy/ algorithm is a way of deciding which data to evict from the cache storage to ensure the memory is not OOM . there are different Eviction Policies</p><ul><li>LRU (Least Recently Used)</li><li>LFU (Least Frequently Used)</li><li>FIFO (First In, First Out)</li><li>Random Replacement</li></ul><h4>LRU :</h4><ul><li>Discards the <strong>least recently accessed</strong> data.</li><li>Efficient for <strong>time-sensitive applications</strong>.</li><li>Example: Web browsers evict<strong> least used tabs</strong>.</li></ul><h4>LFU :</h4><ul><li>Discards data that is <strong>accessed the least times</strong>.</li><li>More memory-intensive than LRU as it requires tracking <strong>usage frequency</strong>.</li><li>Example: Leaderboard Cache.</li></ul><h4>FIFO :</h4><ul><li>Evicts the <strong>oldest</strong> data first, regardless of access frequency</li><li>But not ideal as the old data can be frequently used</li><li>Example: Simple queue-based caching.</li></ul><h4>Random Replacement :</h4><ul><li>Evicts <strong>random</strong> entries.</li><li>Example: Not sure about usecase tho :).</li></ul><p>Feel free to connect with me on <a href="https://www.linkedin.com/in/gunalan-deivaganapathy/"><strong>LinkedIn</strong></a> to stay updated on future System Design tutorials, or if you’d like to discuss system design strategies or challenges!</p><p><strong>#SystemDesign75 #SystemDesign #Caching #ScalableSystems #TechLearning #DistributedSystems #PerformanceOptimization #Latency #RTT #PerformanceOptimization #CloudArchitecture #ScalableArchitecture #Engineering #TechLearning #SoftwareArchitecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*O2jMWu4j_3P3thTlNP_HTw.png" /></figure><p><strong><em>Links to Refer</em></strong>:</p><ul><li><a href="https://docs.aws.amazon.com/whitepapers/latest/database-caching-strategies-using-redis/caching-patterns.html">Caching patterns</a></li><li><a href="https://redis.io/blog/cache-eviction-strategies/">Cache Eviction Strategies Every Redis Developer Should Know</a></li><li><a href="https://blog.cloudflare.com/instant-purge/">Instant Purge: invalidating cached content in under 150ms</a></li><li><a href="https://redis.io/glossary/cache-invalidation/">Cache Invalidation - Redis</a></li><li><a href="https://arpitbhayani.me/blogs/lfu/">Constant time implementation of the LFU cache eviction algorithm</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cde811e7eb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>