What is a distributed system?
In layman terms, a distributed system is a group of computers working together as to appear as a single computer to the end-user. These machines have a shared state, operate concurrently and can fail independently without affecting the whole system’s uptime.
Need for distributed systems
Suppose if we’ve a database server on a single machine, and we’re about to receive more traffic on the machine, we need to scale our server. We can either scale horizontally or vertically. Scaling vertically is well and good while you can, but after a certain point you will see that even the best hardware is not sufficient for enough traffic, not to mention impractical to host.
What a distributed system enables us to do is to scale horizontally. Scaling horizontally simply means adding more machines/computers rather than upgrading the hardware of a single machine.
Horizontal scaling is cheaper than vertical scaling after a certain threshold but that is not its main case for preference. While vertical scaling can only boost performance up to the latest hardware capabilities, the best thing about horizontal scaling is that there is no cap to scale. Whenever performance degrades or you want to support more traffic, you just add more machines and can scale infinitely.
A single high performing machine can become a single point of failure, but a distributed system (which comprises of multiple nodes) provides fault tolerance. A cluster of 10 machines across multiple data centers is more fault tolerant than a single machine. Even is one machine/data-center is down, the other machines/datacenter keep the system up and running.
If we host our application/service on a single host, the roundtrip time for a request to complete from different part of the world could get really high. However with distributed systems, we could keep a node closest to our users in different parts of the world, and when a user from NewYork makes a request to the server, the request is served by the nearest node/data center to NewYork. This way distributed systems also provide overall lower latency to the users.
Overall distributed systems enables us following things:
- Horizontal scaling
- Fault tolerance
- Lower Latencies