Explain Distributed Systems Like I'm Five

This is an anonymous post sent in by a member who does not want their name disclosed. Please be thoughtful with your responses, as these are usually tough posts to write. Email sloan@dev.to if you'd like to leave an anonymous comment.

I hear this term a lot, but I'm not always sure what exactly it is referring to.

Did you find this post useful? Show some love!
DISCUSSION (8)

Like you were five: you ask your best friend a question, she doesn't know the answer, so she asks another person, who doesn't still know the answer but know someone who does, they get the answer, pass it back to the person before until it gets to your best friend. You only interacted with your best friend, nobody told you about "the others".

To have a distributed system you need to have more than one component connected by a network resulting in a single system to the user. These components talk to each other exchanging messages.

The internet is the biggest example of a distributed system. The web is another example of distributed system: you ask something to a browser, they get the answer somehow by talking to various entities linked by a network, they get you the answer back. A telephone network is another distributed system.

Let me know if there's something you're unsure about. I'm happy to expand.

First, let's see the difference between a system and an app:

System: is mostly where many users interact with each others (like dev.to or a hotel reservation)

App: where you use it alone (like Photoshop)

System: is like a factory where many people work to do a common goal (many services do lots of stuff to finish that room reservation the user wants)

App: that guy which works in that factory alone by himself and he is has mostly one single goal (Photoshop is mainly for creating that awesome design)

More examples:

  1. Windows / Linux / macOS are all operating "systems".

  2. Voice recorder is an app.

  3. MS Office word is an app.

  4. Whatsapp provides an app for the end users to send and receive messages, and they also have a system where you send messages and they get stored / processed then encrypted in the middle and received from the other end and decrypted.

Now that you know the difference between a system and an app, @rhymes already explained what a distributed system is...

You can see the addition on the word "systems" (in his comment) to make it "distributed": the components connect via network and talk to each others.

Just one more thing, mostly systems nowadays are a mere of SOA (Service Oriented Architecture).

Most products have various features. Take Amazon:

  • Search
  • Browse
  • Order
  • Payment
  • Shipping
  • etc.

Most apps have those features in one codebase, and therefore as part of one deployable (web) app.

Distributed systems build each feature as independently deployable apps.

If Payment needs info from Order, then Payment will get that data via Order's internal API (perhaps over HTTP).

If Payment needs to inform Shipping that the payment was successful: Payment will simply emit an event PaymentSuccessful that Shipping is listening for (asynchronously). Shipping will now decide to ship the order.

Other features can also listen for those events, so on PaymentSuccessful the Order feature may choose to "close" the order for further editing, etc.

In the end, distributed systems are when each feature communicates over-the-wire instead of within the same process/run-time (e.g. in code).

A distributed system is best explained in contrast to a centralized system.

A centralized system is like your school, we'll call it Sloan Elementary School. You go to school, you ride the bus, you learn from your teachers, you eat from the cafeteria, and you take pride in being a Sloan Unicorn-Sloth. Everything you do there is somehow being managed by Sloan Elementary, is paid for by Sloan Elementary, and likely has the name "Sloan Elementary" printed on it. Sloan Elementary School wears many hats and is the centralized authority for everything having to do with your education.

In contrast, a distributed system is more like the free-for-all out on the playground during recess. There are lots of kids out there from many different grades, playing many different games. The 5rd grade girls are playing kickball in the field (along with that one boy who has a crush on the pitcher), the 3rd grade is split up between Four-Square, Tag, and 2-hand-touch football, and you're having a lot of fun with your other kindergarten friends running and jumping around the playset. There is no one telling the students in each grade what they should do, they are just self-organizing and doing what they want.

But these recess game groups don't have ultimate freedom to do what they want, they need to have some structure in place amongst the games. Otherwise, you might have the football thrown in the middle of the Four-Square game and mess everyone up, or the kickball first base might be at the top of the slide. These groups need to work together to figure out where each one can play their games and come to an agreement on who is doing what so that everyone on the playground has the best time possible.

In more technical terms, a centralized system would be like you building a website. You would have a single server or maybe a cluster, but it all works toward the one product, and you're managing everything with that website.

A distributed system is like the internet. No one person owns the internet, anyone is free to add new servers wherever they want. But in order to be a part of it, you need to follow a set of protocols to ensure that your new server plays nicely with all the others already on the internet.

How I would explain it like you were actually five.

When we want to watch a movie, we take the DVD out of the box. We put it in the DVD player. We press the buttons on the remote. The TV shows the picture.

Each piece has it's own job, and when we put them all together, we get to watch a movie.

When we do an activity like playing a game like tag we have one person be the tagger. If we want to make the game faster we could have more than one tagger. That way we can tag more people and chase them better. But not we have two people we have to communicate with on how we are going to tag and while this could be better it also creates new problems we have to solve in how to tag the most amount of people.

Classic DEV Post from Aug 28

Who's looking for open source contributors? (August 28 edition)

Please shamelessly promote your project. Everyone who posted in previous weeks ...

Sloan
I help moderate content on this platform. I also ask questions on behalf of members looking for advice from the community.

dev.to is where software developers stay in the loop and avoid career stagnation.

Sign up (for free)