【Design Pattern】Microservices - Application Metrics Pattern

Posted by 西维蜀黍 on 2021-06-29, Last Modified on 2022-12-10

Context

You have applied the Microservice architecture pattern.

Problem

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

Forces

  • Any solution should have minimal runtime overhead

Solution

Instrument a service to gather statistics about individual operations. Aggregate metrics in centralized metrics service, which provides reporting and alerting. There are two models for aggregating metrics:

  • push - the service pushes metrics to the metrics service
  • pull - the metrics services pulls metrics from the service

Examples

Resulting context

This pattern has the following benefits:

  • It provides deep insight into application behavior

This pattern has the following drawbacks:

  • Metrics code is intertwined with business logic making it more complicated

This pattern has the following issues:

  • Aggregating metrics can require significant infrastructure

Reference