← Back
Home › Systems › Games

virtual-economy

virtual economy and inventory

Steam inventory

SystemTechniques · 8Primitives · 32 virtual-economy Saga patterndistributed · medium: Split a cross-service operation into local transactions, each paired with an undo; on failure run the undos in reverse, or retry forward.›Inventory reservationfinance · medium: Reserving stock with TTL holds, release on timeout and no overselling under contentionPayment state machinefinance · medium: Persisted state machine for a payment lifecycle (authorize, capture, void, refund) that treats timeouts as unknown, retries with the same key and applies webhooks idempotently.›Client action validationsecurity · medium: Validate client actions server-side: movement bounds, rate checks, statistical anomaly scoringDurable job queuedistributed · medium: Persisted tasks that workers lease for a visibility timeout, ack on success and retry with backoff; at-least-once execution that survives worker and queue crashes.›Transactional outboxdistributed · medium: Write the event as a row in the same local transaction as the state change; a relay publishes it later at-least-once, so state and events never diverge.›Change data capturestorage · medium: Decode the database's own commit log into row-change events in commit order, with a resume position, so any consumer can mirror the data exactly.›Idempotency keysfinance · low: Client-chosen unique key per logical operation, stored with a request fingerprint and the final response, so retries replay the first result instead of acting twice.›Event sourcingfinance · low: Persist state changes as an append-only stream of immutable events per entity; current state is a fold over them, guarded by expected-version appends.›Write-ahead logstorage · low: Append each change to a checksummed sequential log and fsync it before touching data pages; the basis of crash durability in nearly every database.›Double-entry ledgerfinance · low: Append-only journal of transactions whose postings sum to zero per currency; balances are derived, so money can only move, never appear or vanish.›Money representationfinance · low: Store money as integer minor units with an explicit currency exponent, compute in wider integers, and round once with a named rounding mode.›Reconciliationfinance · low: Match internal ledger records against bank and processor statements by reference, then amount and date window; every unmatched or mismatched item becomes an exception.›Alias method samplingnumerics · low: Vose alias tables: O(1) sampling from a discrete distribution after O(n) setupPRNGs (PCG, xoshiro)numerics · low: Small, fast, statistically strong non-cryptographic generators: PCG32 and xoshiro256**, with seeding, parallel streams and unbiased ranges.›Optimistic concurrency controlstorage · low: Run transactions without locks, record what they read, and validate at commit that nothing changed; fastest when conflicts are rare.›Conditional writesdistributed · low: Put-if-absent / if-match compare-and-swap on objects or keys as a commit primitiveHierarchical timing wheelsystems · low: Timers bucketed by expiry into wheels of slots, coarser wheels for far deadlines: O(1) insert and cancel for millions of timeouts.›Exponential backoff with jittersystems · low: Retry after delays that grow geometrically and are randomized, so failed clients spread out instead of hammering a recovering service in synchronized waves.›Hierarchical state machinesystems · low: Nest states so a substate inherits its parent's reactions and only overrides what differs, with ordered entry and exit actions along the path.›Ray primitive intersectiongeometry · low: Ray-triangle (Moller-Trumbore, watertight), ray-AABB slab and ray-sphere testsIsolation forestmachine-learning · low: Score each record by how few random axis-aligned splits it takes to isolate it in a small forest of random trees; anomalies are few and different, so they isolate fast.›Robust statisticsstatistics · low: Location and scale estimates (median, MAD, trimmed mean, Huber M-estimator) that stay correct when a minority of the data is garbage.›+ 1 more techniques+ 16 more primitives

Similar systems

Share the most building blocks with this one.