Skip to contentমূল লেখায় যান

Topic 22 · Courseটপিক 22 · Course

The CAP Theorem

Two clerks in two offices keep the same ledger. The phone line between them goes dead. A customer walks in and asks for a balance. The clerk must either answer from a ledger that may be old, or refuse to answer. This is the problem that the CAP theorem describes.

6 min read6 মিনিটে পড়া যায় · 9 sections9টি সেকশন · 2 sources2টি সোর্স · updated Oct 2026আপডেট: Oct 2026

The CAP theorem: one cut link, one choiceCAP theorem: একটি কাটা লিংক, একটি বাছাই

Cut the link between two nodes, then choose consistency or availability and see what a read does.দুটি নোডের মধ্যকার লিংক কাটুন, তারপর কনসিসটেন্সি বা অ্যাভেইলেবিলিটি বেছে দেখুন একটি রিড কী করে।

2 min2 মিনিট5 steps5টি ধাপ
  • Value on AA-র মান2
  • Value on BB-র মান2
  • Read on BB-তে রিড2
link upলিংক চালুwrite 2লেখা 2readরিডclientক্লায়েন্টNode Aনোড Avalue 2মান 2group 1গ্রুপ ১Node Bনোড Bvalue 2মান 2answer: 2উত্তর: 2

You’ll learnআপনি শিখবেন

  • What a network partition isনেটওয়ার্ক পার্টিশন কী
  • Why a cut link leaves B with old dataকাটা লিংকে B কেন পুরোনো ডেটা রাখে
  • The choice: consistency or availabilityবাছাই: কনসিসটেন্সি নাকি অ্যাভেইলেবিলিটি
  • Why the choice only arises in a partitionবাছাই কেন শুধু পার্টিশনে আসে

In plain words

The CAP theorem says that a system with data on more than one server cannot give you all of three things: Consistency, Availability, and Partition tolerance. Eric Brewer made this conjecture in a talk at the PODC conference in 2000 Source 1সোর্স 1. Two researchers later proved it for a precise model Source 1সোর্স 1.

The proof paper defines each letter in a strict way Source 1সোর্স 1:

LetterMeaning in the paper
C, consistencyAtomic (also called linearizable) consistency. All operations fit in one order, and each looks as if it finished at a single instant. The service acts like one node that handles one operation at a time.
A, availabilityEvery request that reaches a node that has not failed gets a response. The algorithm must eventually end. The paper sets no limit on how long it may take.
P, partition toleranceThe network may lose any number of messages between nodes. In a partition, all messages between the two groups are lost.

সহজ English

The CAP theorem says that a system with data on more than one server cannot give you all of three things. The three things are Consistency, Availability, and Partition tolerance. Eric Brewer made this conjecture in a talk at the PODC conference in 2000 Source 1সোর্স 1. Two researchers later proved it for a precise model Source 1সোর্স 1.

The proof paper defines each letter in a strict way Source 1সোর্স 1:

  • C, consistency: Atomic (also called linearizable) consistency. All operations fit in one order. Each one looks as if it finished at a single instant. The service acts like one node that handles one operation at a time.
  • A, availability: Every request that reaches a node that has not failed gets a response. The algorithm must eventually end. The paper sets no limit on how long it may take.
  • P, partition tolerance: The network may lose any number of messages between nodes. In a partition, all messages between the two groups are lost.

বাংলা ব্যাখ্যা

CAP theorem বলে, একাধিক সার্ভারে ডেটা থাকা কোনো সিস্টেম আপনাকে তিনটি জিনিস একসঙ্গে দিতে পারে না। তিনটি জিনিস হলো Consistency (কনসিসটেন্সি), Availability (অ্যাভেইলেবিলিটি) এবং Partition tolerance (পার্টিশন টলারেন্স)। 2000 সালে PODC কনফারেন্সের একটি বক্তৃতায় Eric Brewer এই অনুমান (conjecture) করেন Source 1সোর্স 1। পরে দুজন গবেষক একটি নির্দিষ্ট মডেলের জন্য এটি প্রমাণ করেন Source 1সোর্স 1।

