<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dương Phúc Khánh (Kido) Engineering Hub]]></title><description><![CDATA[Dương Phúc Khánh (Kido) Engineering Hub]]></description><link>https://khanhduong22.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 02:18:37 GMT</lastBuildDate><atom:link href="https://khanhduong22.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Zero-TBT & 8-Minute Mobile Sessions: Engineering a 60FPS Offline-First PWA on iOS Safari]]></title><description><![CDATA[Most mobile web apps lose 60% of their users within the first 15 seconds. On iOS Safari, heavy JavaScript bundles, layout shifts, and flaky 4G connections…]]></description><link>https://khanhduong22.hashnode.dev/zero-tbt-8-minute-mobile-sessions-engineering-a-60fps-offline-first-pwa-on-ios-safari</link><guid isPermaLink="true">https://khanhduong22.hashnode.dev/zero-tbt-8-minute-mobile-sessions-engineering-a-60fps-offline-first-pwa-on-ios-safari</guid><dc:creator><![CDATA[Dương Phúc Khánh (Kido)]]></dc:creator><pubDate>Wed, 14 Oct 2026 14:04:05 GMT</pubDate><content:encoded><![CDATA[<p>Most mobile web apps lose 60% of their users within the first 15 seconds. On iOS Safari, heavy JavaScript bundles, layout shifts, and flaky 4G connections inside gyms or elevators turn web apps into sluggish, frustrating experiences.</p>
<p>When building the <a href="https://vantoicalis.com"><strong>Winter Arc 100-Day Challenge PWA</strong></a> (engineered by <a href="https://khanhdp.com/about"><strong>Duong Phuc Khanh / Kido</strong></a>), we achieved numbers rarely seen in mobile web applications:</p>
<ul>
<li><p><strong>Average Session Duration</strong>: <strong>8 minutes 04 seconds</strong></p>
</li>
<li><p><strong>Bounce Rate</strong>: <strong>8.2%</strong> (with <strong>&gt;70% Direct Traffic</strong> from home-screen PWA installs)</p>
</li>
<li><p><strong>Sentry Core Web Vitals</strong>: <strong>1.12s P75 LCP</strong>, <strong>120ms P75 INP</strong>, and <strong>0ms Total Blocking Time (TBT)</strong></p>
</li>
</ul>
<p>Here are the three frontend engineering protocols behind those numbers.</p>
<hr />
<h2>1. The 3-Tier Viewport &amp; Dynamic Overlay Protocol (0ms TBT)</h2>
<p>Why do so many Next.js and React apps suffer from 400ms+ Total Blocking Time on mobile? Because developers statically import hidden modals, celebration confetti, walkthrough tours, and heavy charts into the initial route bundle.</p>
<p>We enforce a strict <strong>3-Tier Viewport Protocol</strong>:</p>
<ul>
<li><p><strong>Tier 1 (Interactive Overlays)</strong>: Every modal, drawer, bottom sheet, and celebration overlay is lazy-loaded via <code>next/dynamic(..., { ssr: false })</code>. Zero bytes of overlay JS are parsed during initial hydration.</p>
</li>
<li><p><strong>Tier 2 (Heavy Below-the-Fold Modules)</strong>: Charts and heatmaps below the initial <code>390x844</code> mobile fold are wrapped in fixed <code>min-height</code> skeletons (<code>CLS = 0</code>) and hydrated on intersection.</p>
</li>
<li><p><strong>Tier 3 (Core Above-the-Fold UI)</strong>: Pure server-rendered HTML + lightweight CSS transitions so athletes can tap their daily workout within 1.1 seconds of opening the app.</p>
</li>
</ul>
<hr />
<h2>2. Offline Outbox Pattern for Basement Gyms</h2>
<p>Athletes frequently train in basement gyms where cellular signal drops mid-set. Instead of showing a spinning loader or failing the request when a user finishes a set, our client writes every action to an <strong>IndexedDB Offline Outbox</strong> with a deterministic client timestamp and HMAC signature.</p>
<p>As soon as connectivity returns (<code>window.addEventListener('online')</code> or Service Worker background sync), the outbox replays the batch idempotently to our NestJS backend.</p>
<hr />
<h2>3. Pure Interaction Telemetry (Lazy Analytics Hydration)</h2>
<p>Third-party scripts (GA4, Sentry, Microsoft Clarity) are notorious for ruining mobile INP and TBT. We defer all telemetry SDK initialization until after <code>requestIdleCallback</code> or the user's first pointer/scroll interaction—ensuring 100% of CPU cycles during the first 2 seconds belong to the user interface.</p>
<hr />
<h2>Read More from Kido (Dương Phúc Khánh)</h2>
<ul>
<li><p>🌐 <strong>Official Engineering Hub</strong>: <a href="https://khanhdp.com">https://khanhdp.com</a></p>
</li>
<li><p>🏛️ <strong>Biography &amp; Career Timeline</strong>: <a href="https://khanhdp.com/about">https://khanhdp.com/about</a></p>
</li>
<li><p>📖 <strong>Kido Chronicles (114 Real Engineering Stories)</strong>: <a href="https://truyen.khanhdp.com">https://truyen.khanhdp.com</a></p>
</li>
<li><p>💻 <strong>GitHub</strong>: <a href="https://github.com/khanhduong22">@khanhduong22</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why I Refused a $500/mo Cloud Bill: Running 1,100+ Active Users at 1.12s LCP on a Single 8GB Linux VPS]]></title><description><![CDATA[Modern cloud architecture often suffers from Resume-Driven Development: spinning up managed NAT gateways, multi-node Kubernetes clusters, and serverless…]]></description><link>https://khanhduong22.hashnode.dev/why-i-refused-a-500-mo-cloud-bill-running-1-100-active-users-at-1-12s-lcp-on-a-single-8gb-linux-vps</link><guid isPermaLink="true">https://khanhduong22.hashnode.dev/why-i-refused-a-500-mo-cloud-bill-running-1-100-active-users-at-1-12s-lcp-on-a-single-8gb-linux-vps</guid><dc:creator><![CDATA[Dương Phúc Khánh (Kido)]]></dc:creator><pubDate>Wed, 14 Oct 2026 14:03:09 GMT</pubDate><content:encoded><![CDATA[<p>Modern cloud architecture often suffers from Resume-Driven Development: spinning up managed NAT gateways, multi-node Kubernetes clusters, and serverless databases for workloads that barely hit 50 requests per second.</p>
<p>When I architected the <a href="https://vantoicalis.com"><strong>Winter Arc Platform</strong></a> (and my personal ecosystem at <a href="https://khanhdp.com"><strong>khanhdp.com</strong></a>), I set a strict engineering constraint:</p>
<blockquote>
<p><strong>Run the entire production stack on a single 8GB RAM NVMe Linux VPS while maintaining a Google Core Web Vitals LCP under 1.2 seconds and 99.95% uptime.</strong></p>
</blockquote>
<p>Today, that single node handles <strong>1,100+ weekly active athletes</strong>, <strong>712 daily workout loggers</strong> (opening the PWA 33–34 times/week), <strong>8m04s average session time</strong>, and <strong>113,000+ weekly telemetry events</strong>—at a fraction of a typical cloud bill.</p>
<p>Here is the exact bare-metal tuning playbook I use in production (documented across 114 episodes of <a href="https://truyen.khanhdp.com"><strong>Kido Chronicles</strong></a>).</p>
<hr />
<h2>1. Linux Kernel &amp; Memory Hygiene (<code>vm.swappiness = 10</code> + TCP BBR)</h2>
<p>Default Linux distributions are tuned for general-purpose desktop or legacy server workloads, not high-concurrency container stacks. Three <code>sysctl</code> changes immediately transformed our P99 tail latency:</p>
<pre><code class="language-ini"># /etc/sysctl.d/99-kido-production.conf
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
vm.swappiness = 10
vm.overcommit_memory = 1
net.core.somaxconn = 4096
</code></pre>
<ul>
<li><p><strong>TCP BBR</strong>: Cuts mobile 4G handshake and retransmission latency by 30–40% for users in Vietnam hitting European/Singapore nodes.</p>
</li>
<li><p><code>vm.swappiness = 10</code>: Prevents the kernel from prematurely swapping out hot PostgreSQL shared buffers or Node.js V8 heap pages while still keeping an emergency swap cushion against the OOM Killer.</p>
</li>
<li><p><code>vm.overcommit_memory = 1</code>: Mandatory for Redis/Valkey background <code>BGSAVE</code> forks so copy-on-write snapshots never fail under 70% RAM utilization.</p>
</li>
</ul>
<hr />
<h2>2. Caddy 2 Native File &amp; Reverse Proxy (Zero-Config HTTP/3)</h2>
<p>Instead of stacking Nginx + Certbot + custom Lua scripts, <strong>Caddy 2</strong> serves as our single edge ingress:</p>
<ul>
<li><p>Automatic <strong>HTTP/3 (QUIC)</strong> and TLS 1.3 session resumption out of the box.</p>
</li>
<li><p>Static sub-apps like <a href="https://truyen.khanhdp.com"><strong>Kido Chronicles (</strong><code>truyen.khanhdp.com</code><strong>)</strong></a> are served directly from disk via Caddy's <code>file_server</code> with pre-compressed <code>zstd</code> and <code>gzip</code>, delivering <code>&lt;10ms</code> <strong>TTFB</strong> with <strong>0 MB of container RAM overhead</strong>.</p>
</li>
</ul>
<hr />
<h2>3. Strict Docker Subnet Isolation &amp; Cgroup Limits</h2>
<p>Never let a noisy neighbor container starve PostgreSQL. Every service in our <code>docker-compose.yml</code> is governed by hard <code>mem_limit</code> boundaries and separated into dedicated internal bridge networks (<code>frontend_net</code> vs <code>backend_db_net</code>) with custom <code>DOCKER-USER</code> iptables rules blocking external port scanners.</p>
<hr />
<h2>About the Author</h2>
<p><strong>Duong Phuc Khanh (Kido / Khánh Dương)</strong> is a Senior AI-Native Lead &amp; Systems Architect based in Da Nang, Vietnam, alumnus of <a href="https://vi.wikipedia.org/wiki/Tr%C6%B0%E1%BB%9Dng_%C4%90%E1%BA%A1i_h%E1%BB%8Dc_Kinh_t%E1%BA%BF,_%C4%90%E1%BA%A1i_h%E1%BB%8Dc_%C4%90%C3%A0_N%E1%BA%B5ng">Da Nang University of Economics (DUE)</a>, and creator of <code>agent-harness-kit</code>.</p>
<ul>
<li><p>🌐 <strong>Portfolio &amp; Systems Benchmarks</strong>: <a href="https://khanhdp.com">https://khanhdp.com</a></p>
</li>
<li><p>🏛️ <strong>Encyclopedia Biography</strong>: <a href="https://khanhdp.com/about">https://khanhdp.com/about</a></p>
</li>
<li><p>📖 <strong>114 Production War Stories</strong>: <a href="https://truyen.khanhdp.com">https://truyen.khanhdp.com</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How I Built a 7-Gate Multi-Agent Engineering Harness (And Survived a 6:00 AM Race Condition Storm)]]></title><description><![CDATA[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…]]></description><link>https://khanhduong22.hashnode.dev/how-i-built-a-7-gate-multi-agent-engineering-harness-and-survived-a-6-00-am-race-condition-storm</link><guid isPermaLink="true">https://khanhduong22.hashnode.dev/how-i-built-a-7-gate-multi-agent-engineering-harness-and-survived-a-6-00-am-race-condition-storm</guid><dc:creator><![CDATA[Dương Phúc Khánh (Kido)]]></dc:creator><pubDate>Wed, 14 Oct 2026 14:01:35 GMT</pubDate><content:encoded><![CDATA[<p>At 06:00 AM in Da Nang, Vietnam, while most people are just waking up, nearly <strong>1,000 calisthenics athletes</strong> open the <strong>Winter Arc</strong> mobile PWA simultaneously to log their morning workouts and protect their daily streaks.</p>
<p>Behind the scenes, there is no $5,000/month AWS Kubernetes cluster. The entire production ecosystem—serving <strong>1,100+ weekly active users</strong> with an average session duration of <strong>8 minutes 04 seconds</strong> and a <strong>P75 LCP of 1.12s</strong>—runs smoothly on a single <strong>8GB RAM bare-metal Linux VPS</strong>.</p>
<p>I'm <strong>Duong Phuc Khanh</strong> (mostly known in the engineering community as <strong>Kido</strong> or <strong>Khánh Dương</strong>, <a href="https://github.com/khanhduong22">@khanhduong22</a>). Over the past 7+ years—from winning <em>First Prize at Startup Runway 2018</em> (featured in <a href="https://baodanang.vn/goi-mon-an-bang-dien-thoai-thong-minh-3174905.html">Báo Đà Nẵng</a>) and spending 6 years architecting financial systems at <em>FPT Software (SBI Lab)</em> to leading AI-Native systems at <em>Tech Pulse</em>—I've obsessed over one question:</p>
<blockquote>
<p><strong>How can a tiny, AI-augmented engineering team ship like a 20-person department without sacrificing production reliability?</strong></p>
</blockquote>
<p>Here are the two core architectural pillars that made it possible—and the full story behind my 114-episode engineering war journal, <a href="https://truyen.khanhdp.com"><strong>Kido Chronicles</strong></a>.</p>
<hr />
<h2>Pillar 1: Taming the 6:00 AM Check-In Storm with Valkey Distributed Locks</h2>
<p>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 <strong>TOCTOU (Time-of-Check to Time-of-Use) race condition</strong>.</p>
<p>Without concurrency control, concurrent requests read the same streak state in PostgreSQL, resulting in duplicate streak increments, corrupted leaderboard scores, and database lock contention.</p>
<h3>The Fix: Sub-5ms Idempotent Mutex in Valkey 8</h3>
<p>Instead of relying on heavy <code>SERIALIZABLE</code> database transactions that choke connection pools under burst load, we guard the state transition at the edge using an atomic <strong>Valkey/Redis Distributed Lock</strong> (<code>SET NX PX</code>) paired with an idempotency key:</p>
<pre><code class="language-typescript">// 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 &lt;2ms
  return this.getCachedCheckInStatus(userId, workoutDate);
}
</code></pre>
<p>Combined with a <strong>Service Worker Offline Outbox</strong> on the client and <strong>Caddy 2</strong> native reverse-proxying, our p99 check-in latency dropped from <strong>800ms+ to under 5ms</strong> with zero duplicate writes.</p>
<hr />
<h2>Pillar 2: The 7-Rung "Ponytail" Philosophy &amp; <code>agent-harness-kit</code></h2>
<p>To maintain <strong>4x delivery velocity</strong> across products like <a href="https://index.vn">Index.vn</a>, <a href="https://linkpul.com">Linkpul</a> (50,000+ req/sec short-link gateway), and <a href="https://vantoicalis.com">Winter Arc</a>, I built <a href="https://github.com/khanhduong22/agent-harness-kit"><strong>agent-harness-kit</strong></a>—a multi-agent orchestration framework for Claude Code, Cursor, Gemini, and Google Antigravity.</p>
<p>Every autonomous sub-agent operates in an isolated Git worktree and is governed by what I call the <strong>7-Rung Ladder</strong>:</p>
<ol>
<li><p><strong>Does this need to exist at all? (YAGNI)</strong></p>
</li>
<li><p><strong>Is it already in the codebase?</strong></p>
</li>
<li><p><strong>Does the standard library solve it?</strong></p>
</li>
<li><p><strong>Does a native platform feature (HTML/CSS/PostgreSQL constraint) cover it?</strong></p>
</li>
<li><p><strong>Does an already-installed package handle it?</strong></p>
</li>
<li><p><strong>Can it be written in one clear line?</strong></p>
</li>
<li><p><strong>Only then: write the minimum production-grade code.</strong></p>
</li>
</ol>
<p>Before any PR can merge, it must pass <strong>7 automated verification gates</strong>: AST linting, strict TypeScript typecheck, SonarQube smell checks, unit tests, and headless <strong>Playwright E2E tests with real-time video telemetry</strong>.</p>
<hr />
<h2>Explore the Full Architecture &amp; War Stories</h2>
<p>If you enjoy deep-dive postmortems, distributed systems math, and real production numbers:</p>
<ul>
<li><p>🌐 <strong>Official Hub &amp; Architecture Case Studies</strong>: <a href="https://khanhdp.com">khanhdp.com</a></p>
</li>
<li><p>📖 <strong>Full Biography &amp; Engineering Philosophy</strong>: <a href="https://khanhdp.com/about">khanhdp.com/about</a></p>
</li>
<li><p>🔥 <strong>Kido Chronicles (114 Real Production Postmortems)</strong>: <a href="https://truyen.khanhdp.com">truyen.khanhdp.com</a></p>
</li>
<li><p>💻 <strong>Open-Source Multi-Agent Harness</strong>: <a href="https://github.com/khanhduong22/agent-harness-kit">github.com/khanhduong22/agent-harness-kit</a></p>
</li>
<li><p>🏛️ <strong>Wikidata Entity</strong>: <a href="https://www.wikidata.org/wiki/Q141718572">Q141718572</a></p>
</li>
</ul>
]]></content:encoded></item></channel></rss>