Geeknarrator

  • Home
  • Podcast
  • Blog
  • Serivce
  • Contact Us
Hit enter to search or ESC to close
post-header
computer science

CAP Theorem – Consistency, Availability and Partition Tolerance.

admin
October 2, 2017

 

Hi guys, I hope you are doing good and enjoying the articles so far.Today we are going to learn more about CAP theorem.This is a very important concept to understand when working with high scale distributed system with huge data.To start with lets discuss some of important terms that are used in the world of distributed computing.

1) Distributed computing : In this model of computing there are set of distributed nodes (servers, components) which are connected to each other through a network and talk to each other by passing messages. These messages can be simple Http requests, RPCs or may be messages flowing through a queue like SQS, Apache MQ, RabbitMQ etc.

2) Consistency – This refers to a feature of a distributed system which always show correct/latest data.For example your banking application, it will always show you correct balance in your account.It doesn’t matter how many request you send , it will always provide latest data.Stale data doesn’t exist in such systems.Even if it does, it won’t be used to serve end customer’s requests.

3) Availability – This refers to the ability of a system to be always available.For example social networking apps like facebook, twitter, instagram. These are always available.By available we mean that every customer request will be served always.

4) Partitioning – This usually refers to a geographically separated set of nodes which cannot talk to each other directly. For example a server which is located in Mumbai not directly networked with another server in Delhi, but they are part of one system when we see the bigger picture.

Now since we understand the basic terminology, let’s see what CAP theorem (also known as Brewer’s theorem) has to say :

“It is practically impossible for a distributed computing system to simultaneously provide all three of consistency, availability and partition tolerance.”

In a distributed environment a network failure is highly possible, which can create partitions in your system, which means that data packets would be lost, some of the nodes would be unreachable.Even in such cases, some distributed system need to be tolerant.On the other hand there are systems which can choose to be not partition tolerant and rather be consistent and highly available all the time. Also there are systems who can compromise on their consistency but need to be available and be partition tolerant such as Facebook.

Let’s now discuss, what all options exist :

1) CA but not P (Consistent, highly available but not partition tolerance)  : When it is OK to loose some functionalities of your application due to network partition but NOT OK to be inconsistent and unavailable then you can choose a CA system.For example RDBMS (Oracle,MySQL) . A good example of such system would be a banking application. So when they face a network partition, they may not operate completely (you may not be able to use some features) but they will still chose to be consistent and available.

2) AP but not C (Available and partition tolerant but not consistent) : When it is OK to lose consistency in your application, but NOT OK to be unavailable or partition intolerant you can chose an AP system.A good example would be Facebook likes/comments or flight prices. At times it may happen that the number of likes that you see on you picture on Facebook is 10, but when you actually open the picture you see 20 likes.This inconsistent behavior is OK for such systems. It may not create a news if Facebook is showing incorrect number of comments, but it will definitely create a breaking news if it is down for 10 minute. Examples : CouchDB,Cassandra, Dynamo DB.

3) CP but not A (Consistent and partition tolerant but not highly available) : By now you would have understood, what could be a CP system.Just so that we are on the same page, a CP system would chose to be unavailable but not be inconsistent and partition intolerant.A very good example would be IRCTC website. They may go down for number of times a day, but they don’t want to be inconsistent. If at all there is a partition, they will go unavailable but chose to be consistent all the time. Example : MongoDB, Redis, HBase.

If a system wants to provide any two it has to compromise on the third one. In order to maintain consistency, systems may chose to be unavailable or be partition intolerant, but cannot achieve all three simultaneously (or any of the combinations as discussed above).

I hope this was helpful in understanding the basics of CAP theorem, please feel free to provide comments/feedbacks.

Cheers,

Kaivalya Apte.

 

Share this on:
availabilitybigdatacapcassandraconsistencyDatabaseeventual consistencymongodbnosqlpartition tolerancerdbms
Previous post
Software Engineering Toolbox
Next post
Work smart(less), achieve big. After all you are an engineer.
Related Posts
computer science

Embracing Technical Leadership and the Architect Role: Insights from Venkat Subramaniam

admin
Apr 29, 2023
computer science

Decorator Pattern: Scala