প্রমাণের পেপার প্রতিটি অক্ষরকে কঠোরভাবে সংজ্ঞায়িত করে Source 1সোর্স 1:

  • C, কনসিসটেন্সি: অ্যাটমিক (linearizable-ও বলা হয়) কনসিসটেন্সি। সব অপারেশন একটি ক্রমে বসে। প্রতিটি এমন দেখায়, যেন এক মুহূর্তে শেষ হয়েছে। সার্ভিস এমনভাবে কাজ করে, যেন একটি নোড একবারে একটি অপারেশন সামলাচ্ছে।
  • A, অ্যাভেইলেবিলিটি: যে নোড ব্যর্থ হয়নি, তার কাছে পৌঁছানো প্রতিটি রিকুয়েস্ট রেসপন্স পায়। অ্যালগরিদমকে শেষ পর্যন্ত শেষ হতে হবে। পেপার এটি কতক্ষণ নিতে পারে তার কোনো সীমা দেয় না।
  • P, পার্টিশন টলারেন্স: নেটওয়ার্ক নোডগুলোর মধ্যে যেকোনো সংখ্যক মেসেজ হারাতে পারে। পার্টিশনে দুই দলের মধ্যে সব মেসেজ হারিয়ে যায়।

When you need it

This advice is the tutorial's own. Use CAP when a system keeps copies of data on several servers, for example in two data centers, and the network between them can fail. Testers meet it in tests of replication, failover, and broken links.

সহজ English

This advice is the tutorial's own. Use CAP when a system keeps copies of data on several servers, for example in two data centers. The network between them can fail. Testers meet CAP in tests of replication, failover, and broken links.

বাংলা ব্যাখ্যা

এই পরামর্শ টিউটোরিয়ালের নিজস্ব। কোনো সিস্টেম একাধিক সার্ভারে ডেটার কপি রাখলে CAP ব্যবহার করুন, যেমন দুটি ডেটা সেন্টারে। তাদের মধ্যকার নেটওয়ার্ক ব্যর্থ হতে পারে। টেস্টাররা রিপ্লিকেশন, ফেইলওভার (failover) ও ভাঙা লিংকের টেস্টে CAP-এর মুখোমুখি হয়।

Why you must choose during a partition

The proof is simple. Split the servers into two groups that lose all messages between them. A client writes a new value in group 1. Then a client reads in group 2. The read cannot return the new value, because no message arrived Source 1সোর্স 1. The service must either answer with an old value (and lose consistency) or not answer (and lose availability). The paper proves that no algorithm can guarantee both availability and atomic consistency when messages can be lost Source 1সোর্স 1.

Brewer gives the same view with two nodes on two sides of a partition. If a node can still update data, the two sides become inconsistent. If you keep consistency, one side must act as if it is down Source 2সোর্স 2. Brewer says the general belief is that wide-area systems cannot give up partition tolerance, so the hard choice is between C and A Source 2সোর্স 2.

The paper also shows that any two of the three can work together Source 1সোর্স 1. A system with C and P can refuse requests, as many locking or quorum databases do when some failures occur Source 1সোর্স 1. A system with C and A works when there are no partitions, for example on a LAN Source 1সোর্স 1. A system with A and P can return old data, as a web cache does Source 1সোর্স 1.

সহজ English

The proof is simple. Split the servers into two groups that lose all messages between them. A client writes a new value in group 1. Then a client reads in group 2. The read cannot return the new value, because no message arrived Source 1সোর্স 1. The service must either answer with an old value (and lose consistency) or not answer (and lose availability). The paper proves that no algorithm can guarantee both availability and atomic consistency when messages can be lost Source 1সোর্স 1.

Brewer gives the same view with two nodes on two sides of a partition. If a node can still update data, the two sides become inconsistent. If you keep consistency, one side must act as if it is down Source 2সোর্স 2. Brewer says the general belief is that wide-area systems cannot give up partition tolerance. So the hard choice is between C and A Source 2সোর্স 2.

