6 Distributed Systems
This chapter covers: - Databases: Fundamental concepts related to DBs such as the CAP and PACELC theorem or isolation levels. - System design: Core concepts we can apply in system design interview or when working with systems at scale.
6.1 Databases
In this section, we will explore fundamental concepts related to databases. Mastering these concepts means not only making more accurate decisions when it comes to choosing a database in a particular context, but also avoiding possible production issues because of a lack of fundamental understanding on how DBs work.
6.1.1 ACID
The ACID properties—Atomicity, Consistency, Isolation, and Durability—are key database concepts. Understanding these four properties is critical for anyone working with databases. Let’s break them down.
Atomicity
Definition: All the operations of a transaction must succeed, or none will.
In simpler terms: All or nothing. If one part of a transaction fails, the entire transaction is rolled back, leaving the database unchanged. For example, imagine a bank transfer where money is deducted from one account and added to another. If either step fails, the entire transaction is rolled back, and neither account is updated.