Choosing an architecture
What should the application deployment architecture be? The specifications for the application, along
with the development context, strongly suggest that you should architect the application by
decomposing it into autonomous subsystems in the form of collaborating microservices and
containers, where a microservice is a container.
95
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
In this approach, each service (container) implements a set of cohesive and narrowly related functions.
For example, an application might consist of services such as the catalog service, ordering service,
basket service, user profile service, etc.
Microservices communicate using protocols such as HTTP (REST), but also asynchronously (for
example, using AMQP) whenever possible, especially when propagating updates with integration
events.
Microservices are developed and deployed as containers independently of one another. This approach
means that a development team can be developing and deploying a certain microservice without
impacting other subsystems.
Each microservice has its own database, allowing it to be fully decoupled from other microservices.
When necessary, consistency between databases from different microservices is achieved using
application-level integration events (through a logical event bus), as handled in Command and Query
Responsibility Segregation (CQRS). Because of that, the business constraints must embrace eventual
consistency between the multiple microservices and related databases.
eShopOnContainers: A reference application for .NET and microservices deployed
using containers
So that you can focus on the architecture and technologies instead of thinking about a hypothetical
business domain that you might not know, we have selected a well-known business domain
—
namely,
a simplified e-commerce (e-shop) application that presents a catalog of products, takes orders from
customers, verifies inventory, and performs other business functions. This container-based application
source code is available in the
eShopOnContainers
GitHub repo.
The application consists of multiple subsystems, including several store UI front ends (a Web
application and a native mobile app), along with the back-end microservices and containers for all the
required server-side operations with several API Gateways as consolidated entry points to the internal
microservices. Figure 6-1 shows the architecture of the reference application.
96
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
Figure 6-1. The eShopOnContainers reference application architecture for development environment
The above diagram shows that Mobile and SPA clients communicate to single API gateway endpoints,
that then communicate to microservices. Traditional web clients communicate to MVC microservice,
that communicates to microservices through the API gateway.
Dostları ilə paylaş: |