Best practices that make microservices integration easy

850 views Designing μ-services

Running Microservices in isolation does not make any sense; it is natural for them to work together and solve a bigger problem. This would require each microservice to expose a well-defined API interface simplifying others to talk to it.

The following are the best practices that we should follow that would make interfacing and integration easy.

Forward and Backward Compatability

While rolling out any changes in a microservice, we need to ensure they are both forward and backward compatible. If not, it would break the consumers or interfacing microservices.

Three key places where we need to be extra careful are

  • while changing the database schema
  • while changing the API response body
  • while changing the message format in async communication

We can ensure forward and backward compatibility if we

  • never abruptly delete any column/attribute
  • never abruptly change the type of the column/attribute

We should always roll out breaking changes in phases ensuring the dependent services remain unaffected.

Make APIs tech-agnostic

Tech evolves quickly in the world of software engineering, and hence we would always feel like using the new shiny thing available. While having that urge, we should always ensure we are not picking the technology that would induce tight coupling.

For example, we should not pick a framework that would require the interfacing services to be written in a particular language or require them to use a specific tech stack. This would take away autonomity from the interfacing services as we are dictating which stack to use.

Dead simple consumption

Microservices are built to interact with other services and get things done. So, the core focus should be to make things super simple for anyone to integrate.

It does not matter how good your LLD is if the API interface is hard to integrate. Be consumer-centric while desinging the interface of a microservice and ensure you have

  • simple API
  • simple data format
  • use common protocols

Hide internal implementation details

Never let other microservice learn about the internal implementation detail of your service. If they interact using internal details this would create a tight coupling between the two services.

Internal details could be

  • broker for internal communication
  • building dependency on transitive dependencies
  • allowing directly connecting to the private database

It is always safe to hide the internal implementation details and expose a strict interface to interact with the service. The interface could be REST, gRPC, or anything that your org uses.

Arpit Bhayani

Arpit's Newsletter

CS newsletter for the curious engineers

❤️ by 17000+ readers

If you like what you read subscribe you can always subscribe to my newsletter and get the post delivered straight to your inbox. I write essays on various engineering topics and share it through my weekly newsletter.

Other essays that you might like

BFF - Backend for Frontend - Pattern in Microservices

2225 views 114 likes 2022-07-04

As your application evolves, supporting multiple types of clients like Desktop, Mobile apps, etc becomes tricky. The bac...

Best practices that make microservices integration easy

850 views 50 likes 2022-06-27

Running microservices in isolation does not make any sense. To get something done, multiple microservices need to talk t...

Things to remember while building Microservices

856 views 35 likes 2022-06-20

An engineer working on Microservices should not only just focus on engineering; there are so many other aspects to look ...

Why should we have a standard way of building Microservices?

631 views 27 likes 2022-06-17

We all love creating microservices, but what if every team creates its own microservice uniquely and uses its own conven...

Be a better engineer

A set of courses designed to make you a better engineer and excel at your career; no-fluff, pure engineering.

System Design Masterclass

A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.

Enrolled by 700+ learners

Details →

Designing Microservices

A free course to help you understand Microservices and their high-level patterns in depth.

Enrolled by 17+ learners

Details →

GitHub Outage Dissections

A free course to help you learn core engineering from outages that happened at GitHub.

Enrolled by 67+ learners

Details →

Hash Table Internals

A free course to help you learn core engineering from outages that happened at GitHub.

Enrolled by 25+ learners

Details →

BitTorrent Internals

A free course to help you understand the algorithms and strategies that power P2P networks and BitTorrent.

Enrolled by 42+ learners

Details →

Topics I talk about

Being a passionate engineer, I love to talk about a wide range of topics, but these are my personal favourites.

Arpit's Newsletter read by 17000+ engineers

🔥 Thrice a week, in your inbox, an essay about system design, distributed systems, microservices, programming languages internals, or a deep dive on some super-clever algorithm, or just a few tips on building highly scalable distributed systems.

  • v12.4.4
  • © Arpit Bhayani, 2022

Powered by this tech stack.