Topic: The new master server system
Ok, the thing that I always feared happend a couple of days ago. I got knocked off the internet so the master server went down and no one could find any servers. I knew that this could happen, I had a solution for it. It were going to be in 0.4.0 but with resent events I created 0.3.4 to try it out.
The previous system worked like this. There was one master server called master.teewars.com. When a server started it registered with the master and sent a heartbeat every 30 seconds. Every client just asked the master for a server listing. Thats it. This is prone to errors on several places. For one, the master server can be knocked off, that has happend. The DNS could stop working for some reason so no lookup to master.teewars.com could be done. The DNS thing is unlikly because a DNS always consists of two servers.
The new system however is much much more robust. It consists of several master servers, upto 16, easily upgradable if we want. This is how the server registers itself to a master.
1. The server starts
2. Loads previous known ip addresses of the masters
3. Resolves master1.teewars.com to master16.teewars.com.
3a. It could resolve, saves the result to masters.cfg
3b. Couldn't resolve, uses the last known ip addresses.
4. Asks all master servers how many servers they have registered.
5. Picks the server with the lowest count and registers with it.
6. Sends heartbeats to that server every 30 seconds.
If for some reason the master stops responding, it will begin the process at step 3 again and choose a new one. This means, if a master server goes down, it will take roughly about 1 minute for all the servers on that master to migrate to a new master.
Right now, we have setup 3 masters. Two in Sweden and one in France. Later on we might add more for extra redundency.
The client just asks all the masters for their server listings instead of just asking one server like the old system.
So there it is. The new improved master server system.