WSO2 APIM 4.2 - Suspend endpoint and fail over to secondary server if 404 is received from backend

111 Views Asked by At

In WSO2 APIM 4.2 (open source version) we have setup a load balancer/fail over where we have a redundant back-end setup. In this example we are having an API deployed on 2 servers. If both servers are up and also on both those servers the API is deployed, then the load balancing works fine (Round Robin). And also the fail over works fine but only when the entire server is down.

But if we un-deploy one of the APIs in one of the servers (so only un-deploying that specific API endpoint) then the fail over does not seem to work anymore. Meaning when it hits that server which does not have the API deployed, it returns a 404 error.

We would like to know if its possible to also treat a HTTP 404 response code as a trigger for the fail over mechanism to kick in?

I only found 1 post which is related and it never got answered: How does WSO2 APIM handle 40x http error codes returned by endpoint?

There they mention the codes used within WSO2 in the 10k range, but i cant seem to find any mapping table which code to use for 404 responses.

Thanks for any help in advance!

PS. i have also tried to select all of the codes and then run the API again but the still it does not fail over to the secondary server.

1

There are 1 best solutions below

2
chashikajw On

The behavior you mentioned is the expected behavior in the product. If you undeploy the API from the API Manager and then invoke that particular API, it should return a 404 error. The API Manager provides failover support for the Endpoints in a API, not for the API Manager servers.

I'm not entirely clear on the specific issue you're trying to address, but I believe in your case, you can have a third instance of the API Manager and configure the other two instances of API Manager APIs as backends for that API in the third instance.

Updated:

If your backend sends a 404 error code, it means the backend is working and responding. Therefore, there is no way to trigger failover if the backend is functioning.

The error codes we provide in the endpoint configuration are our internal error codes, which we receive when the backend server is not functioning. It is not possible to directly map backend status codes with the internal codes mentioned in the list.