0% found this document useful (0 votes)
112 views4 pages

CAP Theorem in Blockchain

The CAP Theorem states that in a distributed system, it is impossible to achieve consistency, availability, and partition tolerance simultaneously; one must prioritize two of the three features. In blockchain technology, immediate consistency is often sacrificed for availability and partition tolerance, leading to eventual consistency. The theorem highlights the trade-offs that must be made during network failures, with systems needing to choose between consistency and availability based on their specific requirements.

Uploaded by

vijayananthan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views4 pages

CAP Theorem in Blockchain

The CAP Theorem states that in a distributed system, it is impossible to achieve consistency, availability, and partition tolerance simultaneously; one must prioritize two of the three features. In blockchain technology, immediate consistency is often sacrificed for availability and partition tolerance, leading to eventual consistency. The theorem highlights the trade-offs that must be made during network failures, with systems needing to choose between consistency and availability based on their specific requirements.

Uploaded by

vijayananthan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

What is the CAP Theorem in Blockchain?

CAP Theorem stands for Consistency, Availability, and Partition Tolerance. According
to the theory, a distributed system cannot always ensure consistency, availability,
and partition tolerance. When things go wrong, we must prioritize at most two
distributed system features and trade-offs between them.
 CAP Theorem or Brewer’s theorem states that it is feasible to provide either
consistency or availability—but not both—in the event of a network failure on a
distributed database, a theory from theoretical computer science about
distributed data stores. In other words, according to the CAP theorem, a
distributed database system that experiences a partition must choose between
Consistency and Availability.
 We must simultaneously communicate over the network and store data among
several nodes in a distributed system. A distributed system frequently falls victim
to network failures because of its reliance on network calls in a significant way.
Tolerance for partitions is crucial. In this situation, we must decide, based on our
needs, whether to prioritize consistency or availability.
 With blockchain technology, immediate consistency is frequently sacrificed for
availability and partition tolerance. By requiring a specific amount of
“confirmations,” blockchain consensus techniques are simply simplified to
eventual consistency.
 Network failures can affect any distributed system, hence network partitioning
is usually required. There are just two choices remaining in the event of a
partition: consistency or availability. The system will return an error or time out if
a specific piece of information cannot be guaranteed to be current owing to
network segmentation when consistency is chosen above availability. The system
will always process the query and attempt to return the most recent version of
the data even if it cannot ensure that it is up to date because of network
partitioning when availability is preferred over consistency.
 Blockchain is a decentralized database that manages a shared ledger that
cannot be altered. Transactions are what make up the shared ledger. Consensus
techniques are used to record transactions inside the shared ledger. Sharing
distributed transactions naturally raises questions about the CAP theorem.
 Consistency is sacrificed in Blockchain due to the priority given to Availability
and Partition Tolerance. In this case, Partition tolerance (P), Availability (A), and
Consistency (C) on the blockchain are not attained simultaneously; instead, they
are acquired over time.

CAP Theorem in Blockchain


As we know that CAP stands for Consistency, Availability, and Partition Tolerance so,
let us understand Consistency, Availability, and Partition Tolerance with the help of
some examples. Let us first understand availability as then it will be much easier to
understand consistency and partition tolerance then.
1. Availability
Availability means that all clients who request data receive a response even if one or
more nodes are down. In a distributed system, every operational node replies to
each valid request made to it, to put it another way.
2. Consistency
Consistency means that the duplicated data item will appear in the same copies on
all nodes during different transactions. an assurance that each node in a distributed
cluster returns the same, most recent, and successful writer. Every client’s
perception of the data must be consistent to be considered consistent. Sequential
consistency, which is a particularly powerful type of consistency, is referred to as
consistency in CAP.

3. Partition Tolerance

A communication breakdown—a momentary delay or lost connection between nodes


—is referred to as a partition in a distributed system. Partition tolerance describes
the ability of a cluster to function even in the face of numerous communication
failures between system nodes.

CAP Theorem NoSQL Database Types

Consistency and high availability are not compatible with NoSQL. Eric Brewer initially
stated this in his CAP Theorem. We can only accomplish two out of the three
guarantees for a database, consistency, availability, and partition tolerance. It is
crucial to comprehend the NoSQL database’s constraints. Consistency and high
availability are not compatible with NoSQL.
It can be observed from the above diagram that Consistency and Availability are
connected by a database CA, Availability and Partition Tolerance by a database AP,
and Consistency and Partition Tolerance by a database CP. Let us discuss what CA,
AP, and CP mean.
CA: CA database provides availability and consistency among all the nodes.
However, it cannot accomplish this if there is a partition between any two system
nodes, hence it is unable to provide fault tolerance. For eg: Applications used in
banking and finance demand available and consistent data.
AP: AP database means that the system continues to operate even in the presence
of node failures. AP-based systems compromise consistency and availability. Non-
distributed databases like PostgreSQL uses AP-based database systems.
CP: CP database means that the system continues to operate even though network
failures are occurring in the database. CP systems are strongly consistent but they
are not properly available.
CAP Theorem Applied
1. Availability over consistency (A+P)
 When availability is preferred over consistency the system will always process
the query and attempt to return the most recent version of the data even if it
cannot ensure that it is up to date because of network partitioning.

 When accumulating data is a top priority, availability is crucial. Consider


factors like user preferences or behavioral data in this situation. In situations like
these, you’ll want to record as much data as you can about what a user or
customer is doing, but it’s not necessary to keep the database updated all the
time. Even when network connections are down, they must still be reachable and
available.
 One more reason to adopt a NoSQL database that puts availability over
consistency is the rising demand for offline application use.
The following picture clearly shows Availability over Consistency:

2. Consistency over availability (C+P)

 When discussing consistency and availability, a lot of technical jargon might be


used, but the core idea is simple: consistency is required if the database’s data
must always be current and aligned, even in the event of a network failure.
 When you need several clients to share the same view of the data, consistency
is a particular use case where you should prioritize it. Use a database, for
instance, that provides consistency and assurance that the data you are looking
at is up to date in cases when the network is unreliable or malfunctions while
dealing with financial or sensitive information.
 For example, Information about bank accounts must be consistent and
accurate because it is sensitive information. Therefore, it is preferable to
announce an outage if the most recent accurate information is not accessible
than to provide the consumer with inaccurate information.
The following picture clearly shows Consistency over Availability:

CAP Theorem Examples

Example 1: A mobile phone has been designed in such a way that it has space for
only one sim card which means no sharing.
Solution: This system guarantees Consistency, Availability, and Tolerance to
Partitions.
Example 2: Immediately after sending a message to someone, that individual might
not get it.
Solution: With this system, availability and partition tolerance are compromised
without compromising consistency, or AP.

You might also like