How to implement client-side REST server fault tolerance?

I am working on a system that has a RESTful web service that can manipulate it (the service allows all CURD operations), and a web client that displays system data (most of the client was written in jQuery). In the standard operation scenario, there is a main server and at least one backup server of my system and at least two RESTful web services.

So my question is that my main server is out of order, how can I make a client who looked at the main server look at the backup server now without any user manipulation?

+1
source share
1 answer

Your best option is to make the client do absolutely nothing with server failure. This is not the responsibility of the client, and it should never be. Server technologies such as proxies and load balancers are best suited for troubleshooting server failures.

The most common approach is to abandon the “one primary server” way of thinking and create a cluster of servers, each of which can handle any of your REST requests. If your REST requests have no status (and they should be) and can be redirected to any arbitrary server in the cluster, then the server failure can be processed using the load balancer in front of the cluster.

If the load balancer detects that the server is dead, it simply pulls it out of rotation. This model also helps in scalability, because you can scale your server REST level by simply increasing the number of servers in this layer and automatically registering them with a load balancer.

You can also use DNS to isolate the client from server failure. Just change the DNS record point to the currently active server and change it when the primary server goes down. However, the TTL must be very low to allow this technique to work at any reasonable time. It is better to use DNS for a complete data center failure, rather than from a node, but this is an option, although rather crude.

+1
source

Source: https://habr.com/ru/post/1208602/


All Articles