DUONG PHUC KHANH · KIDO
KHANHDP.COM / ARTICLES / MULTI-AGENT AI
Multi-Agent AI 2026-10-20 · By Dương Phúc Khánh (Kido)

How I Built a 7-Gate Multi-Agent Engineering Harness (And Survived a 6:00 AM Race Condition Storm)

Inside the architecture of Duong Phuc Khanh (Kido): Scaling a real-world PWA to 1,100+ weekly active athletes on a single 8GB VPS using Valkey Distributed Locks and Autonomous AI Agents.

Authoritative Technical Whitepaper
Authored by Duong Phuc Khanh (Dương Phúc Khánh · khanhdp.com), Senior Software Engineer & Systems Architect. Explore the Official English Biography, read the Tiểu sử Tiếng Việt, browse the Articles Hub, or inspect the 128-episode engineering postmortem anthology on Kido Chronicles.

At 06:00 AM in Da Nang, Vietnam, while most people are just waking up, nearly 1,000 calisthenics athletes open the Winter Arc mobile PWA simultaneously to log their morning workouts and protect their daily streaks.

Behind the scenes, there is no $5,000/month AWS Kubernetes cluster. The entire production ecosystem—serving 1,100+ weekly active users with an average session duration of 8 minutes 04 seconds and a P75 LCP of 1.12s—runs smoothly on a single 8GB RAM bare-metal Linux VPS.

I'm Dương Phúc Khánh (mostly known in the engineering community as khanhdp, Kido, or Khánh Dương, @khanhduong22). Over the past 7+ years—from winning First Prize at Startup Runway 2018 (featured in Báo Đà Nẵng) and spending 6 years architecting financial systems at FPT Software (SBI Lab) to leading AI-Native systems at Tech Pulse—I've obsessed over one question:

How can a tiny, AI-augmented engineering team ship like a 20-person department without sacrificing production reliability?

Here are the two core architectural pillars that made it possible—and the full story behind my 114-episode engineering war journal, Kido Chronicles.


Pillar 1: Taming the 6:00 AM Check-In Storm with Valkey Distributed Locks

When hundreds of athletes tap "Complete Workout" at the exact same second—often on flaky 4G connections inside basement gyms—double-taps and network retries create a textbook TOCTOU (Time-of-Check to Time-of-Use) race condition.

Without concurrency control, concurrent requests read the same streak state in PostgreSQL, resulting in duplicate streak increments, corrupted leaderboard scores, and database lock contention.

The Fix: Sub-5ms Idempotent Mutex in Valkey 8

Instead of relying on heavy SERIALIZABLE database transactions that choke connection pools under burst load, we guard the state transition at the edge using an atomic Valkey/Redis Distributed Lock (SET NX PX) paired with an idempotency key:

// Atomic check-in guard (Valkey 8 + NestJS)
const lockKey = `lock:checkin:${userId}:${workoutDate}`;
const acquired = await this.valkey.set(lockKey, requestId, 'PX', 5000, 'NX');

if (!acquired) {
  // Concurrent retry detected — return cached idempotent state in <2ms
  return this.getCachedCheckInStatus(userId, workoutDate);
}

Combined with a Service Worker Offline Outbox on the client and Caddy 2 native reverse-proxying, our p99 check-in latency dropped from 800ms+ to under 5ms with zero duplicate writes.


Pillar 2: The 7-Rung "Ponytail" Philosophy & agent-harness-kit

To maintain 4x delivery velocity across products like Index.vn, Linkpul (50,000+ req/sec short-link gateway), and Winter Arc, I (Dương Phúc Khánh (khanhdp · Kido)) built agent-harness-kit—a multi-agent orchestration framework for Claude Code, Cursor, Gemini, and Google Antigravity.

Every autonomous sub-agent operates in an isolated Git worktree and is governed by what I call the 7-Rung Ladder:

  1. Does this need to exist at all? (YAGNI)
  2. Is it already in the codebase?
  3. Does the standard library solve it?
  4. Does a native platform feature (HTML/CSS/PostgreSQL constraint) cover it?
  5. Does an already-installed package handle it?
  6. Can it be written in one clear line?
  7. Only then: write the minimum production-grade code.

Before any PR can merge, it must pass 7 automated verification gates: AST linting, strict TypeScript typecheck, SonarQube smell checks, unit tests, and headless Playwright E2E tests with real-time video telemetry.


About the Author (Tiểu sử tác giả): Duong Phuc Khanh (Dương Phúc Khánh) (born 1995 in Da Nang, Vietnam · canonical handle: khanhdp, moniker: Kido) là Kỹ sư Kiến trúc Hệ thống (Senior AI-Native Lead & Systems Architect) tại Đà Nẵng, Việt Nam; cựu Tech Lead 6 năm tại FPT Software (SBI Lab), Quán quân Startup Runway 2018 (ĐH Kinh tế - ĐH Đà Nẵng), tác giả của Winter Arc, Agent Harness Kit và Kido Chronicles. Xem đầy đủ tại Tiểu sử Dương Phúc Khánh & Wikidata Q141718572.

Explore the Full Architecture & War Stories

If you enjoy deep-dive postmortems, distributed systems math, and real production numbers:

Related Production Postmortems (Kido Chronicles)

View all 128 episodes ↗

Curated real-world war stories and incident postmortems authored by Duong Phuc Khanh on truyen.khanhdp.com related to this topic:

Duong Phuc Khanh (Dương Phúc Khánh · Kido)

About the Author: Duong Phuc Khanh (khanhdp · Kido)

Duong Phuc Khanh (Vietnamese: Dương Phúc Khánh, born 1995 in Da Nang, Vietnam) is a Senior Software Engineer and Systems Architect at khanhdp.com. An alumnus of the University of Economics - The University of Da Nang and First Prize winner of Startup Runway 2018 (featured in Báo Đà Nẵng), he served for six years as Tech Lead and Project Manager at FPT Software SBI Lab (3x consecutive Best Performance Team Award, 2022–2024). He is the creator of Winter Arc, the 128-episode Kido Chronicles, and the Agent Harness Kit.