Is it possible to retry API request to a target server when we get 5XX ?

When making requests to the target server, if the server responds with a 5xx error. Is it possible to retry again ?

Solved Solved
0 11 5,604
1 ACCEPTED SOLUTION

Yes it is possible to retry if the response from the target server (NOT from Apigee Edge) is 5XX. For example, if the target server responds with a 500, then you could retry the request to a different target server.

To enable retry on 5XX errors, you need to set the "ServerUnhealthyResponse" element with appropriate response codes as unhealthy responses.

For ex: If you want to retry on 500, 502 and 503, then you need to set it as follows:

<TargetEndpoint name="default">
  <HTTPTargetConnection>
      <LoadBalancer>
        <Algorithm>RoundRobin</Algorithm>
        <Server name="target1" />
        <Server name="target2" />
        <MaxFailures>5</MaxFailures>
        <RetryEnabled>true</RetryEnabled>
        <ServerUnhealthyResponse>
            <ResponseCode>500</ResponseCode>
            <ResponseCode>502</ResponseCode>
            <ResponseCode>503</ResponseCode>
        </ServerUnhealthyResponse>
      </LoadBalancer>
      <Path>/test</Path>
  </HTTPTargetConnection>
</TargetEndpoint>

You can read more about retry feature in this link

View solution in original post

11 REPLIES 11

Yes it is possible to retry if the response from the target server (NOT from Apigee Edge) is 5XX. For example, if the target server responds with a 500, then you could retry the request to a different target server.

To enable retry on 5XX errors, you need to set the "ServerUnhealthyResponse" element with appropriate response codes as unhealthy responses.

For ex: If you want to retry on 500, 502 and 503, then you need to set it as follows:

<TargetEndpoint name="default">
  <HTTPTargetConnection>
      <LoadBalancer>
        <Algorithm>RoundRobin</Algorithm>
        <Server name="target1" />
        <Server name="target2" />
        <MaxFailures>5</MaxFailures>
        <RetryEnabled>true</RetryEnabled>
        <ServerUnhealthyResponse>
            <ResponseCode>500</ResponseCode>
            <ResponseCode>502</ResponseCode>
            <ResponseCode>503</ResponseCode>
        </ServerUnhealthyResponse>
      </LoadBalancer>
      <Path>/test</Path>
  </HTTPTargetConnection>
</TargetEndpoint>

You can read more about retry feature in this link

Hi @adevegowda ,

We are noticing strange behavior with the retry.

When our request is retried to a different backend server by apigee, the request body from the previous request is stripped off.  I can't believe that could be true. Do you know about any such behavior? 

 

That sounds very surprising. If you can reliably reproduce that behavior, please contact Apigee support and provide them the information so that they can diagnose the problem. 

Is it possible to retry to only one target server?

@angelfire is this possible?

 

No. Check the documentation.  Retry requires at least two targetservers.

If you want to build in retry, you may wish to consider using Application Integration, which has the capability to run conditional retry, among many other integration scenarios.  Richard Seroter recently posted a useful overview,  and you can also visit the integration cloud forum  here on the googlecloudcommunity site to ask integration-specific questions.

No, as documented, you need multiple targets and RetryEnabled. 

screenshot-20230822-084815.png

 

Hi,

Is it possible to hold the same request for some time (75 seconds) and then retry it to the same Target Endpoint when I receive a 429 error from them?

@kurtkanaskie @dchiesa1@Sai Saran Vaidyanathan@dknezic @ganadurai @Harish123 @shrenikkumar-s @Peeyush_Singhai , @Renuka_atnoor

Can you share the limits on the above retry?

1) What is the max request payload size of per request retry?

2) Is there max number of requests you can keep retry concurrently, say a backend down for 30 secs and there is 20K request in a short time.  How much can you keep?

3) What are other configuration parameters besides maxFailures? like delay retries?

4) What happens to the connection/keep-alive when the API is in a retry state?  Does the synchronous request keep open for max allow per API?

Have you found answers to your questions? Can you please share if you have one.
Thanks