UDP is a connectionless protocol. A UDP health check is implemented as follows:
When you use UDP for health checks, retain default parameter settings.
If the backend server is unhealthy, use either of the following methods to locate the fault:
One possible cause is that the ICMP Echo Reply or ICMP Port Unreachable message returned by the backend server does not reach the health check node within the timeout duration. As a result, the health check result is inaccurate.
It is recommended that you change the timeout duration to a larger value.
UDP health checks are different from other health checks. If the health check timeout duration is too short, the health check result of the backend server frequently toggles back and forth between Healthy and Unhealthy.
For Linux servers, run the following commands to query the rate limit and rate mask:
sysctl -q net.ipv4.icmp_ratelimit
The default rate limit is 1000.
sysctl -q net.ipv4.icmp_ratemask
The default rate mask is 6168.
If the returned value of the first command is the default value or 0, run the following command to remove the rate limit of Port Unreachable messages:
sysctl -w net.ipv4.icmp_ratemask=6160
For more information, see the Linux Programmer's Manual. On the Linux CLI, run the following command to display the manual:
man 7 icmp
Alternatively, visit http://man7.org/linux/man-pages/man7/icmp.7.html.
Once the rate limit is lifted, the number of ICMP Port Unreachable messages on the backend server will not be limited.
Note the following when you configure UDP health checks:
Log in to the server and run the following command as user root:
cat /proc/sys/net/ipv4/icmp_echo_ignore_all
If the backend server runs Linux, the rate of ICMP packets may be limited due to Linux's defense against ping flood attacks when there is a large number of concurrent requests. In this case, if a service exception occurs, the load balancer will not receive error message port XX unreachable and will consider the health check to be successful. As a result, there is an inconsistency between the health check result and the actual server health.