So I’ve been asked to explain microservices to a 10-year-old. They might not know much about computer applications and processes, so it became a challenge. But then, I figured out with who they spend a good amount of their time.
I haven’t done this personally, but I believe if you ask a kid who’s their favorite teacher, you’ll get an answer. Can this teacher teach all the subjects? I hardly think so.
Let’s see an example of BBT Elementary school, where Mr. Wolowitz is the only teacher who takes care of all subjects - Maths, Physics, Art, Biology, and Chemistry. Mr. Wolowitz is like a Monolith, a system that handles all the responsibilities. If Mr. Wolowitz, who has nut allergies, accidentally ate a peanut and couldn’t come to teach, there is no one in BBTES to teach. This is a problem since the students have no one to teach them, thus making the school not functional. I can see the happiness on the kids’ faces, but hey, we have to consider the ones who want to study too, right?
Principal Petersen, who is now aware of the problem, that happens when every responsibility is on a single teacher, hires some new teachers. Like Microservices, which are separate systems for each, the teachers are Dr. Cooper for Physics, Ms. Penny for Art, Dr. Bernadette for Biology, Dr. Amy for Chemistry, and Mr. Wolowitz continue to be the Maths teacher. If Mr. Wolowitz chocks on nuts again, only the maths teacher will be absent now. The school can still function since other teachers are not interrupted. This is called Fault Isolation, where the problem with one system will not collapse the other systems.
Now let’s say BBTES wants to start teaching history. If the only teacher available had been Mr. Wolowitz, Principal Petersen would’ve had to train him to teach history. Or if she is hiring a new teacher, she would want someone who knows all these subjects. But since she follows the Microservice style, she can hire a new teacher for history. Mr. Zack applied for the role and got it. It all happened so fast, and Principal Petersen didn’t have to see if Mr. Zack knew Physics before hiring him. This is like how people, who build a microservice, only need knowledge about what they make.
Anyway, it turns out Mr. Zack knew neither physics nor history. I guess Principal Petersen should’ve done a better job while interviewing. But she has the power to learn from her mistakes. After a better interview, they hired Prof. Spock as a history teacher, and the crisis got solved. She considers hiring Mr. Zack as an experiment and has learned her lesson from that experience. Since she hired Mr. Zack only to teach history, replacing him didn’t make much change. This is why she could experiment with Mr. Zack in the first place. This is like how we can confidently experiment with microservices since the risk is lower. Do you know what is interesting here? None of this chaos affected Dr. Cooper, Ms. Amy, or any others in their work. Thanks to the independence from others like independent microservices.
With all of this progress, there is a rush for admissions to BBTES this academic year. Principal Petersen decided to intake double the amount of children this year. But that means extra work for the teachers, especially for Dr. Cooper, who is now helping Principal Petersen with something. Guess what? It’s time to Scale. Principal Petersen can give a permanent pay hike to Dr. Cooper for the extra work. This is called Vertical Scaling, where we upgrade the system to handle the increased workload. But why would she want to permanently pay Dr. Cooper for temporarily helping her? So she decides to hire Dr. Hofstadter as a volunteering lecturer to share Dr. Cooper’s workload. Since Dr. Hofstadter is a volunteer, he can rest when there is no extra workload to share. And can also take on Dr. Cooper’s workload in case of his absence. This is called Horizontal Scaling, where you don’t upgrade the existing system but add more instances that will share the work.
Pasadena Public School wants a guest teacher for one day, and they ask for one from BBTES. Since Dr. Cooper is helping Principal Petersen, they can’t send him as he holds some sensitive information. But Dr. Cooper is not the only one working there, unlike when it was with Mr. Wolowitz. BBTES can send anyone else who doesn’t hold sensitive information to PPS as per their request. Like this, the ability to expose only specific systems instead of the whole is one of the advantages of Microservices.
A student is feeling hatred towards Maths. Mr. Wolowitz, who breaths and lives for maths, won’t take this well. And if Mr. Wolowitz was the only teacher, the student could’ve not mentioned this to him. But since that is not the case anymore, the student can tell this news to Dr. Amy, who wouldn’t expose this. The student’s secret stays safe with Dr. Amy like a specific Microsevice offers Security and Isolation for Data from other systems.
If BBTES decides to start a new school, they could have Ms. Penny teach in both schools since she can handle both schools and has no reason to be isolated to one school only. This is like how multiple unrelated systems can reuse a microservice, which would’ve been impossible if it was the single-teacher situation ( a teacher that holds sensitive information ).
Even with all of these advantages, there are some disadvantages to the multiple-teacher approach. If there are a lot of teachers, managing all will not be as easy as it was with Mr. Wolowitz only. If the students wouldn’t mind a teacherless day or if the school is in its early days and is still uncertain about its future, hiring more teachers and paying them might not be the best idea. If Mr. Wolowitz can handle all the subjects, getting multiple teachers might complicate the system. Some teachers are interdependent, and because of that, finding out which teacher’s inability is causing the students to fail and finding the root cause is not straightforward. In the case of a microservice where the dependencies could be way complex, debugging the service where the problem originated from could become a nightmare.
You can think of a monolith as a single teacher responsible for all subjects and microservices as one teacher per subject. There are disadvantages and complexities to having multiple teachers. But, like microservices, they come with advantages, which make it all worth it in the right situation.