Kaiede/Bedrockifier

Improved User & State Handling

Opened this issue · 2 comments

First, the backup service assumes that there is nobody logged in when it connects to the server console. It should issue a command to list the players as it connects so it is in sync with the server state. Also, we don’t record any information about state between runs, which means we are limited in the type of logic that can be used to decide when to backup or not.

With the extra reliability of knowing when players are actually active on the server, this can be used to limit the number of backups made. For example, the below configuration would check if it should do a backup every hour, but would only backup if:

  • A backup hadn’t already been made in the last 3 hours.
  • A user had been logged in at some point since the last backup.
schedule:
  interval: 1h
  minInterval: 3h
  requireActivity: true

A configuration such as this would mean that at most, one would lose about 3 hours of work, but backups won’t be made during downtime when nobody has been playing. A simpler solution that just backs up every hour, but only if players are active could look like this:

schedule:
  interval: 1h
  requireActivity: true

The drawback being that while you are getting more frequent backups and will lose less work, you can get “spikes” on days where there’s a lot of activity. Some days getting 3 backups, others getting 24. So users would need to account for the sort of ‘worst-case’ scenario of heavy usage days in their configuration.

A good chunk of this applies to the interval based backups. Under the current model, if you are using something like this:

schedule:
  daily: 01:00
  onLastLogout: true
  minInterval: 1h

You are already getting something quite like the above, however it doesn’t let you capture snapshots during active play. So it’s possible to lose quite a bit of time.

On this front, something like this would be interesting:

schedule:
  onLastLogout: true
  interval: 1h
  minInterval: 1h
  requireActivity: true
  limitEventsSeparately: true

This would mean the last logout triggers a backup, even in the face of the hourly interval backups. But then the event backups would be limited to once an hour separately.

  • requireActivity - Only run interval backups if a user was logged in.
  • limitEventsSeparately - Tell the service to monitor event intervals separately.
  • minEventInterval - Used when limitEventsSeparately is true, instead of minInterval.