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:
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:
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.
Recommended by LinkedIn
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.
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
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.
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.
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.