What is a reasonable timeout to check if the server is on the network?

I need to request ~ 10,000 game servers via UDP to check if they are online on the server every 15 minutes. My code works, but servers that are standalone block streams slow down progress. I use 20 threads, more will cause Python UDP sockets to slow down before going around.

I am currently using a five second timeout before deciding that the server is down. Can this limit be further reduced or should it be raised?


Please do not offer to use heartbeats, my server is an unofficial master for a game that needs to kick and does not receive most of the heartbeats.

+4
source share
1 answer

You do not need to use synchronous communication (i.e. send a packet, block and wait for the results), especially if you use UDP. Just ask one thread to send pings, and the other - the constant reception of pongs in one socket. If you need to perform complex processing with the results, you can use another for this.

The problem will be in the sending logic - you do not want to suppress your own Internet connection, so I would suggest a custom packet rate. In addition, UDP packets can be lost on the network, so retry sending at least once or twice before giving up. I would suggest about 2 seconds as a timeout, because if the ping to game server (i.e. with high latency) takes longer, it probably will not be used anyway.

+1
source

All Articles