1

I am writing a web service API, I have a doubt regarding retry logic in API.

My API calls few other downstream APIs.

Shall I put the retry logic around service calls (downstream APIs) I am making? Or just say to client that 'please retry' and client can have the retry logic?

SIGSTP
  • 1,125
  • 2
  • 9
  • 21

1 Answers1

0

Your API must have a worst scenario approach, so if your API needs other API's in order to work you should take care of the exceptions and timeouts.

One good approach as you mentioned is to implement a retry logic.

Please refer to this question to implement it. A better approach is to implement it with a Fibonacci approach so you do not call other API's in the same interval.

Also there are some libs out there that already implements retrys

Community
  • 1
  • 1
Javier Hertfelder
  • 2,432
  • 4
  • 22
  • 36