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

推荐订阅源

F
Fortinet All Blogs
WordPress大学
WordPress大学
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
博客园 - Franky
D
Docker
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
U
Unit 42
M
MIT News - Artificial intelligence
B
Blog
GbyAI
GbyAI
C
Check Point Blog
P
Proofpoint News Feed
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
雷峰网
雷峰网
IT之家
IT之家
Google DeepMind News
Google DeepMind News
V
V2EX
Stack Overflow Blog
Stack Overflow Blog

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
D1 read replicas returned stale data for 6 seconds — here...
강해수 · 2026-06-17 · via DEV Community

강해수

At p99, a D1 read replica in Tokyo was 6.1 seconds behind a write that landed on the Eastern NA primary. I found this out not from the docs, but from a Korean ad-ops campaign tracker silently throttling the wrong impressions.

D1's architecture is straightforward: one SQLite primary, read replicas pushed to edge POPs, writes always hit the primary, reads go to the nearest replica. The docs acknowledge eventual consistency but give you no number to plan around. So I built a staleness probe — write a row with a UUID and epoch, poll the replica until it appears, record the delta. Across 200 probes from ap-northeast-1:

  • p50: ~800ms
  • p95: ~3,400ms
  • p99: ~6,100ms

That's the shape of the problem if your primary lands in enam and your users are in Asia.

The failure that forced my hand wasn't slow throttling — it was this:

Error: D1_ERROR: no such table: sessions

The table existed. What happened: a migration ran on the primary, the Worker restarted, and the first few requests hit a replica that hadn't caught the schema change yet. The error was misleading. The root cause was assuming replica reads would reflect a write that had just committed.

The fix I landed on doesn't fight the replication lag — it routes around it for the cases that matter. The writer stamps a written_at epoch on the row and sets an X-D1-Written-At response header. The reader compares that epoch against the written_at column it gets back from the replica. If the replica's value is older than the write signal, it falls back to KV — which runs sub-500ms in the same region and is free up to 10M reads/day. For a binary throttle flag that changes maybe a few times per minute, KV is a cheap freshness backstop.

The important part is that you only pay the KV fallback cost on the narrow window where the replica is genuinely behind. Most reads — once the replica catches up — hit D1 normally.

I wrote up the full breakdown — including the complete staleness probe script, the KV write-pair pattern, and how to handle the schema migration race — over on dailymanuallab.com.

Full post →