0

I am using spring retry in my application, it works fine. however, i am just concerning about if it will cause the performance issue if there are huge volume of retry

say one of the downstream service is down, and before it come back up, there are 1 million requests come in, then it will eat up all the resource for the service to do the normal operation.

is there any solution for this?

user2501711
  • 461
  • 7
  • 16

2 Answers2

0

When millions of requests are expected in short time, spring-retry @CircuitBreaker can help to stop calling downstream system and will reduce performance impact.

   @CircuitBreaker(value = {RunTimeException.class},
            maxAttempts =  2,
            openTimeout = 2000L ,
            resetTimeout = 20000L) 
        public void myMethod(String aaa){
        retryTemplate.execute(args0 -> {
            // your business logic goes here
            return null;
        });
    }
Raman
  • 35
  • 1
  • 7
-1

It is just a opinion or suggestion to use Spring-retry (what i do in my case).

  1. Recovery
  2. backoff Policy.
  3. retry Count.

Spring-retry enables user to define multiple retry method against different exception raised.

You should handle those exception accordingly.. like if a method having some severe exception then whether you should try or not (you should decide)..

Suggestion ::The @Recover annotation is used to define a separate recovery method when a @Retryable method fails with a specified exception. You may store thing in database to process it further..

 @Recover
 void recover(SQLException e, String sql){ // Your Code of Handling...}

Now if you know that raised exception is able to handle in next retry then you should apply BackOff Policy. so that this can be handle accordingly..

Vikrant Kashyap
  • 6,398
  • 3
  • 32
  • 52