The paper also shows that any two of the three can work together Source 1সোর্স 1.

বাংলা ব্যাখ্যা

প্রমাণটি সহজ। সার্ভারগুলোকে দুটি দলে ভাগ করুন, যাদের মধ্যে সব মেসেজ হারিয়ে যায়। একজন ক্লায়েন্ট গ্রুপ 1-এ একটি নতুন মান লেখে। তারপর একজন ক্লায়েন্ট গ্রুপ 2-তে পড়ে। রিড নতুন মান ফেরত দিতে পারে না, কারণ কোনো মেসেজ পৌঁছায়নি Source 1সোর্স 1। সার্ভিসকে হয় পুরোনো মান দিয়ে উত্তর দিতে হবে (এবং কনসিসটেন্সি হারাতে হবে), নয়তো উত্তর দেবে না (এবং অ্যাভেইলেবিলিটি হারাবে)। পেপার প্রমাণ করে, মেসেজ হারাতে পারলে কোনো অ্যালগরিদম অ্যাভেইলেবিলিটি ও অ্যাটমিক কনসিসটেন্সি দুটিরই গ্যারান্টি দিতে পারে না Source 1সোর্স 1।

Brewer পার্টিশনের দুই পাশে দুটি নোড নিয়ে একই দৃষ্টিভঙ্গি দেন। কোনো নোড তখনো ডেটা আপডেট করতে পারলে দুই পাশ ইনকনসিসটেন্ট হয়ে যায়। কনসিসটেন্সি রাখলে এক পাশকে এমনভাবে চলতে হয়, যেন সেটি বন্ধ Source 2সোর্স 2। Brewer বলেন, সাধারণ বিশ্বাস হলো ওয়াইড-এরিয়া সিস্টেম পার্টিশন টলারেন্স ছাড়তে পারে না। তাই কঠিন বাছাই হলো C আর A-এর মধ্যে Source 2সোর্স 2।

পেপার আরও দেখায়, তিনটির যেকোনো দুটি একসঙ্গে কাজ করতে পারে Source 1সোর্স 1।

  • C ও P-যুক্ত সিস্টেম রিকুয়েস্ট প্রত্যাখ্যান করতে পারে, যেমন অনেক লকিং বা কোরাম (quorum) ডেটাবেস কিছু ফেইলিউর ঘটলে করে Source 1সোর্স 1।
  • C ও A-যুক্ত সিস্টেম কাজ করে যখন কোনো পার্টিশন নেই, যেমন একটি LAN-এ Source 1সোর্স 1।
  • A ও P-যুক্ত সিস্টেম পুরোনো ডেটা ফেরত দিতে পারে, যেমন একটি ওয়েব ক্যাশ দেয় Source 1সোর্স 1।

Why "2 of 3" misleads

Brewer wrote that the "2 of 3" form was always misleading, because it oversimplified the tensions between the properties Source 2সোর্স 2. CAP rules out only a narrow case: perfect availability and perfect consistency together during a partition, and partitions are rare Source 2সোর্স 2. He gives three reasons Source 2সোর্স 2:

  1. Partitions are rare, so there is little reason to give up C or A when the network is healthy.
  2. The choice between C and A can be made many times in one system, and it can change by operation, by data, or by user.
  3. The three properties are more like scales than switches. Availability runs from 0 to 100 percent, and there are many levels of consistency.

সহজ English

Brewer wrote that the "2 of 3" form was always misleading. It oversimplified the tensions between the properties Source 2সোর্স 2. CAP rules out only a narrow case. The case is perfect availability and perfect consistency together during a partition. Partitions are rare Source 2সোর্স 2. He gives three reasons Source 2সোর্স 2:

  1. Partitions are rare, so there is little reason to give up C or A when the network is healthy.
  2. The choice between C and A can be made many times in one system. It can change by operation, by data, or by user.
  3. The three properties are more like scales than switches. Availability runs from 0 to 100 percent. There are many levels of consistency.

বাংলা ব্যাখ্যা

