SOLID in microservices design
Picture from freepik - www.freepik.es

SOLID in microservices design

I know. SOLID are design principles for software development so... What that hell are you saying about SOLID in microservices Design?

In a few lines, let me explode this idea.

What is SOLID

Very brief explanation. SOLID is an acronym for the following design principles (develop by Robert C. Martin, in beginning 2000), something like "best practices" to have in mind during software development:

  • Single responsability: Your class or method should have only one responsability.
  • Open-Close: Your entity should be open for extension, but closed for modification. New features must be developed in a new entity derived from entity.
  • Liskov substitution: Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
  • Interface segregation: Many client-specific interfaces are better than one general-purpose interface.
  • Dependency inversion: Depend upon abstractions, not concretions.

Microservices patterns

There is a difference between patterns and principles. Pattern is a mechanism or a model that exposes how to implement a development, organization or execution during an artifact design (in programming, architecture and many other disciplines).

Principle is a best practice, an idea of how you can implement a solution during your design stage.

There are a lot of patterns for microservices design. Just to enumeration a few of them grouped:

  • Application architecture patterns
  • Decomposition
  • Refactoring to microservices
  • Data management
  • Transactional messaging
  • Deployment

You can check more in deep about microservices patterns on this link

Moving into principles

Let's move the principles from SOLID into microservices design...

Single responsability

In the same manner than in programming, microservice should be an "specialist" or responsible of a single feature. This feature can be around business point of view, for example a microservice responsible for Client Personal Info; or from an asset of technical point of view, for example consume/produce events in a messaging system.

No alt text provided for this image

Open-Close

We can follow in that principle the same idea than in software development. All new features related to the same asset should to be added in a new microservice instead of extend the responsability of an existing one. For example, from a business point of view if you want to design a microservice for Client Banking Account Info do not extend the current Client Personal Info microservice.

No alt text provided for this image

Liskov substitution

In that way if you design a new microservice that needs to invoke some others to request data or information, it should be able to execute the call but isolated from changes into this invoked microservices. This can be solved with an orchestrator or a parent API to isolate derived microservices

No alt text provided for this image

Interface segregation

During design stage of microservices have in mind the idea that segregate your microservices is the best way to reduce your bugs scope and decrease the complexity of your microservice processes. A good example for this is API led connectivity design that segregate in several layers to consume/orchestrate specific microservices only when necessary.

No alt text provided for this image

Dependency inversion

Designing microservices also includes how to orchestrate/choreography different requests between microservices. The idea in that case is to isolate or not consider a direct call to microservices that maybe has other implementations that we are not interesting to invoke (or to know). The best approach for this scenario is to separate in functional or process layers that knows exactly which microservices to invoke or route.

No alt text provided for this image

Conclusion

Design microservices is not an easy task. It is necessary to have in mind several aspects like business/event oriented services, patterns, layers & microservices responsability...

Apply best practices is always a good starting-point when design is in progress, do not lose perspective on other very importante features like performance, resilience, decoupled and changes.

Final appointment... At least, apply SOLID in microservices software development.

To view or add a comment, sign in

More articles by Pedro Gracia Bernal

  • How I try to (metaphorical) kill a Frontend developer using MCP

    Following my previous article about MCP and how it works, now it is time to have a practical example to check if really…

  • MCP... API replacement?

    Well, during last days I am thinking around how MCP can help, in terms of architecture, to our interfaces and always…

  • Chaos Architecture

    Recently I have been on holidays with an amazing trip to Egypt. When I was younger it was one of my dreams, to have in…

    4 Comments
  • Payments: Join the dots

    This is a representation from my point of view based on different payments concepts. I have divided in the following:…

  • API specs: PaC approach for GaC

    No, I am not going crazy, just chasing cars around my head..

  • Where AI meets with Solution Architects

    It is obvious that AI has come to stay. Regarding to IT roles, it is changing a lot the way that we are going to code…

    2 Comments
  • JSONata java libraries benchmark

    Recently I have been requested to provide a solution regarding to create dynamic rules/actions based on specific values…

  • Solution Architect frameworks, modelling & tools

    After some years of experience, I have recollected several frameworks, modelling & tools that really helps me to…

  • Payments architecture: design a serverless processing

    In order to build an accurate architecture for payment, first it is mandatory to have the process in mind. I did this…

  • Payments architecture: understanding process

    From last months I am involved as Architect for Payments department in my company. For me, a great challenge and…

    5 Comments

Others also viewed

Explore content categories