## 3 Distributed Systems: Concepts and Challenges
### Challenges in Distributed Systems
Being able to manage concurrent actions in a distributed system, without causing data conflicts or other discrepancies in the network, requires the use of highly sophisticated synchronization mechanisms. Implementing those mechanisms, however, could prove a challenging task as well, due to trade-offs needed between the three characteristics (consistency, availability, partition tolerance) featured in CAP (Brewer's) theorem [37]. A few consistency models have been proposed so far, that could address the challenges mentioned previously. The most common ones are strict consistency and eventual consistency. Strict consistency may offer an especially high level of uniformity but this often affects the availability and performance of a system. Eventual consistency, on the other hand, offers performance boosts and greater flexibility but it also introduces temporary inaccuracies. A real-world example of consistency issues is the \"split-brain\" problem in Apache Cassandra, a popular distributed NoSQL database. In a split-brain scenario, network partitions can lead to multiple nodes accepting writes independently, resulting in data inconsistencies. Resolving these inconsistencies requires complex conflict resolution mechanisms and can lead to potential data loss or corruption. Figure 9 shows a multiple data center cluster with 3 replica nodes [38]. Figure 9: Multiple data center cluster with 3 replica nodes and consistency set to LOCAL_ONE. **Partition tolerance**: partition tolerance pertains to a distributed system's ability to keep operating even if partitions keep occurring in the network that result in nodes, or groups of nodes, being unable to communicate effectively with each other. Hardware malfunctions, network failures or other kind of disruptions are the causes of such partitions [39]. Therefore, being able to ensure that a network remains partition tolerant will greatly impact its reliability and availability. The real challenge of maintaining high levels of partition tolerance lies in keeping a balance between other characteristics as well, such as consistency and availability. In a distributed system, however, only two of the three characteristics (consistency, availability, partition tolerance) can be achieved, as stated in the CAP theorem. The CAP theorem, also known as Brewer's theorem, is a fundamental principle in the design of distributed systems [40]. Formulated by [PERSON] in 2000, it states that it is impossible for a distributed data store to simultaneously provide all three of the following guarantees:  
1. Consistency (C): Every read from the system receives the most recent write or an error. In other words, all nodes see the same data at the same time. 2. Availability (A): Every request (read or write) receives a non-error response, without the guarantee that it contains the most recent write. 3. Partition Tolerance (P): The system continues to operate despite network partitions, where communication between some subsets of nodes is lost. According to the CAP theorem, a distributed system can satisfy at most two of these three guarantees simultaneously:  
* CA (Consistency and Availability): These systems reject partitions, meaning they require a consistent network. If a partition occurs, the system must either sacrifice consistency or availability. * CP (Consistency and Partition Tolerance): These systems remain consistent in the presence of network partitions but may not be available to all nodes. * AP (Availability and Partition Tolerance): These systems remain available even when network partitions occur but may not guarantee consistency. * Figure 10 summarizes the CAP theorem's key points. In practical terms, no distributed system can achieve perfect consistency, availability, and partition tolerance simultaneously [41]. Therefore, systems' designers have to make decisions about the necessary trade-offs between these three characteristics and the expected network requirements needed and overall environment.