How does the CAP theorem apply to microservices?
Answer
The CAP theorem states that a distributed system can guarantee at most two of three properties: Consistency (every read receives the most recent write), Availability (every request receives a response, without guarantee it is the latest), and Partition Tolerance (the system continues to function despite network partitions). In microservices, network partitions are inevitable — the network between services will occasionally fail. Therefore, every distributed system must choose between CP (consistency over availability — reject requests when partitioned, like HBase, ZooKeeper) or AP (availability over consistency — serve potentially stale data, like Cassandra, DynamoDB in eventually-consistent mode). Most microservices systems choose AP because user-facing services must remain available, accepting eventual consistency with careful design around stale reads and conflict resolution.
Previous
What is distributed logging and how do you correlate logs across microservices?
Next
What are the trade-offs between eventual consistency and strong consistency in microservices?
More Microservices Architecture Questions
View all →- Advanced What are the trade-offs between eventual consistency and strong consistency in microservices?
- Advanced What are CRDTs and how can they help in distributed microservices state?
- Advanced What is Event Storming and how is it used to design microservices?
- Advanced What is consumer-driven contract testing with Pact?
- Advanced What are the three pillars of observability in microservices?