Essentials of Microservices

1. Decomposing application into Services :

  • Services are loosely coupled
  • Teams that work on one or more services stay autonomous with minimal collaboration with other teams
  • Each Service is small enough to be maintained/developed by a team
  • Services must conform to the Common Closure Principle — things that change together should be packaged together

Decompose by Business capability

  • Identifying Business Capabilities — which is done by understanding the organization’s purpose, structure & business processes
  • Define serviceseach identified business capabilities or a group of them could be mapped to a service

Decompose by Sub-domain

2. Communication between services :

  • Synchronous: HTTP is synchronous, meaning the client sends a request & waits for a response irrespective of code execution on the client (sync or async) which clearly means that client code can only continue its task when it receives the HTTP server response. REST is a popular architectural style
  • Asynchronous: This protocol uses Messaging-based communication. This is the most popular choice to make the integration loosely coupled and asynchronous, also make our application resilient and scalable. We usually use a message broker to manage and process the message sent by the producer and it can be persisted if required; the message broker will guarantee message delivery to the Consumer. This makes the communication asynchronous. There are two options one being Point-to-Point & the other Publisher-Subscriber. Apache Kafka, RabbitMQ, ZeroMQ are few examples
  • Use REST For communication between browser & your service or provide public API
  • For communication between internal services try to model your processes using messages, if not possible then choose gRPC or Event/Message Driven mechanism
  • When dealing with high volumes of messages via HTTP or If you find latency or network saturation to be any sort of bottleneck, consider adopting RPC

3. Data management :

The Data-per-Service pattern

The Saga pattern

The CQRS pattern

Additional Resources and Tutorials on Microservices

--

--

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