No history yet

Distributed Systems

What is a Distributed System?

Most applications you use every day, from social media to online banking, don't run on a single computer. Instead, they're powered by many computers working together. This collection of independent computers that appears to its users as a single, coherent system is called a distributed system.

Think of it like building a house. You could have one person try to do everything: lay the foundation, frame the walls, run the plumbing, and handle the electrical. It would be slow and if that person gets sick, all work stops. Or, you could have a team of specialists: a carpenter, a plumber, an electrician. They work on different parts at the same time and communicate with each other to get the job done. The final result is a single, complete house, but it was built by a coordinated group. Distributed systems work the same way.

Distributed System

noun

A collection of autonomous computing elements that appears to its users as a single coherent system.

Each computer in the network, often called a node, has its own memory and processor. They communicate with each other by passing messages over a network. The main goal is to share resources and work together to accomplish tasks that a single computer couldn't handle, or couldn't handle as efficiently.

Distributed systems are at the core of modern scalable applications, and interviewers often assess your grasp of these concepts to gauge your ability to design robust, efficient systems.

The Hard Parts

Coordinating multiple computers introduces unique challenges that don't exist when you're working with just one machine. Two of the biggest hurdles are network latency and data consistency.

Network Latency: This is the time it takes for a message to travel from one node to another. It's the delay inherent in network communication. Sending a message across a network is never instant, just as sending a letter takes longer than handing it to someone in the same room. This delay can affect the performance of the entire system, especially when nodes need to wait for responses from each other.

Data Consistency: In a distributed system, data is often copied and stored on multiple nodes. This is great for reliability—if one node fails, the data is safe on another. But it creates a problem: how do you ensure that all copies of the data are up to date? Imagine you and a friend are editing the same document online. If you both change the same sentence at the exact same time, which change should be saved? Ensuring every user sees a correct and consistent version of the data across all nodes is a major challenge.

Common Blueprints

While distributed systems can be incredibly complex, they often follow a few common architectural models. Two of the most fundamental are the client-server model and the peer-to-peer model.

In the client-server model, there is a clear division of labor. A central, powerful computer called the server provides a service, like hosting a website or storing files. Many other computers, called clients, connect to this server to request data or use its services. When you browse a website, your computer (the client) sends a request to the website's server, which then sends the webpage back to you. It's a simple, centralized approach.

In the peer-to-peer (P2P) model, there is no central server. Every computer in the network is an equal, or a peer. Each peer can act as both a client and a server. They communicate directly with each other to share data and resources. Early file-sharing services like Napster and modern cryptocurrencies like Bitcoin are well-known examples of P2P systems. This model is more decentralized and can be more resilient, as there is no single point of failure.

Before diving into complex designs, it's a good idea to test your understanding of these core ideas.

Quiz Questions 1/5

What is the primary characteristic of a distributed system?

Quiz Questions 2/5

In the house-building analogy, what does a single person trying to build the entire house represent?

These concepts form the bedrock of system design. Understanding them is the first step toward building applications that are robust, scalable, and reliable.