pattern  

A pattern language for microservices

The beginnings of a pattern language for microservice architectures.

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

Click here for Chinese translation of the patterns

Application architecture patterns

Which architecture should you choose for an application?

Decomposition

How to decompose an application into services?

Refactoring to microservicesnew

Data management

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?

Testing

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

Deployment patterns

How to deploy an application’s services?

Cross cutting concerns

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

Communication patterns

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

Security

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

Observability

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

UI patterns

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 Microservices.io

Microservices.io 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.

Chris helps organizations improve agility and competitiveness through better software architecture. Learn more about his consulting engagements, and training workshops.

PREMIUM CONTENT

Premium content and office hours is now available for paid subscribers at premium.microservices.io.

MICROSERVICES WORKSHOPS

Chris teaches comprehensive workshops for architects and developers that will enable your organization use microservices effectively.

Avoid the pitfalls of adopting microservices and learn essential topics, such as service decomposition and design and how to refactor a monolith to microservices.

Learn more

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

Remote consulting session

Got a specific microservice architecture-related question? For example:

  • Wondering whether your organization should adopt microservices?
  • Want to know how to migrate your monolith to microservices?
  • Facing a tricky microservice architecture design problem?

Consider signing up for a two hour, highly focussed, consulting session.

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 ILFJODYS to sign up for $95 (valid until March 12, 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.

ASSESS your architecture

Assess your application's microservice architecture and identify what needs to be improved.

Consulting services

Engage Chris to conduct an architectural assessment.



Join the microservices google group

Topics

Note: tagging is work-in-process

DDD   ·  GitOps   ·  Microservices adoption   ·  ancient lore   ·  anti-patterns   ·  application api   ·  application architecture   ·  architecting   ·  architecture   ·  architecture documentation   ·  assemblage   ·  beer   ·  books   ·  containers   ·  dark energy and dark matter   ·  deployment   ·  deployment pipeline   ·  design-time coupling   ·  developer experience   ·  development   ·  devops   ·  docker   ·  eventuate platform   ·  generative AI   ·  glossary   ·  health   ·  hexagonal architecture   ·  implementing commands   ·  implementing queries   ·  inter-service communication   ·  kubernetes   ·  loose coupling   ·  microservice architecture   ·  microservice chassis   ·  microservices adoption   ·  microservices rules   ·  microservicesio updates   ·  modular monolith   ·  multi-architecture docker images   ·  observability   ·  pattern   ·  refactoring to microservices   ·  resilience   ·  sagas   ·  security   ·  service api   ·  service architecture   ·  service blueprint   ·  service collaboration   ·  service design   ·  service discovery   ·  service granularity   ·  service template   ·  software delivery metrics   ·  success triangle   ·  tacos   ·  team topologies   ·  testing   ·  transaction management   ·  transactional messaging

All content