Smart HTTP route failover retry policy and RoutebyPercentage

book

Article ID: 130387

calendar_today

Updated On:

Products

STARTER PACK-7 CA Rapid App Security CA API Gateway

Issue/Introduction

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 

http://mcqst02-l22063.lvn.broadcom.net:8080/route1
URL1
-> http://mcqst02-l22067.lvn.broadcom.net/site1/index.html
Failure site
    URL2
-> http://mcqst02-l21561.lvn.broadcom.net:8080/test/echo1

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


 

Environment

Release:
Component: APIGTW

Resolution

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

<Please see attached file for image>

BlockBranch


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

<Please see attached file for image>

Percentage
 

Attachments

1558687968352000130387_sktwi1f5rjvs16fgm.png get_app
1558687965364000130387_sktwi1f5rjvs16fgl.png get_app
1558537166582Route.zip get_app