Brewer লিখেছেন, "2 of 3" রূপটি সবসময় বিভ্রান্তিকর ছিল। এটি বৈশিষ্ট্যগুলোর মধ্যকার টানাপোড়েনকে অতি-সরল করে Source 2সোর্স 2। CAP শুধু একটি সংকীর্ণ ক্ষেত্র বাদ দেয়। ক্ষেত্রটি হলো পার্টিশনের সময় নিখুঁত অ্যাভেইলেবিলিটি ও নিখুঁত কনসিসটেন্সি একসঙ্গে। পার্টিশন বিরল Source 2সোর্স 2। তিনি তিনটি কারণ দেন Source 2সোর্স 2:

  1. পার্টিশন বিরল, তাই নেটওয়ার্ক সুস্থ থাকলে C বা A ছাড়ার কারণ কম।
  2. C ও A-র মধ্যে বাছাই একই সিস্টেমে অনেকবার করা যায়। এটি অপারেশন, ডেটা বা ইউজার অনুযায়ী বদলাতে পারে।
  3. তিনটি বৈশিষ্ট্য সুইচের চেয়ে বেশি মাপকাঠির মতো। অ্যাভেইলেবিলিটি 0 থেকে 100 শতাংশ পর্যন্ত চলে। কনসিসটেন্সির অনেক লেভেল আছে।

Trade-offs

When a partition happens, each choice has a price.

  • Choose consistency. Some requests wait or fail. Retrying forever only delays the choice, and Brewer says it is in effect a choice for C over A Source 2সোর্স 2.
  • Choose availability. Both sides keep working, so the data can differ. After the partition the system must restore consistency and repair mistakes Source 2সোর্স 2. The designer must list the rules (invariants) of the data, which is hard to do well Source 2সোর্স 2.

Brewer suggests three steps: detect the partition, switch to a clear partition mode in which some operations may be restricted, and recover when the network returns Source 2সোর্স 2. For example, a system can record an order and charge the card after recovery Source 2সোর্স 2.

Time matters too. In practice a partition is a limit on how long you wait for a reply, so a timeout forces the decision: cancel the operation, or go on and risk inconsistency Source 2সোর্স 2. A tight bound means partition mode starts more often, also when the network is only slow Source 2সোর্স 2.

সহজ English

When a partition happens, each choice has a price.

  • Choose consistency. Some requests wait or fail. Retrying forever only delays the choice. Brewer says it is in effect a choice for C over A Source 2সোর্স 2.
  • Choose availability. Both sides keep working, so the data can differ. After the partition, the system must restore consistency and repair mistakes Source 2সোর্স 2. The designer must list the rules (invariants) of the data. This is hard to do well Source 2সোর্স 2.

Brewer suggests three steps. Detect the partition. Switch to a clear partition mode in which some operations may be restricted. Recover when the network returns Source 2সোর্স 2. For example, a system can record an order and charge the card after recovery Source 2সোর্স 2.

Time matters too. In practice a partition is a limit on how long you wait for a reply. So a timeout forces the decision: cancel the operation, or go on and risk inconsistency Source 2সোর্স 2. A tight bound means partition mode starts more often, also when the network is only slow Source 2সোর্স 2.

বাংলা ব্যাখ্যা

পার্টিশন ঘটলে প্রতিটি বাছাইয়ের একটি মূল্য আছে।

  • কনসিসটেন্সি বাছলে। কিছু রিকুয়েস্ট অপেক্ষা করে বা ব্যর্থ হয়। চিরকাল রিট্রাই (retry) করলে শুধু বাছাই পিছিয়ে যায়। Brewer বলেন, বাস্তবে এটি A-র চেয়ে C-কে বাছা Source 2সোর্স 2।
  • অ্যাভেইলেবিলিটি বাছলে। দুই পাশই কাজ চালায়, তাই ডেটা আলাদা হতে পারে। পার্টিশনের পর সিস্টেমকে কনসিসটেন্সি ফিরিয়ে আনতে হয় এবং ভুল ঠিক করতে হয় Source 2সোর্স 2। ডিজাইনারকে ডেটার নিয়মগুলোর (invariant) তালিকা করতে হয়। এটি ভালোভাবে করা কঠিন Source 2সোর্স 2।

