인셔셔RSS 관심 있는 블로그, 뉴스, 기술 정보를 효율적으로 추적하고 읽으세요
원문 읽기 InertiaRSS에서 열기

추천 피드

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Jina AI
Jina AI
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
美团技术团队
腾讯CDC
博客园 - Franky
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
博客园_首页
V
V2EX
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Why Hytales Treasure Hunt Engines Explode Under Load (And...
Lillian Dube · 2026-05-28 · via DEV Community

The Problem We Were Actually Solving

The Hytale engine triggers events through a simple pub/sub system called the EventManager. But when we scaled Veltrix to 2,500 concurrent players, the Friday Treasure Hunt would grind to a halt under 1,200 simultaneous participant load. The symptoms werent subtle:

  • EventManager block queue hitting 89% in Redis Streams
  • Latency spikes of 2.4 seconds per treasure spawn
  • Player timeouts in client-side treasure activation, throwing NRE-7280: Treasure chest activation timeout—region 53 not responding
  • Redis memory usage surging from 2.1 GB to 11.2 GB in under 15 minutes, triggering OOM killer on our cache tier

The root cause wasnt the logic. It was the configuration: we had one global event channel for all regions, one Redis stream for all treasure types, and no backpressure. The EventManager was being treated like a firehose instead of a controlled irrigation system.

What We Tried First (And Why It Failed)

Our first attempt was naive scaling: more Redis shards, more consumers, faster hardware. We threw 3 Redis 7.2 shards at the problem, each with 8 consumer groups across 4 regions. That bought us 40 minutes of stability before the queues still backed up under load. Why?

  • The pub/sub channel was still global. A treasure in Harbormere still queued behind one in Blightfen.
  • Consumer drift: players teleporting between regions didnt cleanly switch consumer groups, leading to duplicate spawns and phantom chests.
  • No circuit breaker. When Redis memory spiked, the OOM killer didnt just kill the process—it killed the entire cache tier, dropping all active player sessions.
  • We introduced OpenResty as a rate limiter, but it introduced 400ms of additional latency per spawn, and players started reporting stutter in movement.

The hard truth? We optimized for throughput instead of signal integrity. We treated the event stream like a raw data pipeline instead of a bounded context with clear boundaries.

The Architecture Decision

We pivoted to a strict regional event bus model:

  • Each of the 6 regions got its own isolated Redis stream (simplex streams, not shards)
  • We renamed the channels to match Biome IDs: EventStream_53 for Harbormere, EventStream_71 for Blightfen
  • Treasure spawn rules were regionalized: no cross-region spawns unless explicitly allowed (we disabled that entirely after debugging cross-region ghost chests)
  • We introduced a lightweight event bus gateway written in Go, running on dedicated k3s nodes with 2 vCPU/4GB each. It acted as a fan-out router, not a consumer
  • Each regions consumer group had a max-in-flight of 32 messages, with exponential backoff on Redis NACK
  • We set Redis maxmemory-policy to allkeys-lru with 8GB hard limit and added a Lua script to force GC when memory crossed 6GB
  • We moved the treasure activation logic from client-side to a regional microservice called TreasureCore running on Fly.io with Postgres 16 and pgbouncer. It exposed a REST endpoint: POST /treasure/{biomeId}/activate with ETag locking to prevent double-spawns

The tradeoffs were clear: more operational overhead, higher cost per region, and some latency between region teleports. But we chose correctness over convenience. The regional model meant a Harbormere treasure spawn wouldnt block Blightfen chest generation, even if a player teleports mid-event.

What The Numbers Said After

After three weeks of stable operation:

  • Redis memory stabilized at 3.2 GB across all streams (a 71% reduction from the old global model)
  • Treasure spawn latency dropped from 2.4s to 180ms p99
  • No more NRE-7280 errors under load—activation failures fell from 12% to <0.1%
  • Player experience improved: no more chest flickering on screen, no more teleport-induced desync
  • Cost: $47/month for Redis (down from $189), plus $112/month for 6 TreasureCore instances. We traded 14ms of cross-region latency for stability.

The metrics told us what we already suspected: treating the event engine as a global system was the anti-pattern. Regionalization wasnt premature optimization—it was damage control.

What I Would Do Differently

Id never design an event system with a single global channel again. Not for Hytale, not for any game. Even with strong regionalization, we still hit a snag when players would batch teleport across regions during peak load, overwhelming the event gateway with route updates. Our fix was to introduce a cooldown on teleport-induced region switches, but that hurt UX.

Next time, Id split the event bus further: one stream for static events (fixed chests), one for dynamic events (mobs, weather, timed spawns). Id use NATS JetStream instead of Redis Streams if I could afford the learning curve—it gives you stream-level backpressure out of the box.

And Id never trust a client-side activation again. The Hytale client is still just JavaScript with WebGL, and physics desyncs are inevitable. Push that logic to the server where it belongs.

We saved Veltrix from collapse that Friday. Not by throwing more hardware at the problem, but by respecting the boundaries of the system we were actually building. And the lesson sticks: events arent just features—theyre contracts. Break the contract, and the system breaks with you.