Chapter 8. Fault Tolerance

In this chapter, you’ll learn why you need to embrace failures in microservice architectures because this is something that will happen more often than not. One of the reasons this happens is because microservices architecture heavily relies on the network to function, and the network is a critical part that might not always be available (network down, saturation of the wire, change on the topology, update of the downstream service, etc.).

For this reason, it is important to build services that are fault-tolerant to any kind of problem and to provide graceful solutions instead of just propagating the error.

This chapter will include recipes for the following tasks:

  • Implement different resilient strategies

  • Provide some fallback logic in case there is an error

  • Correctly configure fault-tolerance parameters

8.1 Implementing Automatic Retries


If there are errors, you want to execute automatic retries in order to try to recover from the failure.


MicroProfile Fault Tolerance specification provides a way to implement automatic retries on any CDI element, including CDI beans and the MicroProfile REST Client.

One can implement several strategies to protect against failures and, in the worst cases, provide some default logic instead of a failure. Suppose you have a service that suggests books depending on reader preference. If this service is down, instead of failing, you could cache a list of best-selling books so that at least you ...

Get Quarkus Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.