Ledger

Limits

The numbers that change what you write.

Check a number before you hit it.

-- Short names keep a key's list of used names small.
local Options: Ledger.TxOptions = { Id = "pay:" .. HttpService:GenerateGUID(false), IdAt = Ledger.Now() }

Only numbers that change what you do are here. A call that breaks a limit with a mistake throws before it sends anything. A call that meets a limit while running answers with a reason, such as Full or Backlog.

Names and keys

Limit
Store name1 to 50 bytes. Not Ledger$N, which Ledger keeps for itself.
String key1 to 50 bytes of valid UTF-8. Cannot start with $T: or $P:.
Player keyA UserId, a whole number.
Id textAt most 64 characters.
Total or quantity name1 to 37 bytes.
IdAtAt most 1 day ahead of Ledger.Now().

Size

LimitWhat to do
One key's dataAbout 4 MB (4,160,526 bytes). A warning shows past 2 MiB.Past the cap, a write answers Full. Keep an active key well under 1 MB.
One key's writesAbout 4 MB of writes a minute.A big key cannot be written often. Spread hot data over several keys.
One op in a Tx or Take4,096 bytes of terms, as JSON.Keep ops small.
DataPlain tables only, up to 64 deep. No cycles, NaN, or arrays with gaps or mixed keys.
NumbersWhole numbers below 2^53 unless you give an Arithmetic.
Reset with a StateAt most 1 MiB.

How long Ledger remembers a name

A key remembers the names of recent ops, so a resend does nothing twice.

LimitWhat to do
Timed names (Id and IdAt, or Ledger.Id())Remembered 180 s by default. A key holds about 275 GUID names.Keep names short. NoRoom means the list is full: send again later.
Untimed names (Id alone)A key holds about 90 GUID names. Remembered only for the time you set in Windows.Prefer timed names.
WindowsHow long a name is remembered. Timed: 136 s to 30 days. Untimed: 76 s to 30 days, and you must set it to use one.Set Untimed for any op kind you name without IdAt.
CutWindowHow old a Ledger.Id() name can be. 360 s by default, 318 s to 30 days.Make the name just before an Erase or Reset. After this long, a server answers Expired.

Waiting

CallHow long it can take
Ledger.Id()Busy after 5 s with no server number.
A read (Peek, Inspect, Losses, Resettle)Unresolved after 30 s. Pending too, on a hung read.
EditUnresolved after 30 s once sent. Ledger keeps sending it.
Bump0 to 60 s, up to 90 s if saves fail. Call it in task.spawn.
EraseAbout 200 s at worst.
Peek of a key where a crashed server left trade workUp to about 30 minutes Unresolved. Call Resettle to end it now.
A session saveEvery 30 s. Idle sessions read every 120 s.
Shutdown25 s. BeforeClose functions share the first 5 s.

SaveInterval, IdleReadInterval and HoldMax can each be set from 1 s to 30 days.

Queues

LimitAnswer
A session's unsaved Applys4,096 ops or 1.5 MiBBacklog. Call Flush.
Unanswered writes on one key4,096Busy. Send again later.
Trade work not yet finished on a key16NoRoom. Send again later.

Transactions and stock

Limit
Ledger.Tx keys2 or more, all different. The limit is in bytes, not a count: one key in the trade keeps a list of all the others, and that list has a size cap. About 29 keys fit with 16-character keys, 40 with 5-character keys, fewer with long keys or keys in other stores. Too many throws before anything is sent.
Take LegsOne fewer than the Tx limit.
Quantity Parts1 to 64.
Proceeds fieldsUp to 4.
HoldsUp to 900 s each (HoldMax), plus 60 s for clock differences between servers. 256 at once per part.
Close removing partsAfter 62 minutes from the first Open.
Totals Shards1 to 64, 16 by default. Do not change a live total's Shards.

Reads and watching

Limit
Peek MaxAge0 to 30 days. An answer can be up to about 4.5 minutes behind on a key nobody writes.
FollowChecks every 30 s, slowing to 240 s on a quiet key. Copies last 1 hour.
Store:Keys() page50 keys. Pages are in no set order.
Store:Versions() page1,024 versions, oldest first. Roblox keeps one per hour of writes, for 30 days.
Cut.Losses, Store:LossesKept 7 days.

Requests per call

How many Roblox DataStore requests a call makes, with no contention. read is a GetAsync, write an UpdateAsync.

CallRequests
Edit, Commit1 write. The first Edit of an erasable key also reads once.
ApplyNone. It rides the next save: 1 write per 30 s, however many ops.
Load1 read. An idle session then reads once per 120 s.
Peek, Inspect, Losses, Pending1 read.
Peek(Key, MaxAge)None inside MaxAge.
Peek(Key, { Fresh = true })1 write.
Ledger.Tx, N keysN writes before the answer, 2N-1 in all.
Take, Hold, Confirm1 write, or with one key in Legs 2 before the answer and 3 in all.
Reset, Erase1 write. Erase also removes the key.
Open, CloseOne write per part.
BumpOne write per shard per server batch.
Keys, Versions1 list request per page.
PeekVersion1 read.
Server start1 write.

Next: Releases

On this page