0% found this document useful (0 votes)
8 views9 pages

CAP Theorem and Blockchain Trilemma Explained

Uploaded by

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

CAP Theorem and Blockchain Trilemma Explained

Uploaded by

adarsh abcd
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CAP Theorem and the Blockchain Trilemma

CAP Theorem and the Blockchain Trilemma

What is the CAP Theorem

Theorem

The CAP theorem says that a distributed system can deliver only two of three desired
characteristics: consistency, availability and partition tolerance (the ‘C,’ ‘A’ and ‘P’ in CAP).

CAP Theorem
The CAP theorem is also called Brewer’s Theorem, because it was first advanced by Professor Eric A.
Brewer during a talk he gave on distributed computing in 2000.

Distributed systems
A distributed system is a network that stores data on more than one node (physical or virtual machines)
at the same time.
Because all cloud applications are distributed systems, it’s essential to understand the CAP theorem
when designing a cloud app so that you can choose a data management system that delivers the
characteristics your application needs most.
Consistency

Consistency means that all clients see the same data at the same time, no matter which node they
connect to. For this to happen, whenever data is written to one node, it must be instantly forwarded or
replicated to all the other nodes in the system before the write is deemed ‘successful.’

Availability

Availability means that any client making a request for data gets a response, even if one or more nodes
are down. Another way to state this—all working nodes in the distributed system return a valid response
for any request, without exception.

Partition tolerance

A partition is a communications break within a distributed system—a lost or temporarily delayed


connection between two nodes. Partition tolerance means that the cluster must continue to work despite
any number of communication breakdowns between nodes in the system.

CAP Theorem and Database Systems


Properties
SQL calls for ACID properties, NoSQL follows the CAP theory.

ACID properties
Atomicity: All transactions must succeed or fail completely and cannot be left partially complete, even
in the case of system failure.
Consistency: The database must follow rules that validate and prevent corruption at every step.
Isolation: Concurrent transactions cannot affect each other.
Durability: Transactions are final, and even system failure cannot “roll back” a complete transaction.

No SQL Structure
Column-oriented, where data is stored in cells grouped in a virtually unlimited number of columns
rather than rows.
Key-value stores, which use an associative array (also known as a dictionary or map) as their data
model. This model represents data as a collection of key-value pairs.
Document stores, which use documents to hold and encode data in standard formats, including XML,
YAML, JSON (JavaScript Object Notation) and BSON. A benefit is that documents within a single
database can have different data types.
Graph databases, which represent data on a graph that shows how different sets of data relate to each
other. Neo4j, RedisGraph (a graph module built into Redis) and OrientDB are examples of graph
databases.

Examples of NoSQL databases


Redis
FaunaDB
CouchDB
MongoDB
Cassandra
Elasticsearch
BigTable
Neo4j
HBase

CAP theorem NoSQL database types


NoSQL databases are ideal for distributed network applications.
Unlike their vertically scalable SQL (relational) counterparts, NoSQL databases are horizontally scalable
and distributed by design—they can rapidly scale across a growing network consisting of multiple
interconnected nodes.
Cassandra and the CAP theorem (AP)
Apache Cassandra is an open source NoSQL database maintained by the Apache Software
Foundation.
It’s a wide-column database that lets you store data on a distributed network. However, unlike
MongoDB, Cassandra has a masterless architecture, and as a result, it has multiple points of failure,
rather than a single one.

Relative to the CAP theorem, Cassandra is an AP database—it delivers availability and partition
tolerance but can't deliver consistency all the time.
Cassandra doesn't have a master node, all the nodes must be available continuously.
Cassandra provides eventual consistency by allowing clients to write to any nodes at any time and
reconciling inconsistencies as quickly as possible.
As data only becomes inconsistent in the case of a network partition and inconsistencies are quickly
resolved, Cassandra offers “repair” functionality to help nodes catch up with their peers.

CAP Theorem In Practice


Consistency is achieved when all nodes have the same up-to-date copy of the data.
Availability is achieved when both nodes are up and running and responding with the latest copy of
data.
Partition tolerance is achieved when the network continues to operate despite communication failure or
delay between nodes.

However, in the event of a partition, either availability or consistency is unachievable. In blockchains,


consistency is sacrificed in favour of availability and partition tolerance, achieving eventual consistency over
time through validation from multiple nodes.

The Blockchain Trilemma

The Blockchain Trilemma


The blockchain trilemma is a concept that was likely derived from CAP Theorem which highlights the
trade-offs that exist between three desirable properties of a blockchain system: scalability, security,
and decentralisation.

Scalability
Refers to the ability of the blockchain system to handle a large volume of transactions efficiently. As more
users join the network and the number of transactions increases, the blockchain must be able to keep up
with the demand without sacrificing its other properties.

Security
Refers to the level of protection that the blockchain system provides against various types of attacks, such
as double-spending, 51% attacks, and others. The security of the system is critical, as any weakness or
vulnerability can lead to financial losses for users and damage the overall trust in the blockchain.

Decentralisation
Refers to the distribution of power and control among the network participants. In a decentralised blockchain
system, no single entity has complete control over the network. This helps to ensure the transparency and
immutability of the blockchain, as well as prevent censorship and protect user privacy.

Like CAP Theorem the Blockchain Trilemma states that it is impossible for a blockchain system to
simultaneously achieve all three properties at the same time.

Scaling Compromises

Bitcoin
Bitcoin achieves the highest levels of decentralization and censorship resistance at the cost of scalability
and high electrical consumption costs. This could potentially cause security issues in the future if
declining block rewards can not incentivise a large enough network to prevent a 51% attack.

Ethereum

Ethereum is rolling out upgrades that prioritise scalability at the cost of decentralization and security.
Many alternate layer 1 and layer 2 blockchains run centralized sequencers and consensus modules
completely compromising on decentralization for the benefit of scalability and security.

References
[Link]
[Link]

You might also like