A pattern language for microservices

pattern  

The beginnings of a pattern language for microservice architectures.

点击这里,访问本系列文章的中文翻译

Click here for Chinese translation of the patterns

Which architecture should you choose for an application?

How to decompose an application into services?

How to maintain data consistency and implement queries?

  • Database per Service - each service has its own private database
  • Shared database - services share a database
  • Saga - use sagas, which a sequences of local transactions, to maintain data consistency across services
  • Command-side replica - maintain a queryable replica of data in a service that implements a command
  • API Composition - implement queries by invoking the services that own the data and performing an in-memory join
  • CQRS - implement queries by maintaining one or more materialized views that can be efficiently queried
  • Domain event - publish an event whenever data changes
  • Event sourcing - persist aggregates as a sequence of events

Transactional messaging

How to publish messages as part of a database transaction?

How to make testing easier?

  • Consumer-driven contract test - a test suite for a service that is written by the developers of another service that consumes it
  • Consumer-side contract test - a test suite for a service client (e.g. another service) that verifies that it can communicate with the service
  • Service component sest - a test suite that tests a service in isolation using test doubles for any services that it invokes

How to deploy an application’s services?

How to handle cross cutting concerns?

  • Microservice chassis - a framework that handles cross-cutting concerns and simplifies the development of services
  • Externalized configuration - externalize all configuration such as database location and credentials
  • Service Template - a template that implements standard cross cutting concerns and is intended to be copied by a developer in order to quickly start developing a new service

Style

Which communication mechanisms do services use to communicate with each other and their external clients?

External API

How do external clients communicate with the services?

Service discovery

How does the client of an RPI-based service discover the network location of a service instance?

Reliability

How to prevent a network or service failure from cascading to other services?

  • Circuit Breaker - invoke a remote service via a proxy that fails immediately when the failure rate of the remote call exceeds a threshold

How to communicate the identity of the requestor to the services that handle the request?

  • Access Token - a token that securely stores information about user that is exchanged between services

How to understand the behavior of an application and troubleshoot problems?

  • Log aggregation - aggregate application logs
  • Application metrics - instrument a service’s code to gather statistics about operations
  • Audit logging - record user activity in a database
  • Distributed tracing - instrument services with code that assigns each external request an unique identifier that is passed between services. Record information (e.g. start time, end time) about the work (e.g. service requests) performed when handling the external request in a centralized service

  • Exception tracking - report all exceptions to a centralized exception tracking service that aggregates and tracks exceptions and notifies developers.

  • Health check API - service API (e.g. HTTP endpoint) that returns the health of the service and is intended to be pinged, for example, by a monitoring service

  • Log deployments and changes

How to implement a UI screen or page that displays data from multiple services?

  • Server-side page fragment composition - build a webpage on the server by composing HTML fragments generated by multiple, business capability/subdomain-specific web applications

  • Client-side UI composition - Build a UI on the client by composing UI fragments rendered by multiple, business capability/subdomain-specific UI components


pattern  


Copyright © 2024 Chris Richardson • All rights reserved • Supported by Kong.

About www.prc.education

www.prc.education is brought to you by Chris Richardson. Experienced software architect, author of POJOs in Action, the creator of the original CloudFoundry.com, and the author of Microservices patterns.

Upcoming public workshops: Microservices and architecting for fast flow

In-person: Berlin and Milan

DevOps and Team topologies are vital for delivering the fast flow of changes that modern businesses need.

But they are insufficient. You also need an application architecture that supports fast, sustainable flow.

Learn more and register for one of my upcoming public workshops in November.

NEED HELP?

I help organizations improve agility and competitiveness through better software architecture.

Learn more about my consulting engagements, and training workshops.

LEARN about microservices

Chris offers numerous other resources for learning the microservice architecture.

Get the book: Microservices Patterns

Read Chris Richardson's book:

Example microservices applications

Want to see an example? Check out Chris Richardson's example applications. See code

Virtual bootcamp: Distributed data patterns in a microservice architecture

My virtual bootcamp, distributed data patterns in a microservice architecture, is now open for enrollment!

It covers the key distributed data management patterns including Saga, API Composition, and CQRS.

It consists of video lectures, code labs, and a weekly ask-me-anything video conference repeated in multiple timezones.

The regular price is $395/person but use coupon CCMHVSFB to sign up for $95 (valid until November 8th, 2024). There are deeper discounts for buying multiple seats.

Learn more

Learn how to create a service template and microservice chassis

Take a look at my Manning LiveProject that teaches you how to develop a service template and microservice chassis.

Signup for the newsletter


BUILD microservices

Ready to start using the microservice architecture?

Consulting services

Engage Chris to create a microservices adoption roadmap and help you define your microservice architecture,


The Eventuate platform

Use the Eventuate.io platform to tackle distributed data management challenges in your microservices architecture.

Eventuate is Chris's latest startup. It makes it easy to use the Saga pattern to manage transactions and the CQRS pattern to implement queries.


Join the microservices google group