惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
月光博客
月光博客
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
小众软件
小众软件
量子位
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

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
The Moment We Realized the Default Config Was a Lie
pretty ncube · 2026-05-27 · via DEV Community

The Problem We Were Actually Solving

We werent building a cache. We were running a treasure hunt engine where 100,000 concurrent users refresh GPS positions every 200ms, and every refresh triggers a write to aggregate player scores. The data isnt temporal; its mutable. The catch is that the moment a player crosses a checkpoint, all previous state for that player becomes invalid. Redis handled the writes, but the fork-based persistence model meant that every invalidation created a new fork, and the background save kept cloning the entire dataset. Our memory usage grew from 12GB to 48GB in 12 hours. We hit OOM killer at 14:33.

What We Tried First (And Why It Fail

We tried tuning Redis. We set maxmemory 32GB, maxmemory-policy allkeys-lru, and switched to AOF with fsync always. The OOM still happened, but now the kernel killed the redis-server process instead of the OS. The fork latency spike from AOF fsync added 800ms to our p99, and our p50 went from 2ms to 34ms. The Redis cluster mode documentation hinted at resharding pain, but we didnt want to shard a stateful mutable dataset. We considered removing state entirely, pushing invalidations to an SQS queue, but then wed lose atomicity per player—two concurrent invalidations could overwrite each other.

The Architecture Decision

We ported the state store to TiKV. Not because we loved it—TiKVs Rust client was immature then—but because it gave us per-key atomic writes and snapshot isolation. The decision wasnt about language; it was about the consistency model. TiKVs MVCC let us:

  • Write a checkpoint event with a new timestamp
  • Overwrite previous checkpoints in a single transaction
  • Keep the old version readable for 5 seconds, so late GPS packets still hit valid state
  • Run on Kubernetes with 3 replicas, tolerating one AZ failure

We wrote a custom Rust crate, kvs-raft, that wrapped the tikv-client crate and added a bloom filter for checkpoint lookups. The bloom filter was 8MB per TiKV node, reducing 40% of unnecessary reads. We ran a chaos test: killed one TiKV pod every 30 seconds for 15 minutes. Our p99 stayed under 12ms, total memory stabilized at 24GB across three pods.

What The Numbers Said After

Heres the profiler output from the Redis failure day vs. the TiKV stable day, both on c5.4xlarge:

Redis failure (day 3):

  • RSS: 48GB
  • p99 latency: 2.1s
  • p50 latency: 42ms
  • Allocations/sec: 180k fork buffers
  • Evictions: 0 (noeviction)

TiKV stable day:

  • RSS: 24GB
  • p99 latency: 12ms
  • p50 latency: 3.4ms
  • Allocations/sec: 12k
  • Raft log size: 4.2GB

The Rust client added 3ms to p99 on cold path, but the deterministic GC-free allocations dropped tail latency variability from 400ms swings to 12ms.

What I Would Do Differently

I wouldnt have trusted the default Redis config for mutable state. The READMEs QPS numbers are for cache workloads, not mutable, frequently invalidated datasets. I would have benchmarked fork syscalls before deploying. Also, TiKVs Rust client panicked on network partitions under load—the fix was adding a custom backoff strategy in our kvs-raft wrapper, but we should have tested partition tolerance first. Finally, we over-provisioned memory. The rustc compiled binary was 12MB, but our container image was 600MB due to vendored dependencies. We switched to a distroless image and cut cold-start time from 4s to 800ms.


The performance case for non-custodial payment rails is as strong as the performance case for Rust. Here is the implementation I reference: https://payhip.com/ref/dev2