Urgent.News

What's breaking now, across thousands of outlets.

Tech

How We Eliminated Cache Stampedes in Node.js & Bun with Single-Flight Coalescing

Every engineer who has scaled a high-traffic backend has lived through this nightmare: You have an expensive endpoint (e.g., aggregating leaderboard data or rendering a personalized dashboard). To protect your database, you cache the result with a 60-second TTL. Everything runs smoothly until the key expires while receiving 1,500 requests per second . Within a 50-millisecond window, hundreds of…

Engineers who have scaled high-traffic backends have experienced the nightmare of expensive endpoints that are cached with a short TTL. When a cache key expires during a surge of requests, hundreds of simultaneous requests trigger a database storm, overwhelming the connection pool and causing latency spikes. The traditional solutions - probabilistic early expiration and distributed mutex locks - either waste CPU cycles or introduce network latency and deadlock risks.

The zero-overhead alternative is Single-Flight Promise Coalescing. When a cache miss occurs, the system checks if an execution promise for the key is already running. If so, it returns the existing promise and waits for the result. If not, it creates a new promise, fetches the data, caches it, resolves all awaiting calls, and then removes the promise. This approach eliminates lock contention and connection pool exhaustion while maintaining zero overhead.

The benchmark tested this method against traditional caching under 1,000 concurrent requests, with a simulated database query latency of 25ms. The Single-Flight Promise Coalescing method reduced database queries from 1,000 to just one, achieving a 99.90% reduction in DB load and zero connection contention. KVDock, an open-source caching engine, implements this solution with multi-tier storage support and native polyglot implementations for various runtimes.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Accurate Audio Transcription API in Python and Node.js Game SaaS — Reliability

Short answer: treat audio transcription as a reliability boundary, not a convenience API. For a game catalog that turns messy voice descriptions into searchable text, put an idempotent job contract in…

  • Accurate transcription treated as reliability boundary, not convenience feature
  • Idempotent job contract required with transcription service selection
  • Dashboard tracks completion SLO, quality, and retry stuck jobs

Why your cloud monitoring is blind to IPv6 blackholes (and how to fix it)

TL;DR: your checker probably takes the first address the resolver hands back, and on a dual-stack host that is the AAAA record.

  • IPv6 blackholes cause cloud monitoring to report targets as down incorrectly
  • Monitoring tools often use first address from resolver, potentially an IPv6 on dual-stack host
  • Two-file CLI tool distinguishes between IPv6 timeout and no route ENETUNREACH errors

More from Tuesday 3 November →