Skip to main content

dtechbits: CAP Theorem

 

Consistency
Every read receives the most recent write or an error.
Availability
Every request receives a (non-error) response, without the guarantee that it contains the most recent write.
Partition tolerance
The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.

When a network partition failure happens, it must be decided whether to do one of the following:

  • cancel the operation and thus decrease the availability but ensure consistency
  • proceed with the operation and thus provide availability but risk inconsistency.
CAP Theorem Euler Diagram

Thus, if there is a network partition, one has to choose between consistency or availability. Note that consistency as defined in the CAP theorem is quite different from the consistency guaranteed in ACID database transactions.[4]




Linearizability  or strict consistencyLinear consistency to execute the operations are executed in an order. It provides the definitely updated data as earlier operations are expected to complete atomically inlinear order even though the operations might have done in parallel or concurrently.

Linearizability can be achieved by

1. Distributed locking

2. Two-phase commit

3. Distributed data store with consensus algorithms like Paxos or Raft



PACELC theorem :

The PACELC theorem is an extension of the CAP theorem, providing additional insights into the behaviour of distributed systems during network partitions. The acronym PACELC stands for:

  1. P (Partition tolerance)

  2. A (Availability)

  3. C (Consistency)

  4. E (Else):

    • The "Else" in PACELC suggests that in the absence of network partitions, the system should strive to achieve both consistency and availability. In other words, when the network is not partitioned, the system should aim to be both consistent and available.
  5. L (Latency):

    • PACELC includes an additional factor, "Latency," which highlights the importance of considering the performance characteristics of the system. It emphasises that the system's behaviour during normal operation (without partitions) should also take into account the latency of operations.
  6. C (Complexity):

    • Some versions of the theorem include an additional "C" for "Complexity," which suggests that the decision-making process during network partitions can introduce additional complexity to the system.







Comments

Popular posts from this blog

React JS Basics

  What are side effects in React? In React, side effects are operations that interact with external systems or cause changes outside the component's rendering process. These can include: Data fetching: Retrieving data from APIs or other sources. Subscriptions: Setting up listeners for events or data changes. Timers: Creating timers for delayed actions or animations. DOM manipulation: Directly modifying the DOM (rarely used in modern React with declarative approach). Why use useEffect ? In class-based components, you would typically use lifecycle methods like componentDidMount , componentDidUpdate , and componentWillUnmount to handle side effects. Functional components don't have these methods directly. The useEffect Hook provides a way to manage side effects in functional components. It allows you to run a function after a component renders (or re-renders) and optionally clean up any resources created by that function before the component unmounts. How does useEffect wor...

Next.js vs react

Next.js builds upon React and offers several advantages over using React alone: Key Advantages of Next.js over React: Server-Side Rendering (SSR) and Static Site Generation (SSG): Next.js provides built-in support for SSR and SSG, leading to faster initial page loads, improved SEO, and better performance for content-heavy applications. Simplified Routing: Next.js offers a file-based routing system, making it easier to manage routing configurations compared to React, where you might need to use additional libraries like React Router. Automatic Code Splitting: Next.js automatically splits your JavaScript code into smaller chunks, optimizing page load times by loading only the necessary code for each page. API Routes: Next.js allows you to easily create serverless API endpoints within your Next.js project, simplifying backend integration. Image Optimization: Next.js includes an optimized image component that automat...

GIT Branching strategies

  What are GIT branching strategies? GIT branching strategies are patterns or approaches that tech teams use to organize & manage their code through different branches in a GIT system. Each strategy defines the rules & guidelines for the creation, naming & merging the branches for facilitating collaboration, stability, & release management. In this article, we're going to discuss  git branching strategy best use cases, hands-on on git, as well as the git branching strategies we follow. Along with recommendations on how to use git to accomplish work in a consistent and productive manner. ‍ GIT What are the different GIT branching strategies? Here are some commonly used git branching strategies: Master branch This is the  main  branch and one of the repository in which we have the latest stable code of production.   General rules: - Access to direct merge is restricted - Best practice is to create a CI/CD pipeline to merge code into this ...