西维蜀黍

【Design Pattern】Concurrency - Monitor Object Pattern

MONITOR OBJECT

Generally, Monitor Object is a pattern that controls the concurrent access of a method in an object. If there are some concurrent threads calling a method at the same time, only one thread can execute this method.

  ...


【Design Pattern】Concurrency - Double-checked Locking Pattern

Introduction

This pattern reduces the number of lock acquisitions by simply checking the locking condition beforehand. As a result of this, there’s usually a performance boost.

  ...


【Design Pattern】Concurrency Pattern

  ...


【Design Pattern】Microservices - Health Check Pattern

Context

Sometimes a service instance can be incapable of handling requests yet still be running. For example, it might have ran out of database connections. When this occurs, the monitoring system should generate a alert. Also, the load balancer or service registry should not route requests to the failed service instance.

  ...


【Design Pattern】Microservices - Circuit Breaker Pattern

Background

In Electrical or Electornics domain, a circuit breaker is an automatically operated electrical switch designed to protect an electrical circuit. Its basic function is to interrupt current flow after a fault is detected. It can then be reset to resume normal operation after the fault is solved.

Similarly to protect our microservices from an excess of requests, it’s better to interrupt communication between the front-end and the back-end as soon as a recurring fault has been detected in the back-end.

In his excellent book Release It, Michael Nygard popularized the Circuit Breaker pattern to prevent this kind of catastrophic cascade.

  ...