0

I run a server monitoring site for a video game. It monitors thousands of servers (currently 15,000 or so).

My current setup is a bit janky, and I want to improve it. Currently I use cron to submit every server to a resque job queue. I refill the queue just as soon as it's empty, essentially creating a constantly working queue. The job will then simply try and open a socket connection to the server ip and port in question, and mark it down if it fails to connect.

I have 20 workers, and it gets the job done in about 5 minutes. I feel that this should be able to go MUCH faster.

Is there a better, quicker way of doing this?

WedTM
  • 2,587
  • 5
  • 37
  • 54
  • I'd say evented servers (eventmachine, ...), but my experience with them is a bit limited so I'll let the experts answer. – Benoit Garret Sep 02 '11 at 17:23
  • I was thinking EM as well, however wasn't sure, and didn't want to waste the time on a dead end if someone smarter than I had experience! – WedTM Sep 02 '11 at 17:33

3 Answers3

1

So, what you are doing currently I assume is doing a TCP socket connection which pings your game server. The problem with using TCP is obviously that it is a lot slower than UDP. What I would advise instead is creating a UDP socket that just checks for the game server port.

Here's a nice quote from another question:

>        UDP is really faster than TCP, and the simple reason is because
> it's non-existent acknowledge packet (ACK) that permits a continuous
> packet stream, instead of TCP that acknowledges each packet.

Read this question here: UDP vs TCP, how much faster is it?

From my experience with game servers, the majority if not 100% of all modern game servers allow you to query them on a UDP socket. This will then respond with details on the game server. (I used to host a lot of servers myself too).

So basically, make sure that you are using UDP rather than TCP...

Example Query

I'm just searching for this information now and will update my question...when I find some source.. what game is it that you are trying to get information for?

Community
  • 1
  • 1
Layke
  • 51,422
  • 11
  • 85
  • 111
  • lol. From what I know off the top of my head minecraft is a TCP game. I'm about to check. But I actually think that UDP is not possible with Minecraft. (I'm going to to check) – Layke Sep 02 '11 at 17:41
  • Okay, yeah. minecraft is a TCP only game. Unlike COD, BF2, CSS, etc etc, you cannot query it using a UDP socket, so unless you can dedicate a load more servers to your querying, I think you probably have the fastest way already. Sorry it isn't the answer you were looking for. – Layke Sep 02 '11 at 17:43
  • Layke, nah. I was simply looking for an answer period. If the way I'm doing it already is the fastest, then threading, EM, or more servers is probably the only way :( – WedTM Sep 02 '11 at 17:44
  • 1
    Create two Amazon EC2 instances for 0.02 an hour and use them as a dedicated polling station to query all of your servers constantly. That would be about $28 a month for both. – Layke Sep 02 '11 at 17:47
  • Layke, I'm going to end up using the EC2 instances as you described. It seems to be the best approach so far :) – WedTM Sep 04 '11 at 10:18
  • If you choose to do that, create one instance, configure it. Then clone it and create an AMI, then use that as your "staple" server in order to launch as many as you need! – Layke Sep 04 '11 at 10:49
1

Use typical solutions for typical tasks. This case is about available detection every n seconds - one of daily sysadmin task. It should not be over ICMP, use SNMP over UDP proto. One of complete solution is Nagious/Cacti/Zabbix, which have built-in functionality to combine everything about your servers: LA, HDD, RAM, IO, NET as well as available detection.

Anatoly
  • 15,298
  • 5
  • 53
  • 77
  • If you have no chance to use your own monitoring system, try **pingdom** – Anatoly Sep 02 '11 at 19:49
  • First off, I guess I didn't make this clear, I'm not doing it for my own sake. I run a website that offers uptime tracking as a service. Secondly, the service I'm checking is only available via TCP, not anything else. This would be great if I was monitoring hardware, however, I'm not, I'm monitoring a service. – WedTM Sep 04 '11 at 10:17
  • I mentioned that I currently have over 15,000 servers. Pingdom at most allows 30. – WedTM Sep 04 '11 at 10:17
0

You don't mention how you are making the socket connections, but you might want to try using ruby curl bindings: curb instead of net/http.

This will typically be much faster.

Mike Buckbee
  • 6,793
  • 2
  • 33
  • 36