쉬운 말로 이해하는 CAP 정리
모든 분산 데이터베이스의 설계에 영향을 미치는 일관성, 가용성, 분할 내성 사이의 상충 관계를 이해합니다.
쉬운 말로 이해하는 CAP 정리은(는) CoddyKit의 무료 MongoDB Academy 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 MongoDB Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. MongoDB Academy 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Why Distributed Systems Are Hard
Spreading data across many servers buys scale but brings distributed systems headaches: nodes must agree even when the network hiccups. Enter the CAP theorem.
The Three Properties: C, A, P
The CAP theorem says a distributed store can guarantee only two of three: Consistency, Availability, and Partition tolerance. The catch: partitions always happen.
Consistency Explained
Consistency means every read sees the latest write, from any node. Deposit money and check any ATM — you'd see the new balance. Reliable, but it costs speed.
Availability Explained
Availability means every request gets a response — never an error, even if the answer is slightly stale. A cart that always lets you add items chose this.
Partition Tolerance Explained
A partition is when nodes can't talk to each other — and in real networks, it will happen. So the real choice is always Consistency vs Availability during one.
CP Systems: Choose Consistency
CP systems pick consistency: during a partition they'd rather return an error than stale data. Right for ledgers and inventory, where wrong answers are costly.
AP Systems: Choose Availability
AP systems pick availability: they always answer, even with slightly old data, then sync up later. Perfect for social feeds, reviews, and shopping carts.
Where MongoDB Falls in CAP
MongoDB is CP by default. Only the primary node takes writes, so during a partition it briefly pauses writes rather than risk conflicts. The code shows read options.
// MongoDB read preference configuration in Node.js driver
const client = new MongoClient(uri, {
readPreference: 'primaryPreferred'
// 'primary' - CP: always fresh, fails during election
// 'primaryPreferred' - slightly more available, mostly fresh
// 'secondary' - AP: always available, may be stale
// 'nearest' - lowest latency node
});Eventual Consistency Demystified
Eventual consistency means nodes may briefly disagree, but given a moment, all reads catch up to the latest value. Nothing is lost — it just takes a beat.
PACELC: Beyond CAP
CAP only covers partitions, which are rare. PACELC adds the everyday trade-off: even with no partition, you choose between low latency and strong consistency.
Practical Implications for Developers
CAP helps you design wisely: expect slightly stale data, handle retries gracefully, and pick majority write concern for critical operations. The code shows how.
// Use majority write concern for critical operations
db.orders.insertOne(
{ _id: 'ord_99', item: 'Headphones', qty: 1 },
{ writeConcern: { w: 'majority', j: true } }
);
// w:'majority' = acknowledged by majority of replica set members
// j:true = must be written to journal (durable on disk)Quick Check
Test your understanding of MongoDB & NoSQL Databases concepts from this lesson.
Lesson Recap
You learned the CAP theorem, why partition tolerance is non-negotiable, and that MongoDB is CP by default. Next: exactly where MongoDB fits best.
자주 묻는 질문
“쉬운 말로 이해하는 CAP 정리” 강의는 무료인가요?
네 — “쉬운 말로 이해하는 CAP 정리” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 MongoDB Academy 강의 전체를 잠금 해제할 수 있습니다. MongoDB Academy 강의에는 총 4개의 강의가 포함되어 있습니다.
“쉬운 말로 이해하는 CAP 정리”에서 뭘 배우나요?
모든 분산 데이터베이스의 설계에 영향을 미치는 일관성, 가용성, 분할 내성 사이의 상충 관계를 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 MongoDB Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
MongoDB Academy을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 MongoDB Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“쉬운 말로 이해하는 CAP 정리” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 MongoDB Academy 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 MongoDB Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 관계형 데이터베이스의 병목
- NoSQL 유형: 문서, 키-값, 열, 그래프
- 쉬운 말로 이해하는 CAP 정리
- MongoDB의 위치