GuFigueiredo
GuFigueiredo

Reputation: 635

How to deal with exponential call hierarchy in Microservices Architecture?

I have the following call hierarchy in my architecture:

BFF → Microservice A → Microservice B → Anticorruption Layer → Legacy System

In each service above I am using the retry pattern to deal with HTTP resiliency while one service request a resource in another service.

The problem becomes when, if I have a default policy of 3 retries for each request, this becomes exponential. For example, if my AntiCorruptionLayer is down and returning a 504 (Gateway timeout) and my BFF receives one request, it will retry for 3 times, while service A will retry for 9 times and B for 27 times for just one request!

How to deal with this problem? Any tips?

Upvotes: 2

Views: 261

Answers (1)

Mykhailo Kravchenko
Mykhailo Kravchenko

Reputation: 21

One solutions could be:

  • Anticorruption Layer returns 504.
  • Microservice B retries 3 times, and after that returns 500 instead of 504.
  • Don't retry on 500 in Microservice A or BFF.
  • Every service should have Retry policy and Circuit breaker.

Another solutions could be:

  • Anticorruption Layer returns 504.
  • Microservice B retries 3 times, and after that sends 504 back with some header (Retry-Count:3)
  • In parent service don't retry if Retry-Count is more then 3.

Does it make sense?

Upvotes: 0

Related Questions