<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aniket Patel</title>
    <description>The latest articles on Forem by Aniket Patel (@aniket-blogs).</description>
    <link>https://forem.com/aniket-blogs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F536780%2Fbf09e7e2-2fc3-4211-91fc-2a7effce4777.jpeg</url>
      <title>Forem: Aniket Patel</title>
      <link>https://forem.com/aniket-blogs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aniket-blogs"/>
    <language>en</language>
    <item>
      <title>CAP Theorem</title>
      <dc:creator>Aniket Patel</dc:creator>
      <pubDate>Tue, 03 Sep 2024 07:48:47 +0000</pubDate>
      <link>https://forem.com/aniket-blogs/cap-theorem-5n5</link>
      <guid>https://forem.com/aniket-blogs/cap-theorem-5n5</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbtmopemhtru7mxk3z3d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbtmopemhtru7mxk3z3d.png" alt="Image description" width="800" height="753"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is impossible for a distributed data store to provide all three guarantees simultaneously.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;1. Consistency (C):&lt;/strong&gt; Every read receives the most recent write or an error.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This means that all working nodes in a distributed system will return the same data at any given time.&lt;/li&gt;
&lt;li&gt;Consistency is crucial for applications where having the most up-to-date data is critical: Banking System&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Availability (A):&lt;/strong&gt; It guarantees that every request (read/write) receives a response, without ensuring that it contains the more recent writes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This ensures that the system remains operational and responsive, even if responses from some of the nodes don't reflect the most up-to-date.&lt;/li&gt;
&lt;li&gt;Availability is crucial for applications requiring continuous operation, such as online retail systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Partition Tolerance (P):&lt;/strong&gt; It means that the system can continue to function even if some of the nodes in the network are unable to communicate with each other due to network partitions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A network partition occurs when a network failure causes a distributed system to split into 2 or more groups of nodes that cannot communicate with each other.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When there is a network partition, the system must choose between &lt;strong&gt;Consistency&lt;/strong&gt; and &lt;strong&gt;Availability&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The CAP Trade-off: Choosing 2 out of 3
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. CP (Consistency and Partition Tolerance):&lt;/strong&gt; Traditional relational databases, such as MySQL and PostgreSQL, when configured for strong consistency, prioritize consistency over availability during network partitions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When a system is being partitioned, it might reject certain requests to preserve consistency.&lt;/li&gt;
&lt;li&gt;Example: Banking Systems typically prioritize consistency and accuracy of data over availability. Consider an ATM network for a bank. When you withdraw money, the system must ensure that your balance is updated accurately across all nodes (consistency) to prevent overdrafts or other errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. AP (Availability and Partition Tolerance):&lt;/strong&gt; NoSQL databases such as Cassandra and DynamoDB are designed to prioritize high availability and partition tolerance, even at the expense of strong consistency.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: Amazon's shopping cart is designed to always accept items which is like prioritizing the availability, even during the pick high traffic periods like Black Friday.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. CA (Consistency and Availability):&lt;/strong&gt; In the absence of network partitions, a system can be consistent and available. However, network partitions are inevitable in distributed systems, making this combination impractical.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: In the world of distributed systems, the quest for a database that offers both consistency and availability is a challenging one. Single-node databases excel in providing these qualities but falter when it comes to tolerating partitions. This creates a theoretical impasse in a distributed environment.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>systemdesign</category>
      <category>distributedsystems</category>
      <category>database</category>
      <category>data</category>
    </item>
  </channel>
</rss>
