Forest Logo
search
package_2

server-sync

By @dooougs

Roblox

Mirrored from Wally

ServerSync

A shared world store for Roblox experiences where many servers edit the same world at once. Extracted from Plant World, where it holds every plant in every city.

  • Objects (written once, first copy wins) and updates (per field, newest timestamp wins), sharded into one DataStore key per region.
  • Saves merge with UpdateAsync (compare-and-swap), so servers never overwrite each other and nothing ever waits on a lock.
  • Old updates are compacted into versioned baselines under a try-once MemoryStore lease with a fencing check.
  • Edits are broadcast live through MessagingService in batches sized for its 1 KB / per-minute limits; anything missed is caught by periodic re-reads.
  • Budget-aware reads with jittered back-off, bounded region cache, Studio offline mode.

Install

[server-dependencies]
ServerSync = "dooougs/server-sync@0.1.0"

Use

local ServerSync = require(ServerScriptService.ServerPackages.ServerSync)

local store = ServerSync.newStore({ storeName = "MyWorld_v1" })
local sync = ServerSync.newBroadcaster(store, { topic = "MyWorldUpdates_v1" })
store.start()
sync.start()

store.createObject("3,4#1", { pos = { x = 10, z = 20 }, kind = "tree" })
store.set("3,4#1", "w", 0.5)
store.onChanged(function(id, field, value) print(id, field, value) end)

Entity ids start with their chunk, "cx,cz", by default; pass keys to map ids to regions your own way.

Options

See src/Options.luau for every option and default. Highlights:

optiondefault
storeNamerequiredkeep it identical to keep existing saves
scope, leaseMapNamenone, <storeName>_compact
keys"cx,cz" ids, 8x8-chunk regionscustom id → region mapping
flushInterval / refreshInterval30 / 120 s
refresh, evictiontrueturn re-reads or the region cache off
compaction.enabledtrueplus lag, minUpdates, interval, lease, tombKeep
forceOffline, studioProbe, bindToClosefalse, true, true
broadcaster publish / subscribetrueone-way sync, or none
broadcaster publishInterval / messageBytes4 s / 900

The saved record layout (v = 3) is fixed so saves always load.

Package Details

Install command (Click to copy)


Version

0.1.0

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.