63
CHAPTER 3 | Architecting container and microservice-based applications
•
Mauro Servienti. The secret of better UI composition
https://particular.net/blog/secret-of-better-ui-composition
•
Viktor Farcic. Including Front-End Web Components Into Microservices
https://technologyconversations.com/2015/08/09/including-front-end-web-components-into-
microservices/
•
Managing Frontend in the Microservices Architecture
https://allegro.tech/2016/03/Managing-Frontend-in-the-microservices-architecture.html
Resiliency and high availability in microservices
Dealing with unexpected failures is one of the hardest problems
to solve, especially in a distributed
system. Much of the code that developers write involves handling exceptions, and this is also where
the most time is spent in testing. The problem is more involved than writing code to handle failures.
What happens when the machine where the microservice is running fails? Not only do you need to
detect this microservice failure (a hard problem on its own), but you also need something to restart
your microservice.
A microservice needs to be resilient to failures and to be able to restart often on another machine for
availability. This resiliency also comes down to the state that was saved on behalf of the microservice,
where the microservice can recover
this state from, and whether the microservice can restart
successfully. In other words, there needs to be resiliency in the compute capability (the process can
restart at any time) as well as resilience in the state or data (no data loss,
and the data remains
consistent).
The problems of resiliency are compounded during other scenarios, such as when failures occur
during an application upgrade. The microservice, working with
the deployment system, needs to
determine whether it can continue to move forward to the newer version or instead roll back to a
previous version to maintain a consistent state. Questions such as whether enough machines are
available to keep moving forward and how to recover previous versions of the microservice need to
be considered. This approach requires the microservice to emit health information so that the overall
application and orchestrator can make these decisions.
In
addition, resiliency is related to how cloud-based systems must behave. As mentioned, a cloud-
based system must embrace failures and must try to automatically recover from them.
For instance, in
case of network or container failures, client apps or client services must have a strategy to retry
sending messages
or to retry requests, since in many cases failures in the cloud are partial. The
Implementing Resilient Applications
section in this guide addresses how to handle partial failure. It
describes techniques like retries with exponential backoff or the Circuit Breaker pattern in .NET by
using libraries like
Polly
, which offers a large variety of policies to handle this subject.
Dostları ilə paylaş: