Microservices patterns

Communication patterns

  • Communication style: What kind of IPC mechanism should you use?
  • Discovery: How does a client of a service determine the IP address of a service instance so that, for example, it makes an HTTP request?
  • Reliablity: How can you ensure that communication between services is reliable even though services can be unavailable?
  • Transactional messaging: How should you integrate the sending of messages and publishing of events with database transactions that update business data?
  • External API: How do clients of your application communicate with the services?

Patterns for querying data

The other issues with using a database per service is that some queries need to join data that's owned by multiple services

Service deployment patterns

Observability patterns provide insight into application behaviour

  • Health check API: Expose an endpoint that returns the health of the service
  • Log aggregation: Log service activity and write logs into a centralized logging server, which provides searching and alerting.
  • Distributed tracing: Assign each external request a unique ID and trace requests as they flow between services.
  • Exception tracking: Report exceptions to an exception tracking service, which deduplicates exceptions, alerts developers, and tracks the resolution of each exception.
  • Application metrics: Maintain metrics, such as counters and gauges, and expose them to a metrics server.
  • Audit logging: Log user actions.

Patterns for the automated testing of services

  • Consumer-driven contract test: Verify that a service meets the expectations of its clients.
  • Consumer-side contract test: Verify that the client of a service can communicate with the service.
  • Service component test: Test a service in isolation
Last updated on