admin
Apr 11, 2020
1 Comment
    Sylvia Boyle
    Jan 21, 2018 Reply

    Fantastic site. Lots of useful information here. I’m sending it to several pals ans also sharing in delicious. And of course, thank you to your sweat!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Embracing Technical Leadership and the Architect Role: Insights from Venkat Subramaniam
  • Distributing SQL Databases Globally
  • Why is DynamoDB AWSome?
  • Designing Instagram, Linkedin, Facebook like applications
  • Test Driven Development with Frederik Banke

Recent Comments

  1. kaivalya apte on Software Engineering Interviews – 5 Red Flags
  2. Amitk on Software Engineering Interviews – 5 Red Flags
  3. Anurag Kumar on Software Engineering Interviews – 5 Red Flags
  4. Sylvia Boyle on CAP Theorem – Consistency, Availability and Partition Tolerance.
  5. Rajan on Smart and Stupid Alexa – My Experience
team

Brayan Olson

Art Director

It’s our job to get you the information you need, so you can make the most of your aviation investments.

Categories

  • computer science (18)
  • Interviewing (2)
  • kafka (2)
  • REST APIs (1)
  • Scalability (7)
  • streamprocessing (1)
  • Technology (26)
  • Uncategorized (3)

Recent Posts

  • Software Engineering Interviews – 5 Red FlagsMay 26, 2019
  • Recursion : Understand recursion with a simple exampleOctober 2, 2017

Popular Tags

algorithm AWS bigdata cap clean code computerscience Design pattern elastic elasticsearch framework functional programming functions highly scalable index integration testing internet Interview mistakes invertedindex Java java programming languages microservices money mongodb monolith multiprocessors new index nodowntime nosql old index optimisation Parallel programming partition tolerance positive functions postgresql integration testing postman collection for elastic search Predicate Preparing for interview programming Scala sharding software engineering Testing threads unit testing

Newsletter

newsletter signup

Get notified about updates and be the first to get early access to new episodes.

FAQ

Most frequent questions and answers
What is The GeekNarrator?

The GeekNarrator is a dynamic platform dedicated to sparking curiosity, excitement, and inspiration in the realms of Technology and Software Engineering. Its unique offerings include comprehensive and in-depth technical discussions led by industry experts, providing actionable insights for aspiring and established software engineers alike. The GeekNarrator is more than a resource—it’s a community committed to nurturing your inner geek, helping you leverage technology, and empowering you to excel in software engineering.

How do I collaborate?

If you want to do a paid collaboration, then shoot an email at speakwithkv@gmail.com. 

 

 

We are a tech startup, how can you help?

I’m a firm advocate for the idea that contemporary technology companies must actively engage in podcasting. It’s an excellent medium for articulating the challenges they’re addressing, elucidating the unique solutions they’ve developed, and cultivating awareness around the technology they’re leveraging. But above all, it’s a powerful tool for fostering a vibrant and engaged community.

I can be your ally in this venture. Let’s join forces to create not just an episode, but perhaps an entire series. Our discourse can revolve around the bedrock principles of software engineering and state-of-the-art technology, all while highlighting the remarkable features of your product. This collaboration promises to amplify your voice in the tech community, underscore the importance of your work, and illuminate the path to a tech-forward future.

I am a Software Engineer, how can I use your platform to become a better engineer?

In the field of Software Engineering, effective communication, collaboration, and engaging in deep discussions play pivotal roles. These skills are just as crucial as technical expertise when it comes to becoming a truly exceptional engineer. With this in mind, I create a series of podcast episodes that aim to assist you in honing these abilities, expanding your knowledge, and igniting your curiosity to engage in meaningful conversations.

By tuning into the podcast, you will gain valuable insights from experienced professionals, discover their diverse range of experiences, and be inspired to embark on your own exploration of software engineering. Furthermore, the episodes will equip you with practical techniques to enhance your communication skills, ensuring that your ideas are effectively conveyed and understood.

By actively engaging with the podcast, you will find yourself equipped with the necessary tools to excel not only in the technical aspects of software engineering but also in fostering productive collaboration, articulating your thoughts clearly, and facilitating profound discussions. Together, we will unravel the secrets of effective communication, collaboration, and the art of engaging in thought-provoking conversations, ultimately empowering you to take your engineering capabilities to the next level.

site-logo

Be Geeky!

Subscribe Podcast on:
Youtube
apple music
spotify
Google podcast
Get in Touch

speakwithkv@gmail.com

Twitter Linkedin

© 2023 — Produced by Geeknarrator

All rights Reserved.