CP systems (sacrifice A during partition): refuse/block to avoid stale data. Examples: HBase, etcd/ZooKeeper, MongoDB (majority writes), traditional RDBMS replication.
AP systems (sacrifice C during partition): always answer, reconcile later (eventual consistency). Examples: Cassandra, DynamoDB, Riak, CouchDB.
You and your friend keep the same scoreboard in two rooms connected by a phone line. Suddenly the phone line breaks. You add a point in your room. Your friend can't hear you. Now someone asks your friend the score. Friend has two choices: say the old number (answers fast but it's wrong now), or say "I can't tell you until the phone works" (correct, but unhelpful). You cannot make your friend both answer and be right — because they never heard about your new point! That's the whole CAP theorem.
Dekho, CAP theorem sirf distributed databases ke liye relevant hai — jahan data ek se zyada machines (nodes) pe replicate hota hai. Idea simple hai: network kabhi na kabhi tootega hi (cable cut, machine slow, message drop). Is tooting ko bolte hain partition. CAP kehta hai ki jab partition ho jaye, tab tum ek hi cheez choose kar sakte ho — ya to Consistency (sabko latest correct data dena) ya Availability (har request ka jawab dena, chahe purana data ho). Dono ek saath possible nahi.
Reason bilkul logical hai: socho do node hain, link toot gaya, ek node pe naya write hua x=v1. Doosre node ko pata hi nahi chala. Ab agar koi doosre node se padhe, to wo ya to puranav0 degi (matlab galat, par available) ya bolegi "abhi nahi bata sakti" (matlab correct, par unavailable). Wo dono kaise karegi? Use to naye value ka pata hi nahi! Isi liye proof ban jaata hai.
Isiliye "any 2 of 3 choose karo" waala statement thoda galat hai. P optional nahi hai — partition tumhare control me nahi. Asli choice hai: partition aane par CP bano (correct raho, zaroorat pade to reject karo — jaise bank balance) ya AP bano (jawab dete raho, baad me sync karo — jaise shopping cart). Bank me galat data se paisa loss hota hai, isliye CP. Cart me thoda stale chalega par website down nahi honi chahiye, isliye AP.
Ek aur important baat: PACELC. CAP sirf partition time ki baat karta hai, lekin reality me network theek hone par bhi tradeoff hota hai — agar tum saare replicas ka wait karoge consistency ke liye, to latency badhegi. Toh roz-marra me bhi Latency vs Consistency ka game chalta rehta hai. Yeh samajh lo to interview aur real design dono crack ho jaayenge.