Sobes.tech
Senior

Tell me about the CAP theorem. What would you choose — consistency or availability during a network partition?

sobes.tech AI

Answer from AI

The CAP theorem states that in a distributed system, it is impossible to simultaneously guarantee all three properties: Consistency, Availability, and Partition tolerance. During a network partition, the system must choose between consistency and availability.

  • Consistency (C) means that all nodes see the same data at the same time.
  • Availability (A) means the system always responds to requests.
  • Partition tolerance (P) means part of the network is unavailable, and communication between nodes is disrupted.

The choice depends on the application's requirements:

  • If data accuracy and consistency are important (e.g., banking transactions), consistency is prioritized at the expense of availability.
  • If continuous operation and responsiveness are important (e.g., social networks, caches), availability is prioritized, allowing for temporary inconsistency.

Thus, during a network partition, it is usually necessary to choose between C and A, based on the business logic and system priorities.