Adam
Adam

Reputation: 3665

UDP Health Check

So we have an application that makes udp calls and sends packets. However, since responses are given for UDP calls, how could we ensure that the service is up and the port is open and that things are getting stored?

The only thought we have right now is to send in test packets and ensure they are getting saved out to the db.

So my over all question is, is there a better, easier way to ensure that our udp calls are succeeding?

Upvotes: 0

Views: 2272

Answers (3)

zangw
zangw

Reputation: 48506

Option 1:

  • The health check node sends an ICMP request to the backend server based on the health check configuration.
    • If the health check node receives an ICMP reply from the backend server, it considers the backend server healthy and continues the health check.
    • If the health check node does not receive an ICMP reply from the backend server, it considers the backend server unhealthy.
  • After receiving the ICMP reply, the health check node sends a UDP probe packet to the backend server.
    • If the health check node receives an ICMP Port Unreachable message from the backend server within the timeout duration, the backend server is considered unhealthy.
    • If the health check node does not receive an ICMP Port Unreachable message from the backend server within the timeout duration, the backend server is considered healthy.

Refer to https://support.huaweicloud.com/intl/en-us/elb_faq/elb_faq_0024.html


Option 2

We need to enable both TCP and UDP to the same ports on the Server side

  • UDP for traffic
  • TCP for health-check

Upvotes: 0

Adam
Adam

Reputation: 3665

We took a different approach and we are checking to make sure the calls made it to the db. Its easy enough to query a table and ensure records are in there. If none recent, we know something is wrong. CodeGnome had a good idea, just not the route we went. Thanks!

Upvotes: 0

Todd A. Jacobs
Todd A. Jacobs

Reputation: 84413

On the listening host, you can validate that the port is open with netstat. For example, if your application uses UDP port 68, you could run:

# Grep for :<port> from netstat output.
$ netstat -lnu | grep :68
udp        0      0 0.0.0.0:68              0.0.0.0:*

You could also send some test data to your application, and then check your database to verify that the fixture data made it into your database. That doesn't mean it always will be, just that it's working at the time of the test.

Ultimately, the problem is that UDP packets are best-effort, and not guaranteed. So unless you can configure your logging platform to send some sort of acknowledgment after data is received and/or written, then you can't guarantee anything. The very nature of UDP is that it leaves acknowledgments (if any) to the application layer.

Upvotes: 3

Related Questions