-
Notifications
You must be signed in to change notification settings - Fork 1
Microservices Architecture
The microservice architecture is an architectural style that structures an application as a set of loosely coupled, services organized around business capabilities.
The goal of the microservice architecture is to accelerate software development by enabling continuous delivery/deployment.
The microservice architecture does this in two ways:
- Simplifies testing and enables components to deployed independently
- Structures the engineering organization as a collection of small (6-10 members), autonomous teams, each of which is responsible for one or more services
These benefits are not automatically guaranteed. Instead, they can only be achieved by the careful functional decomposition of the application into services.
A service must be small enough to be developed by a small team and to be easily tested. A useful guideline from object-oriented design (OOD) is the Single Responsibility Principle (SRP). The SRP defines a responsibility of a class as a reason to change, and states that a class should only have one reason to change. It make sense to apply the SRP to service design as well and design services that are cohesive and implement a small set of strongly related functions.
The application also be decomposed in a way so that most new and changed requirements only affect a single service. That is because changes that affect multiple services requires coordination across multiple teams, which slows down development. Another useful principle from OOD is the Common Closure Principle (CCP), which states that classes that change for the same reason should be in the same package. Perhaps, for instance, two classes implement different aspects of the same business rule. The goal is that when that business rule changes developers, only need to change code in a small number - ideally only one - of packages. This kind of thinking makes sense when designing services since it will help ensure that each change should impact only one service.
When designing a solution with Microservices, there are a series of questions that will need to be addressed:
- How to decompose an application into services?
- How to deploy an application’s services?
- How to handle cross cutting concerns?
- Which communication mechanisms to use?
- How do external clients communicate with the service
- How does a client discover the network location of a service instance?
- How to prevent a network or service failure from cascading to other services?
- How to maintain data consistency and implement queries?
- How to understand the behavior of an application and troubleshoot problems?
- How to make testing easier?
- How to implement a UI screen or page that displays data from multiple services?
Before you begin, you must start somewhere. It starts with the Business Challenge. What problem or opportunity are you trying to address. From there you will want to decompose the application into services. See below for more details and the appropriate design pattern(s) to help answer these questions.
- Decomposition
- How to decompose an application into services?
- DDD
- How to decompose an application into services?
- Deployment
- How are services packaged and deployed?
- Multiple service instances per host
- Service instance per host
- Service instance per container
- Serverless
- Service deployment pattern
- Kubernetes
- PaaS
- How are services packaged and deployed?
- Cross Cutting Concerns
- Microservice Chasis
- Handles cross-cutting concerns
- How to enable a service to run in multiple environments without modification?
- Externalized Configuration
- Docker compose
- Externalized Configuration
- Microservice Chasis
- Communication Style
- RPI
- Use RPI for inter-service communication. The client uses a request/reply-based protocol to make requests to a service.
- Messaging
- Use asynchronous messaging for inter-service communication. Services communicating by exchanging messages over messaging channels.
- Domain-Specific Protocol
- SMTP, RTMP, HLM, HDS
- RPI
- External API
- How do the clients of a Microservices-based application access the individual services?
- API Gateway
- Back-end for Front-End
- How do the clients of a Microservices-based application access the individual services?
- Transactional Messaging
- How to reliably/atomically update the database and publish messages/events.
- Transactional outbox pattern
- How to publish messages/events into the outbox in the database to the message broker?
- Transaction log tailing
- Polling publisher
- How to reliably/atomically update the database and publish messages/events.
- Service Discovery
- How does the client of a service - the API gateway or another service - discover the location of a service instance?
- Client-side service discovery
- Server-side discovery
- How do clients of a service (in the case of Client-side discovery) and/or routers (in the case of Server-side discovery) know about the available instances of a service?
- Service Registry
- How are service instances registered with and unregistered from the service registry?
- Self Registration
- How are service instances registered with and unregistered from the service registry?
- 3rd party registration
- How does the client of a service - the API gateway or another service - discover the location of a service instance?
- Reliability
- How to prevent a network or service failure from cascading to other services?
- Circuit Breaker
- How to prevent a network or service failure from cascading to other services?
- Data Management
- What is the database architecture in a micro service application?
- Database per service
- Shared database
- How to maintain data consistency across services?
- Saga pattern
- How to implement queries in a microservice architecture?
- API composition
- How to implement a query that retrieves data from multiple services in a microservices architecture?
- CQRS
- How to reliably/atomically update the database and publish messages/events
- Event Sourcing
- Application publishes events
- What is the database architecture in a micro service application?
- Security
- How to communicate the identify of the requestor to the services that handle the request?
- Access Token
- How to communicate the identify of the requestor to the services that handle the request?
- Testing
- How to easily test a service?
- Service component test
- Consumer-driven contract test
- Consumer-side contract test
- How to easily test a service?
- Observability
- How to understand the behavior of an application and troubleshoot problems?
- Log aggregation
- Application metrics
- Audit logging
- Distributed tracing
- Exception tracking
- Health check API
- Log deployments and changes
- How to understand the behavior of an application and troubleshoot problems?
- UI Patterns
- How to implement a UI screen or page that displays data from multiple services?
- Server-Side page fragment composition
- Client-side UI composition
- How to implement a UI screen or page that displays data from multiple services?