[Paper&Waterfall] Syncing & saving data across servers on a network

Hey all, just got a question about keeping data across paper servers consistent and saving it.

Currently a server I dev on (RPG-style) is 1 paper main server.
We’re looking to split into multiple different servers - each server being a different part of the map. All servers, the database and Waterfall proxy would be on the same dedi.

Certain data needs to be synced across the servers, such as custom statistics and data that needs to be the same across the servers. I’m thinking the best way to do this is create a socket that all the servers listen to.

When a player joins the proxy, load their data from the SQL (if they are not pending having data uploaded, explained below) and send it in a json format to all other servers, overriding any data they may already have about the player.

When a player leaves a paper server (either to leave the network or swap to a different paper server), send their data in a json format to all other servers (including the proxy). This would override any data that other servers have about the player (I’m aware that the join event on the new server is fired before the quit event on the previous, hence the data overriding). The Proxy would read the data received and asynchronously update SQL in a batch process - maybe using a scheduler to do it > every 30 seconds or so. The data waiting would be in a map where their uuid is the key, if the player joins whilst data is waiting to be updated for them, this data > would be sent to all servers instead of querying the SQL - as this would be most up to date as oppose to what’s in the SQL.

So after the player joins the proxy once, every server always has the most up to date information about the player.

We currently average 20-60 players, so it needs to be able to handle this (and hopefully more in future).

Just wondering if this is the best way to go about it, and if it is: should each plugin that requires it get it’s own socket or should there just be 1?

You don’t really want to manage sockets yourself tbh., I suggest using a pub-sub-messaging system either the one built in Redis (if you already use Redis in your setup) or a software dedicated to that like RabbitMQ. The major benefit being that you don’t need to reimplement messaging APIs, reconnection and stuff yourself, also the generally stability and being able to rely on widely used software to fix issues with it would probably also help in a long run.

I would also advice to just save the data directly from the minecraft servers itself or maybe a dedicated storage server that listens on the same pub-sub channel as your servers (no need to add that load onto a game/proxy server tbh. if you plan for this to be a bigger project)

1 Like