31.03.2020 Views

NET-Microservices-Architecture-for-Containerized-NET-Applications

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

business microservice composed of several physical services. But ultimately, both patterns -Bounded

Context and microservice- are closely related.

DDD benefits from microservices by getting real boundaries in the form of distributed microservices.

But ideas like not sharing the model between microservices are what you also want in a Bounded

Context.

Additional resources

• Chris Richardson. Pattern: Database per service

https://microservices.io/patterns/data/database-per-service.html

• Martin Fowler. BoundedContext

https://martinfowler.com/bliki/BoundedContext.html

• Martin Fowler. PolyglotPersistence

https://martinfowler.com/bliki/PolyglotPersistence.html

• Alberto Brandolini. Strategic Domain Driven Design with Context Mapping

https://www.infoq.com/articles/ddd-contextmapping

Logical architecture versus physical architecture

It’s useful at this point to stop and discuss the distinction between logical architecture and physical

architecture, and how this applies to the design of microservice-based applications.

To begin, building microservices doesn’t require the use of any specific technology. For instance,

Docker containers aren’t mandatory to create a microservice-based architecture. Those microservices

could also be run as plain processes. Microservices is a logical architecture.

Moreover, even when a microservice could be physically implemented as a single service, process, or

container (for simplicity’s sake, that’s the approach taken in the initial version of eShopOnContainers),

this parity between business microservice and physical service or container isn’t necessarily required in

all cases when you build a large and complex application composed of many dozens or even

hundreds of services.

This is where there’s a difference between an application’s logical architecture and physical

architecture. The logical architecture and logical boundaries of a system do not necessarily map oneto-one

to the physical or deployment architecture. It can happen, but it often doesn’t.

Although you might have identified certain business microservices or Bounded Contexts, it doesn’t

mean that the best way to implement them is always by creating a single service (such as an ASP.NET

Web API) or single Docker container for each business microservice. Having a rule saying each

business microservice has to be implemented using a single service or container is too rigid.

Therefore, a business microservice or Bounded Context is a logical architecture that might coincide (or

not) with physical architecture. The important point is that a business microservice or Bounded

Context must be autonomous by allowing code and state to be independently versioned, deployed,

and scaled.

32 CHAPTER 4 | Architecting container and microservice-based applications

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!