Balancing traffic a psecific way

Hello. I am trying to reslov the following task but i canot. please help me. I have 2 servers of my service: main and slave. My customers get an access to the service via Cloudflare. There are rare cases when main goes down and not availanble, I have a /ping GET function to check this status. In case the main servers is not responding to more than 10 seconds, I want cloudflare to change the server to my slave. I found an option when Cloudflare can randomly balance trafic, but I don’t need it. Can you help me?

Hello. I am trying to reslov the following task but i canot. please help me. I have 2 servers of my service: main and slave. My customers get an access to the service via Cloudflare. There are rare cases when main goes down and not availanble, I have a /ping GET function to check this status. In case the main servers is not responding to more than 10 seconds, I want cloudflare to change the server to my slave. I found an option when Cloudflare can randomly balance trafic, but I don’t need it. Can you help me?

(Duplicate post here)

You could consider the Cloudflare load balancer…

…or you could use your own healthcheck function to use the Cloudflare API to change the IP address in the DNS (subject to a suitable TTL)…

TTL is not sutable. IP change shoud be made in seconds. I couldn’t find this functionality in Load Balancer.

Try here…

Another option is to change from master-slave to a multi-master based cluster and service requests on any origin that is up with round-robin DNS.