Brewer তিনটি ধাপ বলেন। পার্টিশন শনাক্ত করুন। একটি স্পষ্ট পার্টিশন মোডে (partition mode) যান, যেখানে কিছু অপারেশন সীমিত হতে পারে। নেটওয়ার্ক ফিরলে রিকভার করুন Source 2সোর্স 2। যেমন, একটি সিস্টেম অর্ডার রেখে দিতে পারে এবং রিকভারির পর কার্ডে চার্জ করতে পারে Source 2সোর্স 2।

সময়ও গুরুত্বপূর্ণ। বাস্তবে পার্টিশন হলো উত্তরের জন্য কতক্ষণ অপেক্ষা করবেন তার একটি সীমা। তাই টাইমআউট সিদ্ধান্তটি বাধ্য করে: অপারেশন বাতিল করুন, অথবা এগিয়ে গিয়ে ইনকনসিসটেন্সির ঝুঁকি নিন Source 2সোর্স 2। কড়া সীমা মানে পার্টিশন মোড আরও ঘন ঘন শুরু হয়, নেটওয়ার্ক শুধু ধীর হলেও Source 2সোর্স 2।

A real-life example

This example is the tutorial's own. A test platform stores exam answers on a server in city A and a copy on a server in city B. The link between the cities breaks. A student saves an answer on server A. A teacher opens the answer on server B.

  • If server B shows the old answer, the platform kept availability and lost consistency.
  • If server B says "try again later", the platform kept consistency and lost availability.

Both are valid under the theorem. The team must decide which choice suits each operation. An old exam answer may be fine for a few minutes. A payment taken twice is not.

সহজ English

This example is the tutorial's own. A test platform stores exam answers on a server in city A. It keeps a copy on a server in city B. The link between the cities breaks. A student saves an answer on server A. A teacher opens the answer on server B.

  • If server B shows the old answer, the platform kept availability and lost consistency.
  • If server B says "try again later", the platform kept consistency and lost availability.

Both are valid under the theorem. The team must decide which choice suits each operation. An old exam answer may be fine for a few minutes. A payment taken twice is not.

বাংলা ব্যাখ্যা

এই উদাহরণ টিউটোরিয়ালের নিজস্ব। একটি টেস্ট প্ল্যাটফর্ম শহর A-র একটি সার্ভারে পরীক্ষার উত্তর রাখে। এটি শহর B-র একটি সার্ভারে একটি কপি রাখে। দুই শহরের মধ্যকার লিংক ভেঙে যায়। একজন স্টুডেন্ট সার্ভার A-তে একটি উত্তর সেভ করে। একজন শিক্ষক সার্ভার B-তে ওই উত্তর খোলে।

  • সার্ভার B পুরোনো উত্তর দেখালে প্ল্যাটফর্ম অ্যাভেইলেবিলিটি রেখেছে এবং কনসিসটেন্সি হারিয়েছে।
  • সার্ভার B "try again later" বললে প্ল্যাটফর্ম কনসিসটেন্সি রেখেছে এবং অ্যাভেইলেবিলিটি হারিয়েছে।

CAP theorem অনুযায়ী দুটিই বৈধ। টিমকে ঠিক করতে হবে প্রতিটি অপারেশনের জন্য কোন বাছাই মানায়। পুরোনো পরীক্ষার উত্তর কয়েক মিনিটের জন্য চলতে পারে। দুবার নেওয়া পেমেন্ট চলে না।

Common mistakes

সহজ English

