Uncoupling via Middleware

Calls in a single program only ever function on the same host at the same time in the same process. Synchronous distributed communication (REST) enables communication between different hosts and different processes at the same time. Asynchronous communication via messaging systems (section 8.4) also enables an uncoupling over time. A system should not wait for the response of an asynchronous process. The system should continue working on other tasks instead of just waiting for a response. Errors that cause one system after another to break down like dominoes are much less likely when using asynchronous communication. The systems are forced to deal with long response times since asynchronous communication often means long response times.

Stability and Microservices

Stability patterns like Bulkheads restrict failures to a unit. Microservices are the obvious choice for a unit. They run on separate virtual machines and are therefore already isolated with regard to most issues. This means that the bulkhead pattern arises very naturally in a microservices-based architecture. Figure 9.5 shows an overview: A microservice using Bulkheads, Circuit Breakers, and Timeouts can safeguard the use of other microservices. The used microservice can additionally implement fail fast. The safeguarding can be implemented via patterns in those parts of a microservice that are responsible for communicating with other microservices. This enables this aspect to be implemented in one area of the code and not distributed across the entire code.

Stability in the Case of Microservices

Figure 9.5 Stability in the Case of Microservices

On a technical level the patterns can be implemented in different ways. For microservices there are the following options:

  • Timeouts are easy to implement. When another system is accessed, an individual thread is started that is terminated after a timeout.
  • • At first glance Circuit Breakers are not very complex and can be developed in your own code. However, any implementation must work under high load and has to offer an interface for operations to enable monitoring. This is not trivial. Therefore, a home-grown implementation is often not sensible.
  • Bulkheads are an inherent feature of microservices since a problem is, in many cases, already limited to just one microservice. For instance, a memory leak will only cause one microservice to fail.
  • Steady State, Fail Fast, Handshaking and Test Harness have to be implemented by each microservice.
  • • Uncoupling via middleware is an option for shared communication of microservices.
< Prev   CONTENTS   Source   Next >