How to create "master server"

Hey everyone! I have my third party api with json data, but it does not matter. I’d like to fetch data from it, and send it across all servers using MessagingService. I think its nice idea, to keep data synced, and do not request api from every server instance, but how can i make only one “Master server” which will be responsible for sending data to others?

Can you clarify what you mean by a ‘master’ server?

The only thing I could think of is HttpService really.

you can make it by using 2 places in your game but im not 100% sure about this.

Honestly if possible I would just have the servers request data themselves. Otherwise if you really want a master server approach you could use data like the time the server started and compare that to create a master server since all other servers can independently verify that data.

Let me be detailed…

If i dont have “master server”:

5/5 servers (Instances) with same interval request my API to receive data, and store it locally.

If i have “master server”:

1/5 servers (Instances) requests my API, and sync it with other, 4 instances using MessagingService

Master Server is the ONLY game instance, that use HttpService to fetch my servers.

You can just make the oldest qualified server the master by comparing server start times (or server qualify times if you need more specific rules). I would make every server capable of asking for the data from the master and retrieve it themselves if they don’t get a response for redundancy. The “master server” will shift around though as servers open or close so you would need to make it dynamic.

It’s probably better practice in most contexts to find a way to make it so that it works without a master server though.

But how can i “store” oldest server?

Each server stores the time they started. Then when a new server joins it asks the oldest server to respond to it. Each other server will then know it’s not the oldest server and therefore not the master. You’ll need to have them all determine the oldest again when the master server shuts down or stops responding to messages.

1 Like