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.