User Tools

Site Tools


dev_todo:metaserver_improvements

Metaserver Redo

The current metaserver has room for some improvements. The biggest right now is that there is a single metaserver (thus single point of failure). It also doesn't record all the information that would be useful.

Currently, the metaserver records this information:

  • IP address
  • Hostname (provided by server - not resolved by metaserver!)
  • number of current players
  • version of the server
  • free form comment set by the server admin
  • number of bytes server has received
  • number of bytes server has sent
  • how long server has been up.

Proposal for improvements:

  • All the fields currently present above
  • Codebase for server, maps, & archetypes. In this way, more readily apparantly what a server is running. This would be text provided by the server.
  • Metaserver should include port number of the server, so it would be possible to have multiple servers running on the same host.
  • metaserver should confirm hostname matches IP address from request. This currently isn't feasible because doing nameservice lookups could time out, causing server to hang up
  • SC_VERSION and CS_VERSION of the server - in this way, client could filter out servers it know it couldn't support.
  • A text flags section - different flags have different, but standardized, meaning. $ could be pay to play, P means player killing, etc
  • Multiple metaservers, so there is not a single point of failure.
  • Maybe add a second comment field - one for html (to display on the web), and one plain text so it can be properly displayed in the client?

Thoughts on Implementation

Making it a web based service (cgi-bin script or php script) is a good way to go. The web server deals with running multiple copies at the same time - thus, we don't care as much about timeouts in resolving the host name (one of the scripts running on the server may take a while to complete, but that doesn't cause problems as other scripts can run). Web based script access is also quite common, which means that it would be much easier to get multiple instances up compared to requiring a custom program to be run.

While overkill, tying it into a mysql database on the back end takes care of file locking/contention issues. A secondary table could be used to blacklist certain servers, typically those that are misconfigured.

There would be 3 scripts to handle this:

  1. Script that the server uses to update information
  2. Script that the client uses to get server information.
  3. Script that generates HTML table that people could point their web browser at.

Script 1 could be done relatively simply by passing values in the URL - http://metaserver?sc_version=aaaa&players=3&etc. But probably better to use an http request library, and use post submits - means we don't need to do lots of escaping by passing something as a URL.

Scripts 2 & 3 are relatively simple - they basically just dump the data from the mysql database. For the client script, it could be handly for it to include some demarcation line, like '— Metaserver Info Start —' so that the client doesn't have to be able to fully parse http - it just needs enough to make a request and look for that, knowing anything that follows it is the information it wants. But if it also uses a http request library, that should provide necessary parsing logic.

The server component is the hardest part. Since HTTP is tcp connections, these can time out, may take some time to make the connection, etc. Simplest way short term would be to have a seperate process that is started (perhaps through popen) that the server talks to, and that other process updates the metaservers. In a sense, it acts as a proxy, but so long as the popen is done with non blocking IO, never any danger of things getting frozen on the server. That proxy would try to update all the metaservers it knows about, with some extra logic on what to do when a metaserver isn't responding. Alternatively, using threads may be a cleaner way to do this. The data that the metaserver thread would need is pretty limited, so would not need much in the way of locks (and in fact, a data structure just for the dynamic metaserver data could be created, with the server just locking that as it needs to update it, with perhaps the metaserver thread having its own copy that it periodically copies from the original, so that neither lock would need to be held for very long)

There shouldn't be any need for the metaservers to talk to each other. Since each server will try to talk to all the metaservers, there should be no need. The client will choose one of the metaservers from the list to use (at random), thus doing load balancing of a form. The preferred metaserver could also be set in the client. If the client can not connect to the first metaserver, it would try the next, etc.

dev_todo/metaserver_improvements.txt · Last modified: 2007/07/20 01:48 (external edit)