How do you get your services to talk to each other?

Microservices are fun, they allow for the creation of very scalable and efficient architectures. All major platforms take advantage of them because of this. There is no way to have a Netflix or Facebook or Instagram without the help of Microservices.

However, splitting your business logic into smaller units and deploying them in a distributed manner is just step 1. You then have to understand what’s the best way to make them talk to each other. That’s right, Microservices aren’t only meant to be outwards-facing — or in other words, to serve external clients — sometimes they can act as clients to other services within the same architecture.

So how do you make two services talk to each other? The easy answer is to keep using the same API that is presented to the public. For example, if my public-facing API is a REST HTTP API, then by all means, all services will interact with each other through it.

And that is a very valid scenario, but let’s take a look at other ways we can improve on that.

A small sidenote: communication is based on agreed-upon protocols. That’s true for communication between microservices as well as between service and client. One way to ensure protocols are always kept is to share the code that describes them between these decoupled codebases. That could be classes, types, mock data objects, etc. One tool that helps greatly in achieving that is Bit.

Bit source-controls TS/JS modules independently and maintains the dependencies between them, even when they are pushed to separate remote hosting. That enables one updated module to cause a ripple effect of CIs running on all its dependent modules.

#software-architecture #nodejs #microservices #web-development

My Favorite Interservice Communication Patterns for Microservices
1.10 GEEK