The term “Microservice Architecture” has become popular over the last few years descibe a way of designing large scale software applications as suites of small, independently deployable services. While there’s no precise definition of this style of architecture, there are certain common characteristics around organisation around business capability, automated deployment, intelligence within the endpoints, and decentralized control of languages and data.
The common guiding principles of microservices are:
Small
All services are small, fulfiling a single business function. Ideally each service is developed and operated by a small, agile, autonomous team.
Cohesive
All service implementation is part of fulfilling the single service business function. Anything that is not should be part of a seperate service.
Independent
Services are capable of being deployed independently and generally little or no direct coupling exists between services. Some services may communicate with a number of other services acting as an orchestrator, but in general the number of these in any system should be low. Ideally inter-service communication will be via an indirect method such as a message queue or an Event Broker service.
Stateless
A stateless service handles every request with the information contained only within it. Microservices should generally be stateless and service each request without “remembering” any previous communications from the service client(s).
Further Principles
The above principles can be further extended by the following set:
single responsibility
Each microservice should be responsible for a single specific feature or aggregation of cohesive functionality. The rule to apply this principle is: “Things which change for the same reason belong in a service; Things which change for a different reason belong in other service(s)”.
Domain Driven Design
Domain driven design is an architectural approach aligned with object-oriented thinking. The approach is to design systems to reflect the real world business “domains”. It considers the business domain, and the elements, behaviors and interactions between business domains. For example, in a retail domain, individual microservices can be designed to handle various business functions such as ordering, packaging, dispatching etc.