Microservice Principles: Smart Endpoints and Dumb Pipes

Types of Microservice Communication

There are two primary forms of communication between microservices that need to be solved for:

  • Request-Response: One service invokes another service by making an explicit request, usually to store or retrieve data. The service then expects a response: either a resource or an acknowledgement.
  • Observer: Event based, implicit invocation where one service publishes an event and one or more observers that were watching for that event respond to it by running logic asynchronously, outside the awareness of the producer of the event.
Diagram of user signup flow for a social media application

Anti-pattern: Centralized Service Bus

Building a complex centralized communication bus that runs logic to route and manipulate messages is an architectural pitfall that tends to cause problems later on. Instead, microservices favor a decentralized approach: services use dumb pipes to get messages from one endpoint to another endpoint.

Request-Response Model

Request-response communication between microservices is used anywhere in which one service sends a request and expects either a resource or acknowledgment response to be returned.

Consul maintains a DNS record that resolves to the different backend microservice instances so that one service can talk directly to another service, with no load balancer in-between.

Observer Model

Observer communication is critical to scaling out microservices. Not every communication requires a response or an acknowledgement. In fact, in many workflows there are at least a few pieces of logic that should be fully asynchronous and nonblocking.

Conclusion

The microservice principle of smart endpoints and dumb pipes is easy to understand when you embrace the concept of decentralization of architecture and logic. Despite using “dumb pipes” microservices can still implement essential messaging primitives without the need for a centralized service bus. Instead, microservices should make use of the broad ecosystem of frameworks that exist as dumb pipes for both request-response and observer communications.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nathan Peck

Nathan Peck

4.1K Followers

Developer Advocate for Container Services at Amazon Web Services