Distributed Systems
A distributed system is a computing environment in which various components are spread across multiple computers (or other computing devices) on a network. These devices split up the work, coordinating their efforts to complete the job more efficiently than if a single device had been responsible for the task.
1. Key Characteristics
- Scalability: The ability to grow by adding more resources (Horizontal Scaling).
- Reliability: The system continues to function even if one or more components fail.
- Availability: The system is operational and accessible when required.
- Transparency: The system appears to the user as a single, coherent system, hiding the complexity of the distribution.
2. The CAP Theorem
The CAP theorem states that a distributed data store can only provide two of the following three guarantees simultaneously:
- Consistency: Every read receives the most recent write or an error.
- Availability: Every request receives a (non-error) response, without the guarantee that it contains the most recent write.
- Partition Tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.
In reality, network partitions are unavoidable, so you usually have to choose between CP (Consistency + Partition Tolerance) or AP (Availability + Partition Tolerance).
3. Fallacies of Distributed Computing
L. Peter Deutsch and others at Sun Microsystems listed these false assumptions that programmers new to distributed applications often make:
- The network is reliable.
- Latency is zero.
- Bandwidth is infinite.
- The network is secure.
- Topology doesn't change.
- There is one administrator.
- Transport cost is zero.
- The network is homogeneous.
4. Common Patterns
- Sharding: Splitting data across multiple machines to distribute load.
- Replication: Keeping copies of data on multiple machines for redundancy and faster reads.
- Leader Election: Designating one node as the coordinator to manage state changes.
programming/microservices-architecture programming/cloud-computing-basics programming/event-driven-architecture