Real-time ratings: technical architecture
Real-time rating is a bundle of services that turns millions of gaming events into updated positions in hundreds of milliseconds, while maintaining honesty, auditability and economic manageability. Below is a practical constructor from requirements to operation.
1) Requirements and targets
Latency to UI: ≤ 200-300 ms p95 from event arrival to position update.
Accuracy: correct offset of the "best N "/divisions/tie-breaks during load and failures.
Availability: ≥ 99. 9% for the tournament period; degradation without loss of integrity.
Idempotency: "exactly once" at the accrual level, "at least once" in transport.
Scale: horizontal growth by region/division/team (top-K on the ball).
Audit: unchangeable logs of rules, events, charges and issues.
2) System diagram (10,000 ft level)
Клиент → Event Ingest → Scoring Engine → Stream Aggregator (Top-K/Top-M) → Write-Optimized Store → Hot Cache/Edge → UI/Comms → Rewards/Claim
Фоново: Snapshotter, Anti-Fraud/RG, Analytics & A/B, Audit/Observability.
3) Event Ingest
Tasks: protection against duplicates, bursts, network losses.
Idempotency: each event has an 'event _ uuid'; "seen/accrued" check.
Delivery semantics: transport - at-least-once, points accounting - exactly-once.
Backpressure: queues with dynamic batches; at overload - prioritization of "active" tours.
Time windows: allow late events (for example, up to 90 seconds) - route to the "recalculation window."
Time: server UTC, on the client - only locale mapping.
4) Scoring Engine
Principles: versioned rules, anti-pay-to-win, easy rollback.
Versioning: 'rule _ set _ id' + feature-flags per-region/division.
Models: multiplier ('Score = round (100log2 (Win/Bet + 1))'), win-based with log-curve, wager-based (only as background meta).
Offset "best N ": keep the top-N structure per player/day/tour; summation/median by format.
Exceptions: bonus funds' coef _ bonus ≤ 0. 5 'or' 0'; cap per spin/day; quotas per provider.
Tie-break: 1) earlier achievement of the final speed; 2) greater diversity; 3) deterministic seed.
5) Stream aggregation and top K
The goal: to quickly recalculate positions without scanning the entire set.
6) Storage: write vs read
Write-optimized store: accrual log, best-N states, tie-breaks, metadata (record/updates only).
Read-optimized store (Query): denormalized "showcases" for UI: top 100, "my position," "top of the day/division," contribution to the team.
Snapshotter: hourly "snapshots" of the leader board; fast rollback/replay, reports and audits.
Consistency: eventual for broad lists, read-your-writes for "my position."
7) Cash and Edge
Hot cache: last positions and score of players on the shard; TTL 1-5 sec; disability by event.
Edge layer/CDN: static blocks, "cold" results pages, but not accrual logic.
Fallback: during degradation - "bronze mode": UI update every X seconds + heavy widget block.
8) Time, windows and timezones
Single "true" time: UTC on services; deadlines in UTC.
Localization - Time conversion on the client (user time zone).
Borders: "soft window" closing 1-3 min for network lags (in T&C).
We go word class: clock-skew monitoring, NTP alerts, drift measurement.
9) Dealing with late and duplicate events
Late events: keep the "reconciliation window"; recalculation locally + "calm" adjustment of positions from the notification feed.
Doubles: 'event _ uuid' + (player, game, bet, ts) in a narrow window; magazine "seen."
Accrual idempotence - Event → change transaction with applied/rolled_back status
10) Anti-fraud and RG (built into the pipeline)
Behavioral scoring: uniform intervals, super-speed, "no noise" - flags.
Connection graph: common devices/IP/payments → clusters; hold awards, manual verification.
Quotas and caps: N best attempts/day, quotas for one slot/provider, cap points per spin/day.
Bonus funds: odds/elimination.
RG: points are only awarded within voluntary limits (time/deposits/losses); break reminders.
11) Multi-region and fault tolerance
Asset-to-asset by region: regional shards + global vault; proximity routing.
RTO/RPO: RTO <15 min (folback on snapshots), RPO = 0 for accruals (idempotent log replay).
Partition-tolerance: in case of a network gap - local leader board, subsequent consolidation and soft position correction.
FX and currencies: if prizes are in different currencies, we fix the moment of conversion, FX buffer 1-3%.
12) Security and privacy
Data: minimization (pseudonyms, without PII in the aggregator), encryption "in flight" and "at rest."
Access: principle of least privileges, secrets in KMS, access audit.
T & C/jurisdictions: rule/version logs, geo-blocks, age restrictions.
13) Observability and SRE practices
SLO: UI lag ≤ 300 ms p95, Claim time ≤ 10 min p95, uptime ≥ 99. 9%.
Metrics: events/sec, proportion of takes/rejects, late-rate, top-K heap-growth, stream lag, accrual errors, claim-rate.
Tracing: ingest → scoring → cache → UI.
Alerts: stop button (disable heavy experiments/reduce N best), auto degradation.
Post-mortem: RCA for 24-48 hours, action items list, error-budget policy.
14) Rewards & Claim
Auto award: in case of a close event - calculation of positions, issuance, receipts.
Claim-window: ≤ 72 hours, retray delivery, deterministic order of payments.
Transparency: history of awards in profile: rule, time, amount, source.
Holds: for rare/valuable prizes before KYC/AML.
15) A/B experiments and circuit evolution
What to test: N best (10/20), cap per spin (on/off), diversity bonus (0/50/100), aggregation type (amount/median).
Randomization: by region/channel/cluster - avoid overflows.
Guardrails: RTP, complaints/10k, RG signals - not degraded.
Migrations: storage scheme compatibility, dual-write for the duration of the migration.
16) UX-patterns real-time ratings
Rating center: rule of victory, timer, your score, remaining attempts, next reward.
Live feedback: "+ 40 points for x3," "2 attempts out of 20 remained," "you climbed 3 places."
Showcases: overall top 100, "my position," "top of the day/division," contribution to the team.
A11y: contrast, large numbers, focus states, voicing progress.
Localization: deadlines/timers in the local TZ, multilingualism.
17) Frequent failures and degradation scenarios
18) Checklist launch real-time ratings
Rules/Economics
- Formula, top N, tiebreaker, divisions
- RewardRate, payout width, wagers, claim ≤ 72 h
Equipment
- Idempotent Ingest, Late-window, Sharding
- Stream-Aggregator (топ-K/Top-M), Snapshotter
- Hot Cache/Edge, Health/Status API, stop button
Safety/RG
- Behavioral scoring, linkage graph, mouthguards/quotas
- RG limits, reminders, KYC/AML for big prizes
Data/A/B
- Dashboards: lag, late-rate, doubles, fairness metrics
- Experimental design and guardrails, dual-write during migrations
UX
- Rating center, micro-feedback, A11y, localization
- Short rules in 1 screen + full T&C
A reliable real-time rating is not one service, but a disciplined ecosystem: idempotent reception, versioned scoring, top-K stream aggregation, fast cache, status snapshots and built-in anti-fraud/RG mechanisms. Add strict SLO/SLA, comprehensible UX and change verification via A/B - and you get leaderboards that players trust, and the product gets predictable growth of Retention, Stickiness and LTV.