Redirect on Target failures to new url

Is there a way to redirect each client/developer on backend failure after 5 times to a new endpoint?

Say if backend is down for any known/unknown reason and we want to continue the users to use the api to be redirected to a different url where it can continue functioning with out any downtime after 5 failure hits..

This is not to spike arrest/rate limit the users though but provision with new ways on backend failures.

Please suggest.

Thanks.

0 4 202
4 REPLIES 4

@vinay - is it a different URL(host+path) or a different failover server(host only) where you want to redirect?

If you want to redirect to a failover server, you can use the isFallback option in the loadbalancer configuration.

    <HTTPTargetConnection>
        <LoadBalancer>
            <Algorithm>RoundRobin</Algorithm>
            <Server name="target1"/>
            <Server name="target2">
                <IsFallback>true</IsFallback>
            </Server>
            <MaxFailures>5</MaxFailures>
        </LoadBalancer>
        <Path>/</Path>
        <HealthMonitor>
            <IsEnabled>true</IsEnabled>
            <IntervalInSec>5</IntervalInSec>
            <TCPMonitor>
                <ConnectTimeoutInSec>10</ConnectTimeoutInSec>
                <Port>80</Port>
            </TCPMonitor>
        </HealthMonitor>
    </HTTPTargetConnection>

I am attaching a sample, with the assumption that you want to redirect to a failover server. Hope this helps.mock-target-api-rev1-2019-02-21.zip

It is a different URL(Host+path)..We simply want to redirect users to new url after certain failures from backedn so that user can follow different approach & continue business..

I have read the approach which you have provided but doesn't fit in the needs(thanks for the detail nagashree much appreciated).

Clients-> Api->Target endpointA(down)(it fails with 5xx)

After 3 attempts Api should redirect to endpoint B(may be 302) so that client can continue using the endpointB approach to continue his work..

Vinay,

there is no builtin logic in Apigee Edge to re-submit requests 3 times (or N times).

if you would like your API Proxy to behave that way you would have to script that retry logic, perhaps in a hosted target (nodejs).

Can you share a working sample for this approach?