<?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 Rajan Gupta on Medium]]></title>
        <description><![CDATA[Stories by Rajan Gupta on Medium]]></description>
        <link>https://medium.com/@rg144262?source=rss-1b3fcae5087b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4rjkC2e3q06iVmLh</url>
            <title>Stories by Rajan Gupta on Medium</title>
            <link>https://medium.com/@rg144262?source=rss-1b3fcae5087b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:17:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rg144262/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[My difficulty with CAP theorem !!]]></title>
            <link>https://medium.com/@rg144262/my-difficulty-with-cap-theorem-305c48e87ad9?source=rss-1b3fcae5087b------2</link>
            <guid isPermaLink="false">https://medium.com/p/305c48e87ad9</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Rajan Gupta]]></dc:creator>
            <pubDate>Fri, 11 Oct 2024 19:24:35 GMT</pubDate>
            <atom:updated>2024-10-11T19:26:12.497Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>My difficulty with CAP theorem !!</strong></h3><p>Yeah, so we all know what CAP theorem is andwhat does C, A and P stands for, and that we can’t provide all three at the same time.</p><p>when we google can get images similar to following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dpNX6faEf6fxqvog.png" /></figure><p>And it all sounds good, and everybody is fine with it, But I get totally confused. and what intrigues me is the CA part, but let’s first take a look at how I’m able to understand and comprehend AP and CP without any objection.</p><h3><strong>AP databases, fine !!</strong></h3><p>I can understand how the AP databases such as Cassandra, couchDb and DynamoDB, can provide AP but not C.</p><ul><li>so it’s mostly masterless architecture, i.e reads and writes can go to any node, hence all the nodes are available during a partition.</li></ul><p><strong><em>Hence, during a partition, availability comes at the cost of consistency here.</em></strong></p><h3><strong>CP databases, fine !!</strong></h3><p>I can also understand, how and why does CP databases such as MongoDB, Hbase and Redis, provide AP but not C.</p><ul><li>one node must be primary serving the writes, while the others can serve the reads but not writes.</li></ul><p>When the primary node becomes unavailable, the secondary node with the most recent operation log will be elected as the new primary node. Once all the other secondary nodes catch up with the new master, the cluster becomes available again. As clients can’t make any write requests during this interval, the data remains consistent across the entire network.</p><blockquote><strong>Hence, during a partition, consistency comes at the cost of availability here.</strong></blockquote><h3><strong>But CA databases, how??</strong></h3><p>As in how can a system, have consistent data on all nodes, and also be available all the time(especially for writes)??</p><p>Let me explain why, I struggled to understand this:</p><ul><li>in RDBMS, strong consistency is a must (all ACID properties are required)</li><li>hence all the nodes, must be in same state in case of a read.</li><li>hence when a partition occurs:</li></ul><blockquote>option 1: either continue operating, but this means we’ll lose consistency, which we can’t so not an option</blockquote><p>OR</p><blockquote>option 2: or stop all operations, maintain consistent state.</blockquote><ul><li>RDBMS chooses option 2, and hence losses availability as well.</li></ul><blockquote>Hence my confusion, when it doesn’t provide availability, during a partition, then how can we call it a CA database.</blockquote><h3>How I finally understood it</h3><p>and that’s when I realised how silly i was being, when I’m saying, during a partition, RDBMS has to stop all operations, hence it’s providing consistency, but not availability, then RDMBS must be angrily screaming at me</p><blockquote>“When I said i can’t provide partition tolerance, I then why the hell you’re talking about partition tolerance, I provide C and A when there’s no partition”</blockquote><h3>My own understanding of CAP theorem</h3><p>You can either choose consistency and availability (like RDBMS), but don’t even think about system being able to operate during a network partition</p><p>OR</p><p>If you want some degree of partition tolerance in a highly distributed environment, hence either choose consistency ( like Mongo) or availability (like Cassandra)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=305c48e87ad9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>