বাংলা ব্যাখ্যা

  • CAP-কে "যেকোনো 2টি বেছে নিন" হিসেবে পড়া। বাছাইটি পার্টিশনের সময় আসে। সুস্থ নেটওয়ার্ক C ও A দুটিই দেয় Source 2সোর্স 2।
  • C-এর দুটি অর্থ গুলিয়ে ফেলা। CAP-এ কনসিসটেন্সি হলো একবারে একটি রিকুয়েস্টের বিষয় Source 1সোর্স 1, অথবা ডেটার একটি হালনাগাদ কপির বিষয় Source 2সোর্স 2। ACID-এ এটি ট্রানজেকশনের নিয়মের বিষয়। Brewer বলেন, CAP-এর অর্থ একটি কঠোর উপসেট (subset) Source 2সোর্স 2।
  • একটি পুরো প্রোডাক্টকে চিরকালের জন্য "CP" বা "AP" লেবেল দেওয়া। বাছাই অপারেশন, ডেটা বা ইউজার অনুযায়ী আলাদা হতে পারে Source 2সোর্স 2।

What a tester can check

Tutorial advice

These test ideas are the tutorial's own advice, not a claim of the sources.

  • Break the link. In a test environment, cut the network between two nodes. Check what the app does for a read and for a write.
  • Know the choice. For each important operation, ask the team: does it refuse, or does it answer with old data? Write the answer in the test plan.
  • Check the repair. After you restore the link, check that the two sides agree, and that no order or payment ran twice.

সহজ English

These test ideas are the tutorial's own advice, not a claim of the sources.

  • Break the link. In a test environment, cut the network between two nodes. Check what the app does for a read and for a write.
  • Know the choice. For each important operation, ask the team: does it refuse, or does it answer with old data? Write the answer in the test plan.
  • Check the repair. After you restore the link, check that the two sides agree. Check that no order or payment ran twice.

বাংলা ব্যাখ্যা

এই টেস্টের ধারণাগুলো টিউটোরিয়ালের নিজস্ব পরামর্শ, সোর্সের দাবি নয়।

  • লিংক ভাঙুন। টেস্ট এনভায়রনমেন্টে দুটি নোডের মধ্যকার নেটওয়ার্ক কেটে দিন। রিড ও রাইটের জন্য অ্যাপ কী করে, তা দেখুন।
  • বাছাইটি জানুন। প্রতিটি গুরুত্বপূর্ণ অপারেশনের জন্য টিমকে জিজ্ঞেস করুন: সে কি প্রত্যাখ্যান করে, নাকি পুরোনো ডেটা দিয়ে উত্তর দেয়? উত্তরটি টেস্ট প্ল্যানে লিখুন।
  • মেরামত যাচাই করুন। লিংক ফিরিয়ে আনার পর দুই পাশ একমত কিনা দেখুন। কোনো অর্ডার বা পেমেন্ট দুবার চলেনি কিনা দেখুন।

Key words

WordMeaning
Consistency (C)In the paper: atomic consistency, as if one node handled all operations in one order Source 1সোর্স 1
Availability (A)Every request to a working node eventually gets a response Source 1সোর্স 1
PartitionA network failure that loses all messages between two groups of nodes Source 1সোর্স 1
Partition tolerance (P)The service keeps its promises although the network may lose messages Source 1সোর্স 1
Partition modeA state where a system detects a partition and may limit some operations Source 2সোর্স 2
InvariantA rule about the data that should always be true Source 2সোর্স 2

Reels on this topicএই টপিকের রিলস

Short videos from other creators, picked for this topic. They are not part of this page's fact-checked text. Nothing loads from YouTube until you press Play.অন্য ক্রিয়েটরদের বানানো ছোট ভিডিও, এই টপিকের জন্য বাছাই করা। এগুলো এই পেজের ফ্যাক্ট-চেক করা লেখার অংশ নয়। চালান বাটন চাপার আগে YouTube থেকে কিছুই লোড হয় না।

  1. [1]
    Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services

    S. Gilbert and N. Lynch, ACM SIGACT News, 2002 (author copy, MIT CSAIL) · accessed 2026-10-22দেখা হয়েছে: 2026-10-22

  2. [2]
    CAP Twelve Years Later: How the "Rules" Have Changed

    E. Brewer, IEEE Computer, 2012 (copy republished by InfoQ) · accessed 2026-10-22দেখা হয়েছে: 2026-10-22