Microservices design principles establish some standard practices for planning, developing, and implementing a distributed architecture for your application. Read about some of the most common characteristics of design principles, its examples, and implementations carried out by various companies worldwide.
2. Revisiting the Old Hat of Design Principles
Single Responsibility
Open/Closed
Liskov Substitution
Interface Segregation
Dependency Inversion
In the early 2000s, Robert C Martin conceived the first five
principles for Object-Oriented design, which would act as
a guideline for implementing segregated business
services.
Later, Michael Feathers created the acronym SOLID, as
we know it today.
3. The Ideal
Microservices
Design Principles
Here are some of the ideal and best
microservices design principles. You
will find its implementation strategies,
to set a guideline for best practices
while designing a microservices
architecture in the next slides.
Single Concern or Responsibility
Interface Segregation
Loose Coupling
Deployability
Event-Driven Microservices
Autonomy
4. The single concern principle goes hand-in-hand with the microservices architecture style, which states that
each deployment unit must contain one or a few highly cohesive services.
This makes the microservices architecture easy to maintain and scale with evolving business requirements
and a growing tech stack.
Implementation:
By employing the single responsibility principle, GojekTech got rid of the authentication token from their
new internal chat services and added a separate database for the service, and established an
asynchronous communication for quick channel creation.
This improved their application availability and enabled strong data consistency. Eventually, their chat
service – ‘Icebreaker’ – was doing the single function it was meant to in the first place.
Single Concern or Responsibility for
Improved Task Distribution
5. With different business domains, modules, and services segregated across the microservices architecture,
there is often a mass of frontend (client programs) tied to one logic.
The goal is to ensure that each type of frontend is attached to the service contracts that would best serve
its requirements.
Implementation:
An API gateway is the best way to go around implementing the principle.
The advantage of using an API gateway is that it can handle message format transformation, protocol
bridging, message structure transformation, routing, and much more.
Dynamic Performance with Interface
Segregation
6. Intercommunication and interaction between the service users and the services determine the functioning
of a microservices architecture.
Tightly coupled services always run at the risk of affecting the entire application, even if it’s a minor
change or security issue like memory leaks and database connectivity issues.
Implementation:
The Alibaba Cloud Research and Development Teams utilized REST to make their overall program
architecture loosely coupled.
As a result, managing their microservice became easy and quick with uninterrupted and distributed
services.
Loose Coupling for Seamless
Communication between Services
7. The essence of microservices architecture lies in its autonomy – service autonomy, engineer’s autonomy
over services, and high availability for consumers.
It dictates the parameters for scalability and enhances reliability for an extended period of time, even after
services or business capabilities change.
Implementation:
Structure small organizational teams around one service (two pizza teams).
Maintain a decentralized database with every service having its own data with no shared connections.
Implement the circuit breaker pattern to make your service failure-proof.
Autonomy for Improved Scalability
8. It is well-encapsulated and has a boundary that separates it from its environment.
By this logic, it also means that all logic and data of a single service must be encapsulated in a single unit
– deployed and managed independently.
Implementation:
Automate your deployment processes and employ CI/CD methodologies for a better time to market.
Utilize containerization and container orchestration with platforms like Docker and Kubernetes.
Employ service mesh for monitoring, authentication, circuit breaker, etc., to command over the
communication services.
Discreet Deployability for Error-Free
Services
9. In this architecture, event triggers are sent across the decoupled services for communicating with multiple
services simultaneously.
In addition, instead of using synchronous call, which often runs the risk of blocking a system process,
asynchronous communication is utilized to keep the chain running.
Implementation:
Utilize REST along with EDA for better communication and transactions.
Choose a messaging framework – Message processing, Stream processing, or a unique combination of
both offered by Pulsar, NATS, Kafka, etc.
Utilize CQRS to combat the issues of event sourcing.
A Robust Event-Driven Microservices
Architecture
10. That's a wrap!
The journey is all worth it when you have a guiding principle to help
you construct the robust, efficient, secure, and reliable
microservices architecture.
It doesn’t matter if you are starting from scratch or in the process of
transitioning, the principles aid engineers in making a fully
conscious decision about their architecture or how to go about it.