Smart HTTP route failover retry policy and RoutebyPercentage


Article ID: 130387


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway


HTTP route failover retry: Looking for a routing strategy that if the failure rate is 50% for URL1 it will send to URL2 if URL1 comes back at more than 50% send request to URL1

Routing scenario using javascript and cache objective if URL1 has  50% failure then all the traffic (100%) needs to be routed to URL2, if URL 1 comes online route as normal
Failure site

Attached policy Export BlockBranch.xml

Summary Route by Percentage:  Javascript Math.Floor function with Match.random to determine the amount of traffic route to Site1 & Site2.  Decrease the value of the comparison variable to push more data to that specific region.  Backend URLs: URL1& URL2 Need to route the traffic to both the urls by applying 90/10 traffic ratio and this is achieved using Math. Floor by executing JavaScript assertion.Now 90% of traffic is routed to URL1 and 10% to URL2 by using the above logic. 

Attached policy export RouteByPercentage.xml



Component: APIGTW


Attached policy Export BlockBranch.xml
Javascript and cache to monitor failover count and retries 

<Please see attached file for image>


Attached policy export RouteByPercentage.xml
Javascript uses context.setVariable("js.response", Math.floor((Math.random() * 10) + 1));

<Please see attached file for image>



1558687968352000130387_sktwi1f5rjvs16fgm.png get_app
1558687965364000130387_sktwi1f5rjvs16fgl.png get_app get_app