Mir250 and REST APIs
Introduction to Distributed Systems
What Is a Distributed System?
A distributed system is a group of separate computers that work together, but to the outside world, they look like a single machine. Think of a large online service like Google Search or Netflix. You interact with one interface, but behind the scenes, thousands of computers are coordinating to find your results or stream your movie.
Essentially, it's a network of computers that pool their resources and capabilities to accomplish a task that a single computer couldn't handle.
These systems don't share memory or a clock. Instead, they communicate by sending messages over a network. This design allows them to be incredibly powerful and resilient. If one computer in the system fails, others can pick up the slack, and the service often continues without interruption. This is a core feature known as fault tolerance.
The Big Challenges
Building a reliable distributed system is tricky. Engineers face a constant balancing act between three crucial properties: consistency, availability, and partition tolerance. It's often impossible to guarantee all three at once, a concept known as the CAP theorem.
Consistency
noun
Ensures that every computer in the system has the same, most up-to-date data. When a piece of data is updated, all subsequent requests will see that new value.
Imagine a bank's distributed database. If you deposit $100, you want that new balance to be reflected immediately, no matter which ATM or app you use. That's consistency in action.
Availability
noun
Guarantees that the system is always operational and ready to respond to requests, even if some parts are down. Every request receives a response, without a guarantee that it contains the most recent information.
This means the system is always “on.” When you visit a website, you expect it to load. High availability means it almost always does, serving your request successfully.
Partition Tolerance
noun
The system continues to operate even if messages are lost or delayed between its different parts (a 'network partition'). This is crucial for systems spread across different data centers or geographic locations.
For any system running on the internet, network failures are a fact of life. Partition tolerance is non-negotiable. This means designers must often choose between strong consistency and high availability when a network partition occurs.
Common Architectures
Distributed systems can be organized in many ways. Two of the most fundamental models are client-server and peer-to-peer.
In the client-server model, there's a clear division of labor. A central server provides data or services, and multiple clients request and consume them. When you browse a website, your browser is the client, and it requests the web page from a powerful server. The server holds the authority and the resources, while the clients are the consumers.
The peer-to-peer (P2P) model is more decentralized. Every computer, or “peer,” in the network has equal capabilities and responsibilities. Each peer can act as both a client and a server, sharing files or resources directly with other peers without needing a central server. Early file-sharing services and modern technologies like blockchains are often built on P2P principles.
These foundational concepts are the building blocks for the complex, large-scale systems we rely on every day.