• Skip to main content
  • Skip to primary sidebar
BMA

BeMyAficionado

Inspire Affection

Principles of Microservices – Decentralize All The Things

September 6, 2020 by varunshrivastava Leave a Comment

Decentralization is a tricky concept. There are many facets to it. In this article, I want to talk about decentralizing everything in a way it doesn’t hurt you or your organization.

When I think about decentralization the first thing that comes to my mind is Self Service.

Table of Contents

    • Self Service
    • Owner-Operator Model
    • Internal Open Source Model
    • Orchestration VS Choreography
      • Orchestration Approach
      • Choreography Approach
  • Conclusion

Self Service

Self-service is very important in a truly decentralized system. The people working on any service should not have to wait for any permissions or resources in order to do stuff. They should be free to work on their own.

This leads us to the Owner-Operator model.

Owner-Operator Model

This model is all about giving ownership to the team completely. In this, the team not only owns the service completely but also responsible for its evolution.

Make the team responsible for their decisions. Give them the power but also make them responsible for it.

With Great Power Comes Great Responsibility

There won’t be any other bug fixing team or deployment team or operations team. The team will own up to everything and will take responsibility for each and every part of the service.

This takes us to another connected concept of Internal Open Source Model.

Internal Open Source Model

Have you worked on any open source project before?

In that, you write your own little piece of code and raise a pull request to the owner asking them to include it. But the final decision of including your code lies with the owner of that project.

The same model should be implemented within the organization.

If one team requires something from the other team and they know exactly what they want. They can always write out that functionality and send a pull-request to the owning team.

But this is it. Their job ends here.

It is now the other team’s responsibility whether to take the code or propose an alternative or write something else. This way there is a clear boundary between different teams.

This is one way to start thinking about decentralizing the entire system.

Orchestration VS Choreography

This is another concept that needs to be looked at while designing microservices.

Let me explain you by giving an example of both the design models.

Suppose you have to create a Customer Enrollment flow. In this Customer Enrolls himself.

Once the customer is enrolled, a series of steps are performed. The Customer Record is created in the database. Loyalty account is created. A welcome pack is dispatched for the customer. And a welcome email is sent at the end.

Customer Enrollment
Customer Enrollment

This functionality can be implemented in a couple of different ways.

Orchestration Approach

Let’s talk about the orchestration approach first.

As you can see that the above steps are a simple flow. So, in the orchestration model, a single service will own the responsibility for executing the entire flow.

This service will be at the centre and call different services at different stages.

This is the most widely adopted model that can be easily found in any organization. There are many pros to this approach as well.

Identifying the bug is fairly easy. You will know which part of your service is broken and then you can fix it at the source. Since all the business flows are enclosed in a single place, understanding of the system is pretty straightforward. Just by looking at the code, one can understand what is happening.

service orchestration approach

But these pros always have some cons.

In this model, one service acts like a God service with all the powers. It controls the flow of every other service. Sure it helps to decentralize different services but itself becomes a centralized authority telling other services what to do. This God class drains the responsibility from other services in such a way that they end up becoming just the wrapper over the database (simple data accessors).

All the logic resides with the God service. And this is not exactly what you would want in a decentralized system.

Decentralization means each and every component of the system have the same authority, same power. They should share equal responsibility and control.

Choreography Approach

Choreography design avoids the formation of God Services.

This is achieved by introducing some kind of message broker for events in between which decouples the tight coupling between different services.

In this approach, every component is aware of its own responsibility. They know their job and no central authority is required to tell them what to do.

The design for this will be something like the below image.

Here the Customer service only responsibility is to raise an event that customer has been created. Other services will be listening to this event and will start processing.

event driven choreography

As you can see there is no central authority in this model. Every service is responsible for performing its own task. This provides good cohesion and loose coupling. However, there is one downside to this approach as well. The debugging is much harder.

Since every service is working on its own, its defect would take much longer to be identified. Let’s say Loyalty and whitemail worked fine but there was no email sent to the customer. In this case, until and unless customer complaints about the issue, nobody will know of this issue.

Of course, we can have external monitoring tools but that is the extra we have to do in order to make sure that all the services are working as they are supposed to. And these tools are expensive and requires additional maintenance.

For instance, we can configure the Splunk logs to look for the opening & closing of “certain text” and make sure those openings are being closed. And whenever it doesn’t found the required closing, it raises the alerts.

Conclusion

As we saw that decentralization is a tricky concept but it can be done by following the steps mentioned in this article.

I’m sure these steps are not applicable for all directly but the goals should be the same. It takes time to change the concrete ideas and adopt new ones.

So just to summarize the topics we discussed. You should always allow teams to be self-serviceable. Follow the owner-operator model for better control and responsibility. Use an internal opensource model to maintain control and authority over the service code. And last but not least choose between Orchestration and Choreography wisely. Both approaches are equally good but depend on the problem you are trying to solve.

I hope you enjoyed the article. Let me know in the comments.

Related

Filed Under: Programming Tagged With: decentralization, internal opensource model, microservices, orchestration vs choreography, owner-operator model, principles of microservices, self service

Primary Sidebar

Subscribe to Blog via Email

Do you enjoy the content? Feel free to leave your email with me to receive new content straight to your inbox. I'm an engineer, you can trust me :)

Join 874 other subscribers

Latest Podcasts

Recent Posts

  • Is The Cosmos a Vast Computation?
  • Building Semantic Search for E-commerce Using Product Embeddings and OpenSearch
  • Leader Election with ZooKeeper: Simplifying Distributed Systems Management
  • AWS Serverless Event Driven Data Ingestion from Multiple and Diverse Sources
  • A Step-by-Step Guide to Deploy a Static Website with CloudFront and S3 Using CDK Behind A Custom Domain

Recent Comments

  • Varun Shrivastava on Deploy Lambda Function and API Gateway With Terraform
  • Vaibhav Shrivastava on Deploy Lambda Function and API Gateway With Terraform
  • Varun Shrivastava on Should Girls Wear Short Clothes?
  • D on Should Girls Wear Short Clothes?
  • disqus_X5PikVsRAg on Basic Calculator Leetcode Problem Using Object-Oriented Programming In Java

Categories

  • Blogging
  • Cooking
  • Fashion
  • Finance & Money
  • Programming
  • Reviews
  • Software Quality Assurance
  • Technology
  • Travelling
  • Tutorials
  • Web Hosting
  • Wordpress N SEO

Archives

  • November 2024
  • September 2024
  • July 2024
  • April 2024
  • February 2024
  • November 2023
  • June 2023
  • May 2023
  • April 2023
  • August 2022
  • May 2022
  • April 2022
  • February 2022
  • January 2022
  • November 2021
  • September 2021
  • August 2021
  • June 2021
  • May 2021
  • April 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • February 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • January 2019
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016

Tags

Affordable Hosting (4) algorithms (4) amazon (3) aoc-2020 (7) believe in yourself (4) best (4) database (4) earn money blogging (5) education (4) elementary sorting algorithms (4) experience (3) fashion (4) finance (6) Financial Freedom (7) food (7) friends (3) goals (5) google (5) india (10) indian cuisine (5) indian education system (4) java (16) life (16) life changing (4) love (4) make money (3) microservices (9) motivation (4) oops (4) podcast (6) poor education system (4) principles of microservices (5) problem-solving (7) programmer (5) programming (28) python (5) reality (3) seo (6) spring (3) success (10) success factor (4) technology (4) top 5 (7) typescript (3) wordpress (7)

Copyright © 2025 · Be My Aficionado · WordPress · Log in

Go to mobile version