What is the best way to prevent requests being sent to faulty target servers via JavaScript Policy ?

We use Javascript to make HTTP calls to our target servers. At times we get error responses from target servers due to some problem. What is the best way to prevent requests being sent to such faulty target servers until they are recovered via JavaScript ?

I understand that we can use HealthMonitor/HTTPMonitor if we make the calls to target servers via the target endpoints or Service callout policy. Is there anything equivalent for Javascript policy ?

2 3 199
3 REPLIES 3

Not applicable

Hi @AMAR DEVEGOWDA

Is there any specific reason why you want to use javascript and not Load balancer logic which is inbuilt? To keep things simple try to use the Load balancer with HTTP monitor.

I have never tried what you are asking for but If you look at the way the LB logic works, it constantly polls the backend and based on the HTTP status code and a number of failed/succeeded calls, a specific target is removed out of the rotation or added back. You will need an async process to keep polling and a counter to keep track of the count.

If you really want to do this in jsc, keep the monitoring/polling outside Edge and use Baas or KVM to store the counters/target endpoint which is live so that JSC can lookup the live target server details at any point of time.

@Maruti Chand,

Thanks for your suggestion. This was a requirement from one of the Edge users and infact I suggested the same to them. But I wanted to understand if there was any better way to do in JS other than polling.

Hi @AMAR DEVEGOWDA,

It is not a good idea to use javascript for callouts. Try to stick to standard methods of using a Target end point or service callout if it is done for any kind of orchestration. You can use load balancing in both methods to avoid requests being sent to faulty targets