<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Karan Bhansali on Medium]]></title>
        <description><![CDATA[Stories by Karan Bhansali on Medium]]></description>
        <link>https://medium.com/@karan.bhansali42?source=rss-36fc831f9f28------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Karan Bhansali on Medium</title>
            <link>https://medium.com/@karan.bhansali42?source=rss-36fc831f9f28------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 06:23:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karan.bhansali42/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Your 100-Thread Server Crawls at 5% CPU (And When Synchronous Code Wins)]]></title>
            <link>https://medium.com/@karan.bhansali42/why-your-100-thread-server-crawls-at-5-cpu-and-when-synchronous-code-wins-83bd450003c6?source=rss-36fc831f9f28------2</link>
            <guid isPermaLink="false">https://medium.com/p/83bd450003c6</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[synchronous]]></category>
            <category><![CDATA[core-fundamental]]></category>
            <dc:creator><![CDATA[Karan Bhansali]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 01:24:20 GMT</pubDate>
            <atom:updated>2026-12-03T01:24:20.514Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why 90 ms out of 95 ms goes to waiting on someone else, how Little’s Law caps a 100-thread pool, and the three cheaper fixes before reaching for async.</h3><p>Walk into a DMV with one clerk and thirty people in line. The clerk finishes with person one, calls person two, finishes with person two, and calls person three. Nobody moves until the person in front of them walks out.</p><p>Person thirty does not care how fast the clerk types. They care that twenty-nine people are standing ahead of them.</p><p>That is synchronous processing: one thing at a time, in order, waiting for each step to finish before starting the next. It sounds slow, and under the wrong workload it collapses, yet the entire web sits on top of a synchronous foundation (HTTP: request, wait, response). Knowing when to keep that DMV line and when to break it up saves months of wasted complexity.</p><h3>Where 95 Milliseconds Actually Go</h3><p>Every line you wrote in your first program ran synchronously. Python, Ruby, PHP, and standard Java run top to bottom by default, waiting for each line to finish before starting the next.</p><p>Look at a typical 95 ms request handling a file and a database call:</p><ul><li><strong>Read file from disk:</strong> 50 ms wait.</li><li><strong>Parse file contents:</strong> 5 ms on the CPU.</li><li><strong>Query Postgres:</strong> 30 ms wait.</li><li><strong>Send HTTP response:</strong> 10 ms wait over the network.</li></ul><p>The total time is simply the sequential sum: 50 + 5 + 30 + 10 = 95 ms. Four sequential operations that each take 25 ms will always take 100 ms total, with zero overlap.</p><p>Now split those same 95 milliseconds by what the processor was actually doing. <strong>Five milliseconds</strong> went to computing. <strong>Ninety milliseconds</strong> went to sitting blocked, waiting for disk, database, and network responses.</p><p>That is the hidden trap in synchronous code: a blocking network call looks identical in syntax to math on the CPU. Around 95% of the request consists of a thread held open in memory while some other machine does the work.</p><h3>How a 100-Thread Server Runs Out of Road</h3><p>Imagine a synchronous web server configured with <strong>100 threads</strong>, like a classic Tomcat, JBoss, Django, or Flask setup before async. Each incoming request grabs a thread from line one and holds it until the response goes out.</p><p>When requests 1 through 100 arrive together, all 100 threads stay busy waiting on the database. Request 101 lands in a queue, even while your CPU graphs look nearly idle.</p><p>Little’s Law (Threads / Seconds Per Request) sets a hard ceiling on how many requests per second that server can handle:</p><ul><li><strong>10 ms per request:</strong> 10,000 req/s</li><li><strong>100 ms per request:</strong> 1,000 req/s</li><li><strong>500 ms per request:</strong> 200 req/s</li><li><strong>2,000 ms per request:</strong> 50 req/s</li></ul><p>Notice the trap you do not control. If a downstream service slows down from 100 ms to 500 ms and you change zero lines of your own code, your server&#39;s maximum capacity drops by <strong>80%</strong> overnight, from 1,000 to 200 requests per second. That is why Java teams spend half their lives tuning thread pool sizes: the pool is the only half of the fraction they can touch.</p><h3>When Synchronous Is Actually the Right Call</h3><p>Synchronous code gets a bad reputation because people reach for it in the wrong places, yet waiting is a feature whenever order and correctness outrank raw speed:</p><ul><li><strong>Bank transfers:</strong> Moving 5,000 dollars from savings to checking requires debiting savings, waiting for confirmation, and only then crediting checking. Fire both in parallel and a failed debit creates 5,000 dollars out of thin air.</li><li><strong>ACID database transactions:</strong> Every BEGIN TRANSACTION ... COMMIT block expects each step to confirm before the next one runs.</li><li><strong>Fast CRUD endpoints:</strong> A simple REST handler that reads from Postgres and returns JSON in 15 ms or 20 ms gains nothing from async overhead.</li></ul><h3>Four Thresholds and the Decision Order</h3><p>Measure how long the work takes before rewriting your architecture:</p><ul><li><strong>Simple read and return (</strong><strong>15 ms):</strong> Perfect. Leave it synchronous.</li><li><strong>Three sequential DB queries at </strong><strong>10 ms each (</strong><strong>30 ms):</strong> Fine. Under 100 ms, stay synchronous.</li><li><strong>Five independent API calls at </strong><strong>200 ms each (</strong><strong>1,000 ms):</strong> Terrible sequentially, yet fixable by running all five concurrently in 200 ms without rewriting the whole service around async queues.</li><li><strong>File upload + virus scan + thumbnail (</strong><strong>5,000 ms+):</strong> User rage. Keep this out of the request handler.</li></ul><p>When a synchronous endpoint feels slow, ask four questions in strict order before defaulting to background queues:</p><ol><li><strong>Is it under </strong><strong>100 ms?</strong> Leave it alone.</li><li><strong>Do the slow steps depend on each other?</strong> If no, run them concurrently inside the same request handler (five independent 200 ms calls drop from 1,000 ms to 200 ms).</li><li><strong>Does the user need the result right now to continue?</strong> If yes, they have to wait, so speed up the underlying work rather than moving it.</li><li><strong>Is it slow (over </strong><strong>500 ms), dependent, and safe to finish later?</strong> Accept the request, return an ID, run the job in the background, and notify the user when it finishes.</li></ol><h3>Why Production Stacks Still Default to Synchronous</h3><p>Look around real production systems and synchronous code is everywhere for one reason: it is the simplest mental model to debug at 2 a.m.</p><ul><li><strong>PHP and WordPress:</strong> One process per request, top to bottom, then gone. For 15 years, that simple synchronous loop powered 40% of the internet.</li><li><strong>Java (Tomcat and JBoss):</strong> Thread-per-request stayed the enterprise default until pool limits forced tuning or reactive rewrites.</li><li><strong>Django and Flask:</strong> Synchronous handlers by default; Django did not even ship async support until version 3.1 in 2020, fifteen years after creation, and most production Django apps still run synchronously.</li></ul><p>Async is the last resort, not the starting line. Keep code synchronous and readable until your measurements cross 500 ms or your thread pool starts queueing while the CPU sits asleep.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83bd450003c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why a Gigabit Link Still Feels Like Dial-Up (And How Bandwidth Works)]]></title>
            <link>https://medium.com/@karan.bhansali42/why-a-gigabit-link-still-feels-like-dial-up-and-how-bandwidth-works-2a80839c221e?source=rss-36fc831f9f28------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a80839c221e</guid>
            <category><![CDATA[fundamentals]]></category>
            <category><![CDATA[bandwidth]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Karan Bhansali]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 01:16:46 GMT</pubDate>
            <atom:updated>2026-12-03T01:16:46.589Z</atom:updated>
            <content:encoded><![CDATA[<h3>How pipe width caps throughput, why a 1 Gbps ocean link stalls at 3.5 Mbps, and two afternoon tests to spot the real bottleneck.</h3><p>You can give a server sub-millisecond latency and plenty of worker threads, yet a user trying to load a 4K stream over a 10 Mbps line will still stall. Netflix recommends <strong>25 Mbps</strong> for 4K video, and no amount of backend tuning pushes 25 megabits per second through a 10-megabit connection.</p><p>Latency measures how fast one request travels. Throughput measures how many requests finish per second. <strong>Bandwidth</strong> sets the third limit: how wide the pipe is in the first place.</p><p>That pipe width decides what AWS charges you per gigabyte leaving a data center, why an app flies on office Wi-Fi while choking on cellular data, and why adding more servers sometimes changes nothing at all.</p><h3>Bits, Bytes, and Where 35% of Your Link Vanishes</h3><p>Bandwidth is the maximum amount of data a network link can carry in a given window, measured in bits per second (bps), kilobits (Kbps), megabits (Mbps), or gigabits (Gbps).</p><p>Network speeds use lowercase <strong>bits</strong>, while file sizes use uppercase <strong>bytes</strong> (8 bits = 1 byte). A 100 Mbps internet plan tops out at <strong>12.5 MB/s</strong>, which surprises nearly everyone the first time they time a large download.</p><p>Even then, you rarely see the full 12.5 MB/s because <strong>throughput can never exceed bandwidth</strong>, and overhead eats away at the pipe in layers:</p><ul><li><strong>100 Mbps:</strong> what the link is sold as.</li><li><strong>97 Mbps:</strong> after Ethernet framing.</li><li><strong>93 Mbps:</strong> after IP and TCP headers.</li><li><strong>91 Mbps:</strong> after TLS record overhead.</li><li><strong>82 Mbps:</strong> after packet retransmissions.</li><li><strong>65 Mbps:</strong> what your application actually measures.</li></ul><p>Notice the split there. Protocol headers and encryption take about 9% combined. Packet loss and sharing the path with other traffic at the bottom take 27%. When someone suggests inventing a denser wire format to speed up a slow transfer, they are chasing the 9% while ignoring the 27% caused by distance and contention.</p><h3>Eight Orders of Magnitude Between Your Server and Your User</h3><p>Real networks span eight orders of magnitude from a weak cell signal to the cables under the Atlantic:</p><ul><li><strong>3G mobile:</strong> 1–10 Mbps (around 5 Mbps typical)</li><li><strong>4G LTE mobile:</strong> 10–50 Mbps (around 30 Mbps typical)</li><li><strong>Home Wi-Fi:</strong> 50–300 Mbps (around 150 Mbps typical)</li><li><strong>5G mobile:</strong> 100–1,000 Mbps (around 500 Mbps typical)</li><li><strong>Home fiber:</strong> 500–2,000 Mbps (around 1,000 Mbps typical)</li><li><strong>Data center server-to-server link:</strong> 10–100 Gbps (around 25 Gbps typical)</li><li><strong>Submarine intercontinental fiber cable:</strong> 200+ Tbps per cable</li></ul><p>A server-to-server link inside a data center runs roughly <strong>1,000 times wider</strong> than a home or mobile connection. The exact same JSON payload that looks instantaneous in staging can drag on a phone riding the train.</p><h3>How Latency, Bandwidth, and Throughput Fit Together</h3><p>Think of a highway between two cities:</p><ul><li><strong>Latency (milliseconds):</strong> how long one car takes to drive from city A to city B. Set mostly by distance, then queueing and processing. Adding ten extra lanes will not make one car arrive sooner.</li><li><strong>Bandwidth (Mbps or Gbps):</strong> the number of lanes on the highway. Set by the physical link and what you pay for. This is the capacity ceiling everything else lives under.</li><li><strong>Throughput (requests/sec or Mbps):</strong> cars actually passing the tollbooth per hour. Set by whichever of latency or bandwidth runs out first, minus congestion and loss. Adding lanes only helps if bandwidth was the bottleneck.</li></ul><p>Two of those are properties of the road, and throughput is simply the score you measure after congestion takes its cut. Three everyday combinations show how they interact:</p><ul><li><strong>High bandwidth, low throughput:</strong> A 10-lane highway with 5 cars on it, like browsing plain text articles over a gigabit fiber plan.</li><li><strong>Low bandwidth bottleneck:</strong> A 2-lane road flooded by 1,000 cars during a live stream, causing queues, rising latency, and capped delivery.</li><li><strong>High bandwidth, high latency:</strong> A 20-lane highway stretching across a huge gap, like satellite internet with wide capacity and 500+ ms round-trip delays.</li></ul><h3>The Bandwidth-Delay Product: Why Fast Links Run Slow</h3><p>Multiply bandwidth by round-trip latency and you get the <strong>Bandwidth-Delay Product</strong>, the amount of data sitting physically in flight on the wire before an acknowledgement returns.</p><p>On a <strong>1 Gbps</strong> link, that in-flight volume grows fast with distance:</p><ul><li><strong>Same data center (1 ms RTT):</strong> 125 KB in flight.</li><li><strong>Same continent (30 ms RTT):</strong> 3,750 KB in flight.</li><li><strong>Across an ocean (150 ms RTT):</strong> 18,750 KB in flight.</li></ul><p>If a TCP sender uses an old unscaled <strong>64 KB</strong> window, it hits pause after sending 64 KB and waits 150 ms for the ocean round trip before sending the next chunk. That tiny ceiling caps a 1 Gbps intercontinental link at roughly <strong>3.5 Mbps</strong>. Modern TCP window scaling and bulk tools opening multiple parallel connections exist specifically to keep the pipe full while packets are mid-flight.</p><h3>Two Afternoon Tests to Find Which Lever to Pull</h3><p>Most wasted performance weeks come from pulling the right lever on the wrong bottleneck. Next time an endpoint feels slow, run two quick tests:</p><ol><li><strong>Make the payload bigger.</strong> If latency jumps proportionally with payload size, you are <strong>bandwidth-bound</strong>. Compress responses, resize images, paginate lists, or put a CDN in front.</li><li><strong>Send more concurrent users.</strong> If things break as concurrency climbs while payload size stays tiny, you are <strong>throughput-bound</strong>. Add servers, batch requests, or push non-urgent work to async queues.</li><li><strong>Neither moves the problem?</strong> You are <strong>latency-bound</strong> on a single trip. Move endpoints closer together, cache repeat lookups, or eliminate extra round trips.</li></ol><h3>CDNs and the Stadium Cell-Tower Problem</h3><p>CDNs are usually taught as a latency trick, yet they were invented to solve bandwidth math. Serving every Netflix viewer from one building in Virginia would demand an aggregate link no single facility can buy, concentrically spiking right during a major release. Copying video to <strong>200 edge locations</strong> divides site bandwidth to <strong>1/200th</strong> per location, keeps each city’s failure isolated so traffic reroutes to the next nearest edge, and trims user round-trip distance along the way.</p><p>Knowing that also tells you when a CDN will fail you: if your bottleneck is one slow database query, replicating servers to 200 cities just replicates a slow query 200 times.</p><p>On the client side, remember that bandwidth is shared. A single 4G cell tower offers roughly <strong>150 Mbps</strong> total capacity:</p><ul><li><strong>Alone in a field:</strong> 150,000 kbps (150 Mbps) for your phone.</li><li><strong>On a busy street (~150 people):</strong> 1,000 kbps (1 Mbps) each.</li><li><strong>In a stadium (~10,000 active phones):</strong> <strong>15 kbps each</strong>.</li></ul><p>Four signal bars only measure radio quality, not tower contention. Inside a packed stadium, a modern 4G phone gets roughly the speed of a <strong>1998 dial-up modem</strong>. That is why front-end and API teams shrink payloads aggressively: convert a 5 MB photo to a 200 KB WebP file, paginate endpoints to 20 items instead of 10,000, lazy-load off-screen assets, and ship progressive previews so the app still holds together when nobody has 30 Mbps to spare.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a80839c221e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Fast Code Still Crashes Under Load (And How Throughput Works)]]></title>
            <link>https://medium.com/@karan.bhansali42/why-fast-code-still-crashes-under-load-and-how-throughput-works-6bfe2e13c6c0?source=rss-36fc831f9f28------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bfe2e13c6c0</guid>
            <category><![CDATA[fundamentals]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[throughput]]></category>
            <dc:creator><![CDATA[Karan Bhansali]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 01:06:03 GMT</pubDate>
            <atom:updated>2026-12-03T01:06:03.710Z</atom:updated>
            <content:encoded><![CDATA[<h3>How systems handle millions of users at once, why 70% CPU is the real limit, and how Little’s Law exposes hidden bottlenecks.</h3><p>A server that answers one request in two milliseconds feels instant on your laptop. Put that same single-threaded prototype in front of a lunch-hour traffic spike and it falls over after a few hundred requests a second.</p><p>Latency measures how long one request takes. Throughput measures how many requests finish in a given window, and real production traffic tests the second number far harder than the first:</p><ul><li>One ordinary application server handles around <strong>2,000</strong> requests per second.</li><li><strong>Visa</strong> processes roughly <strong>65,000</strong> transaction messages per second at peak.</li><li><strong>Google</strong> handles over <strong>99,000</strong> search queries every single second.</li><li><strong>Twitter/X</strong> absorbs surges past <strong>140,000</strong> tweets per second during major global events.</li></ul><p>Going from one ordinary box at 2,000 requests per second to 140,000 requests per second has almost nothing to do with shaving another millisecond off a single call. It is about how many requests a system can finish in parallel without collapsing.</p><h3>What Throughput Actually Measures</h3><p>Throughput is the volume of work a system completes per unit of time. Depending on the layer you are measuring, teams track four units:</p><ul><li><strong>Requests per second (RPS):</strong> completed API or HTTP calls.</li><li><strong>Transactions per second (TPS):</strong> completed database or payment transactions.</li><li><strong>Queries per second (QPS):</strong> database queries processed.</li><li><strong>Megabits per second (Mbps):</strong> network data transferred.</li></ul><p>Picture a restaurant kitchen. How fast a chef cooks one dish is latency, say 6 minutes from ticket to pass. How many meals the kitchen sends out in an hour is throughput. Every piece of the kitchen maps directly to backend infrastructure:</p><ul><li><strong>Customers served per hour:</strong> Requests per second</li><li><strong>Number of tables:</strong> Available connections</li><li><strong>Number of chefs in the kitchen:</strong> CPU cores or worker threads</li><li><strong>Stoves and ovens:</strong> Memory and processing power</li><li><strong>Time to cook one dish:</strong> Latency for a single request</li></ul><p>One chef cooking 6-minute dishes finishes <strong>10 meals per hour</strong>. Put 4 chefs in the same kitchen with the same recipe and the kitchen finishes <strong>40 meals per hour</strong>. Throughput quadrupled, while the time to cook any individual meal stayed pinned at 6 minutes.</p><p>That gap explains why adding servers fails to fix a slow page. If one user waits too long for a response, more servers will not speed up that single request. If the site collapses when everyone logs in at noon, more servers is the exact fix.</p><h3>Stop Treating Latency and Throughput as One Dial</h3><p>Latency and throughput sit on two separate axes, and real systems occupy all four quadrants:</p><ul><li><strong>Fast and large:</strong> A Redis GET or a CDN edge node answers in single-digit milliseconds while serving massive request volume.</li><li><strong>Slow but enormous:</strong> A nightly batch pipeline takes far longer per item, yet chews through huge totals every second.</li><li><strong>Fast, but small:</strong> A single-threaded prototype looks great in local benchmarks for one caller and runs out of capacity early.</li><li><strong>Slow and small:</strong> A legacy SOAP endpoint sits in the bottom-right corner when nobody measures either axis.</li></ul><p>Moving up means adding capacity across more workers or machines. Moving left means optimizing the hot path so each item finishes sooner.</p><h3>Why Overloaded Servers Drop Traffic Instead of Waiting</h3><p>Think of a highway with toll lanes. Suppose 100 requests per second arrive at a single server whose capacity is 20 requests per second. Out of every ten arriving requests, two get an OK and eight get dropped.</p><p>Those eight requests do not wait politely in a slower line. They fail. From a user’s browser, a dropped request looks the same as a dead site.</p><p>Adding servers widens the road: three servers turn two OK responses into six, and five servers cover all ten. Sizing a fleet to match peak demand down to the last machine still leaves you exposed, though. The moment one server reboots or crashes, you drop straight back into failing traffic, which is why production clusters run with spare lanes on purpose.</p><h3>The 70% Cliff and Why Overload Makes Systems Slower</h3><p>Teams measure throughput ceilings with load tests: ramp traffic upward, count successful completions per second, and watch four signals together:</p><ul><li><strong>Requests per second (RPS):</strong> How many complete requests succeed each second</li><li><strong>P50 / P99 latency:</strong> Median wait vs. the slowest 1%, which spikes hard near capacity</li><li><strong>Error rate:</strong> Percentage of failures once you pass the ceiling</li><li><strong>CPU / Memory usage:</strong> Resource saturation, where 100% CPU caps further throughput</li></ul><p>Queueing math creates a sharp cliff long before a server hits 100% utilization. Under a basic queueing curve where response time = service time / (1 - utilization), a 10 ms request behaves smoothly through light traffic and then explodes near the top:</p><ul><li>From <strong>10% to 50% busy</strong>, response time barely moves.</li><li>At <strong>70% busy</strong>, a 10 ms piece of work takes <strong>33 ms</strong> end to end, because 70% of that time is spent waiting in line.</li><li>Between <strong>90% and 99% busy</strong>, response time jumps by a factor of 10.</li></ul><p>That is why production systems target <strong>60–70% of maximum throughput</strong>, and why an engineer who spots a box at 95% CPU treats it as already broken rather than “almost full.”</p><p>Push past the ceiling in a real load test and throughput does not plateau. It collapses:</p><ul><li><strong>500 RPS offered:</strong> 500 completed.</li><li><strong>1,500 RPS offered:</strong> 1,500 completed.</li><li><strong>2,000 RPS offered:</strong> 1,500 completed.</li><li><strong>3,000 RPS offered:</strong> <strong>900 completed</strong>.</li></ul><p>Doubling load from 1,500 to 3,000 requests per second cut successful completions from 1,500 down to 900. Once a service saturates, it burns CPU on requests that already timed out upstream, clients retry and multiply incoming traffic at the worst moment, and threads spend more time on bookkeeping than real work. Load shedding solves this by rejecting excess requests immediately so the remaining traffic still finishes.</p><h3>Little’s Law: The Equation Connecting Both Metrics</h3><p>One formula ties concurrency, throughput, and latency together:</p><p><strong>Concurrency = throughput x latency</strong></p><p>Suppose your service receives <strong>500 req/s</strong> and each request takes <strong>0.20 s</strong> (200 ms). Multiply them together and you need <strong>100 threads in flight</strong>. With a 200-thread pool, half the pool sits spare.</p><p>Now freeze traffic at 500 req/s and let a downstream database slow down from 200 ms to 400 ms. Required concurrency jumps from 100 threads to all 200 without a single extra user showing up, which is how a slow dependency knocks over a service whose own code never changed.</p><p>Read the equation backwards and it hands you the hard ceiling for free:</p><p><strong>Max throughput = 200 threads / 0.20 s = 1,000 req/s</strong></p><p>No configuration tweak pushes a 200-thread pool at 200 ms latency past 1,000 requests per second.</p><h3>Six Ways to Increase Throughput</h3><p>Teams raise that ceiling using six main levers:</p><ul><li>Vertical scaling — Buy a bigger, faster server — Widen each lane so cars move faster</li><li>Horizontal scaling — Add more servers — Build more highways</li><li>Caching — Serve repeat results without recomputing — Open express lanes for regular commuters</li><li>Async processing — Move non-urgent work to background queues — Keep delivery trucks off daytime lanes</li><li>Database optimization — Fix slow queries and missing indexes — Clear the bottleneck intersection</li><li>Load balancing — Spread incoming traffic across instances — Direct cars toward emptier routes</li></ul><p>The first two options trade convenience against resilience, and they solve different problems:</p><ul><li><strong>Vertical scaling</strong> (one bigger machine) increases throughput until you hit the largest instance a cloud vendor rents, then stops for good. Faster CPUs genuinely lower single-request latency, and resizing an instance takes an afternoon. The catch is cost and blast radius: top-tier machines cost superlinearly more, and if that single machine dies, everything goes down with it.</li><li><strong>Horizontal scaling</strong> (more machines) grows throughput roughly linearly as long as you keep adding nodes, and surviving a dead server becomes routine once you keep enough spare headroom. Adding instances does nothing for single-request latency, though, and your application has to stay stateless enough for any machine to handle any request.</li></ul><p>For most early systems, vertical scaling buys a year of breathing room in a single afternoon. Moving to multiple machines usually becomes unavoidable for availability before raw throughput alone demands it: once your system can survive losing a box without dropping users, horizontal throughput comes along as a side effect.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bfe2e13c6c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why 100 Milliseconds Costs Millions (And Where Latency Hides)]]></title>
            <link>https://medium.com/@karan.bhansali42/why-100-milliseconds-costs-millions-and-where-latency-hides-7fe351a56181?source=rss-36fc831f9f28------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fe351a56181</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[latency]]></category>
            <category><![CDATA[fundamentals]]></category>
            <dc:creator><![CDATA[Karan Bhansali]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 00:57:32 GMT</pubDate>
            <atom:updated>2026-12-03T00:57:32.690Z</atom:updated>
            <content:encoded><![CDATA[<h3>What happens inside a single page load, from speed-of-light physics to p99 tail math.</h3><p>Amazon once ran an experiment where they added 100 milliseconds of delay to page loads. A tenth of a second is faster than a finger snap, yet revenue dropped 1%. At Amazon’s scale, that delay cost hundreds of millions of dollars a year.</p><p>Google ran a similar test and slowed search results by 500 milliseconds. Traffic fell 20%, meaning one in five people bounced. Notice the curve there: five times more delay caused twenty times more drop-off. Nobody filed support tickets or complained in either experiment. Users felt the drag subconsciously and hit the back button before thinking about why.</p><p>That wait time is latency, and caching, CDNs, load balancers, and database indexes all exist to cut it down.</p><h3>What Latency Actually Feels Like</h3><p>Think about ordering an Uber in Manhattan on a Friday night. You tap “Request,” and then you stand on the curb while the driver sees the ping, accepts it, sits in gridlock, and pulls up to your pin. That entire wait from tap to curb is latency, measured in milliseconds. Bandwidth measures how much data moves at once; latency measures how long the round trip takes. You can send a single byte from New York to Sydney and still pay 200 milliseconds of physics.</p><p>Decades of human-computer interaction research map those wait times to five consistent user thresholds:</p><ul><li><strong>Under 100 ms:</strong> Instant, with zero perceived delay</li><li><strong>100–300 ms:</strong> Slight lag, still snappy</li><li><strong>300 ms–1 s:</strong> You notice you are waiting for something</li><li><strong>1–3 s:</strong> Frustration sets in; you glance at another tab</li><li><strong>Over 3 s:</strong> Roughly 40% of people leave</li></ul><p>Because perception scales logarithmically, only 200 milliseconds separate “instant” from “snappy,” while two full seconds separate “frustration” from “gone.” Where you start determines whether an optimization matters. Shaving a second off a 3.2-second page rescues real users, whereas cutting 90 ms down to 40 ms feels identical.</p><h3>Anatomy of a 250-Millisecond Click</h3><p>Most developers focus on application code when a page feels slow, even though the network burns more than half the budget before your server runs a line. A typical 250 ms first visit breaks down like this:</p><ol><li>DNS lookup turns the domain into an IP address (30 ms).</li><li>TCP handshake opens the connection (35 ms).</li><li>TLS handshake negotiates encryption (70 ms).</li><li>Your server routes the request, runs logic, and queries Postgres (45 ms total).</li><li>The response travels back and the browser paints the screen (90 ms).</li></ol><p>Setup alone takes 135 ms. Come back to the same page a minute later and those first three steps drop to zero because your OS cached the DNS record, the TCP connection stayed open, and TLS resumed without a full handshake. The page loads in 135 ms, 46% faster, while your server code and rendering stay at 45 ms and 90 ms. That is why connection reuse, HTTP/2, and TLS 1.3 session resumption pay off, and why timing a page after ten local refreshes hides the 250 ms load a first-time visitor gets from search.</p><h3>Five Places Latency Hides</h3><p>When a team says “we have a latency problem,” you need to know which of five buckets grew because each one has a different fix.</p><p><strong>Network latency</strong> (5 ms healthy, 200 ms bad) comes down to physics. Light in fiber-optic glass travels around 200,000 km/s, two-thirds of its speed in a vacuum. From Virginia to Mumbai (about 12,900 km), the theoretical floor for a round trip is 130 ms, and real cables take 180–200 ms. Put a CDN edge 50 km away and the trip takes 0.5 ms; send a packet from New York to Sydney (15,990 km) and it takes 160 ms; bounce off a geostationary satellite (143,144 km up and down, even at full vacuum speed) and it takes 477 ms. Distance beats medium every time.</p><p><strong>Processing latency</strong> (8 ms healthy, 3,000 ms bad) is your server thinking. A clean endpoint finishes in 5–10 ms, while a GraphQL resolver triggering N+1 queries can stall for seconds.</p><p><strong>Queue latency</strong> (0.5 ms at 2 AM, 10,000 ms during a spike) is the sneaky one. Your request reaches a server whose worker threads are busy handling 500 other requests, so yours sits in line. A 20,000x swing makes queue time calm overnight and brutal during a launch.</p><p><strong>Database latency</strong> (3 ms healthy, 2,000 ms bad) separates indexed lookups from full scans. A primary-key lookup in Postgres takes 1–5 ms, while an unindexed join across three tables can cross 500 ms. Adding a single missing index can drop a 1.2-second query to 3 milliseconds.</p><p><strong>Serialization latency</strong> (0.5 ms healthy, 20 ms bad) covers converting objects to JSON or protobuf and stays tiny unless payloads grow huge.</p><p>Total latency equals the sum of all five, so the biggest bar decides what the user feels. On a 600 ms page where network takes 20 ms, server code takes 30 ms, and an unindexed query takes 550 ms, driving network latency to zero leaves 580 ms, and driving server code to zero leaves 570 ms. Adding that one missing database index drops the page to 63 ms. Measure every span before writing code.</p><h3>Why Averages Lie</h3><p>A 70 ms average looks healthy on a dashboard, yet it can hide a median (p50) of 40 ms, p90 of 95 ms, p99 of 420 ms, and p99.9 of 2,300 ms.</p><p>Basic probability turns that rare 1% tail into an everyday failure. If one page load makes 100 backend calls and 1% of calls are slow (p99), the odds of escaping a slow call across all 100 are 0.99¹⁰⁰, about 37%. Roughly 63% of page loads wait on a slow call, and the users sitting in that tail are often the customers with the most data.</p><h3>How Amazon, Google, and Netflix Shave Milliseconds</h3><p>Big engineering teams tackle those bottlenecks across four levers:</p><p><strong>Amazon precomputes overnight.</strong> Along with running 400+ CloudFront edge locations to keep images near users, Amazon avoids running live ML inference for “Recommended for You” on every page load. A batch job runs for 40 minutes at 03:00 and writes snapshots to cache by 03:40, so a shopper at 10:14 gets a 5 ms cache read instead of a 500 ms computation. You trade freshness for speed: an order placed at 09:00 is missing until the next run, making staleness a product decision rather than a pure engineering one.</p><p><strong>Google hedges slow requests and lives in RAM.</strong> Google routes traffic over private global fiber and serves search results from main memory rather than disk. Storage and network speeds span nine orders of magnitude:</p><ul><li>L1 cache: 0.5 ns</li><li>L2 cache: 7 ns</li><li>Main memory (RAM): 100 ns</li><li>SSD random read: 16,000 ns</li><li>Round trip inside one datacenter: 500,000 ns (0.5 ms)</li><li>Spinning disk random read: 10,000,000 ns (10 ms)</li><li>California to Netherlands round trip: 150,000,000 ns (150 ms)</li></ul><p>Reading from RAM is 100,000 times faster than reading from a spinning disk, and making a datacenter network hop to skip a RAM lookup is 5,000 times slower. To handle random tail spikes like garbage-collection pauses, Google sends a request to Server A, waits until p95 (around 120 ms), and then sends the same request to Server B. If B replies in 45 ms, the client uses B and cancels A. Holding until p95 adds about 5% extra traffic while cutting most tail latency, because two independent replicas rarely stall at the same instant.</p><p><strong>Netflix puts hardware inside your ISP.</strong> Through Open Connect, Netflix ships custom servers into ISP datacenters so video travels one or two local hops instead of crossing congested peering points, and new seasons push once off-peak instead of hitting origin servers a million times at launch. On your device, while you watch Episode 4 (where over 80% of viewers continue to Episode 5), the app pre-buffers the next episode so playback starts immediately.</p><p>Smaller teams can use the same playbook without custom hardware: put static files on a $20/month CDN, cache slow computations that rarely change, and measure every span in a trace before optimizing the biggest bar.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fe351a56181" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Become a Forward Deployed Engineer: Ship AI for Real Customers — Part 1: The Job and the Customer]]></title>
            <link>https://medium.com/@karan.bhansali42/become-a-forward-deployed-engineer-ship-ai-for-real-customers-part-1-the-job-and-the-customer-5b514c7d4944?source=rss-36fc831f9f28------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b514c7d4944</guid>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[forward-deployed-engineer]]></category>
            <dc:creator><![CDATA[Karan Bhansali]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 06:49:06 GMT</pubDate>
            <atom:updated>2026-11-26T06:49:06.293Z</atom:updated>
            <content:encoded><![CDATA[<p>A forward deployed engineer (FDE) is a software engineer who embeds directly with a single customer, operating inside that customer’s environment until a piece of software reliably solves their actual problem. Because the title is still unfamiliar to most people — and carries slightly different meanings across organizations — this guide avoids personal opinions and looks directly at how hiring companies define the role themselves. Palantir originally created the position, and companies like OpenAI, Salesforce, and Ramp have published detailed accounts of how their FDE teams operate. Alongside those insights, we analyzed 41 real job postings across 18 companies to count the exact skills employers ask for.</p><p><strong>By the end of this walkthrough, you will be able to:</strong></p><ul><li>Define a forward deployed engineer in two plain sentences and explain how Palantir’s phrase <em>“one customer, many capabilities”</em> captures the role.</li><li>Trace how a real customer engagement unfolds step by step — from the first week on-site to production launch and expansion to a second team — using OpenAI’s account.</li><li>Outline what a typical workweek looks like and how much travel job postings actually require.</li><li>Identify the most frequently requested skills across real job listings, backed by actual counts.</li><li>Distinguish a forward deployed engineer from a product engineer, consultant, solutions engineer, and deployment strategist using the companies’ own definitions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*JJ9PfnZbRfWXQzzO6Igemg.png" /></figure><p><strong>The Problem: “We Want AI for Claims” — Without Defining What That Means</strong></p><p>Picture the head of claims at a mid-sized car and home insurer. Every day, her team of <em>adjusters</em> — the people who check each <em>claim</em> (a customer’s request to be paid for a loss, such as a cracked windshield or hail-damaged car) against the policy and decide the payout — takes about three weeks to settle a simple case. After every winter storm or hail season, the pile of open claims grows.</p><p>Last week, she watched a demo where an AI model read a claim file and wrote a solid summary in a few seconds. So she calls you with the line that starts almost every enterprise AI project: <em>“We want AI for claims.”</em></p><p>The demo was real, but it was set up to succeed on clean, hand-picked examples. Her team’s actual work lives in a very different environment:</p><ul><li>An aging database where dates are stored in two separate formats.</li><li>Nightly files dropped onto a server by outside systems at 2:00 a.m.</li><li>A legacy policy service that answers only one page at a time.</li><li>Scanned documents.</li></ul><p>Surrounding those systems are real-world constraints: adjusters who need to trust the tool before using it, a security team with a long questionnaire, and strict laws governing customer personal data. None of that showed up in the demo.</p><p>Someone has to close the distance between <em>“the model did it in a demo”</em> and <em>“the claims team relies on it every morning.”</em> OpenAI calls that distance <strong>“the deployment gap”</strong> — and the person who closes it, one customer at a time, is the <strong>forward deployed engineer</strong>.</p><h3>Words for this lesson</h3><p>These words come back all through the course. Each one has an everyday picture to hold on to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vuxtp3JUX2y5rtyIZAKJA.png" /></figure><h3>The customer in this course: AMC Mutual, a fictional insurer</h3><p><strong>Core idea:</strong> The customer is invented, every record is generated, and the synthetic records are designed so none of them can ever belong to a real person.<br>To see how a forward deployed engineer works step by step, we need a realistic customer environment without exposing anyone’s private data. Think of the patients medical students practice on: trained actors describing symptoms that aren’t their own. They are realistic enough to train on, while keeping real people’s records safe.</p><p>For this walkthrough, our customer is AMC <strong>Mutual Insurance Company</strong> — an entirely fictional company invented to mirror a real enterprise environment:</p><ul><li><strong>What it does:</strong> A property and casualty insurer covering personal cars and homes against loss and damage.</li><li><strong>How it’s structured:</strong> A mutual insurer — owned by its policyholders rather than shareholders.</li><li><strong>Scale and footprint:</strong> Founded in 1962 and headquartered in Harrisburg, Pennsylvania, with roughly 2,800 staff selling policies across 11 states (including California) mostly through independent agents.</li><li><strong>Financial profile:</strong> Brings in about $1.1 billion annually in premiums — profitable, established, and slow-moving.</li></ul><p><em>(Before picking the name, we verified it wasn’t taken: web searches returned only English villages named AMC, SEC filings showed no matching company, and the matching web domains were unregistered.)</em></p><p><strong>Why Every Record Is Synthetic — and Designed Never to Match a Real Person</strong></p><p>Inside AMC’s databases, every single record is <strong>synthetic</strong> — generated deterministically from a fixed starting number so the dataset stays consistent, with zero real customer data involved.</p><p>However, because an FDE has to find and mask personally identifiable information (PII) before an AI model ever touches it, the dataset intentionally plants realistic-looking details in claim notes: names, addresses, phone numbers, Social Security numbers, driver’s license numbers, and VINs. Each field is engineered so it can never accidentally belong to a real person or car:</p><ul><li><strong>Social Security numbers:</strong> Every number uses <strong>group </strong><strong>00</strong> (digits four and five)—a group the Social Security Administration never assigns (alongside serial 0000)—and avoids area codes 000, 666, and 900–999.</li><li><strong>VINs:</strong> The ninth character (the check digit) is intentionally wrong, ensuring no VIN matches an actual vehicle.</li><li><strong>Phone numbers:</strong> All numbers sit inside <strong>555-0100 to </strong><strong>555-0199</strong>, the range reserved for fiction in TV and film.</li><li><strong>Policy and claim IDs:</strong> Prefixed with <strong>BMQ</strong> (policies) and <strong>CLQ</strong> (claims) using a custom check digit.</li><li><strong>Database flag:</strong> Every row carries SYNTHETIC = true.</li></ul><p><strong>The hidden engineering trap:</strong> If you plug in an off-the-shelf PII scanner that only masks <em>valid</em> Social Security numbers, it will miss every single SSN in this database because group 00 is technically invalid—leaking sensitive-looking records straight to the LLM. That is the exact kind of subtle failure FDEs uncover before moving to production.</p><p><strong>Watch out:</strong> synthetic is not the same as masked. Synthetic data was never real. Masked data was real, and someone hid the personal parts. A tool tested only on AMC’s invalid numbers has not yet been tested on real ones.</p><p><strong>Why It Matters: Anyone Can Build a Demo — Shipping a Daily System Is the Real Job</strong></p><p>Think of a cooking show versus a restaurant kitchen. A cooking show makes a meal look effortless because all the vegetables were chopped before the cameras rolled. Running a busy restaurant kitchen every night is an entirely different job.</p><p>That difference explains why so many companies are now hiring forward deployed engineers. On <strong>13 November 2026</strong>, we scanned the public job boards of <strong>19 companies</strong> hiring FDEs and found <strong>336 open roles</strong> with <em>“forward deployed,”</em> <em>“FDE,”</em> or <em>“deployment strategist”</em> in the title. When we analyzed <strong>41 of those job postings across 18 companies</strong> in detail, one message stood out: companies aren’t hiring people to build clever demos — they want engineers who can carry a project from the first meeting to daily use.</p><p>The top skills requested across those 41 postings make that clear:</p><ul><li><strong>37 of 41</strong> ask for putting software into production and keeping it reliable</li><li><strong>36 of 41</strong> ask for owning a vague problem without being told what to do</li><li><strong>32 of 41</strong> ask for scoping and discovery</li><li><strong>32 of 41</strong> ask for building AI agents</li></ul><p>Learning how to call an LLM is the easy part. What makes or breaks an enterprise AI project is everything around the model:</p><ol><li>The first discovery meeting</li><li>The measured baseline</li><li>Legacy systems and integrations</li><li>Personal data protection</li><li>The security review</li><li>Honest proof that it works</li><li>The final handover</li></ol><p>Every AI system inside a real company has to cross that exact terrain before a team trusts it every morning — and walking through each step in order is how you learn to ship it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*huK9A7tz_s_towDlYMs1_Q.png" /></figure><p>Read the two columns step by step. On step 4, the demo has nothing to compare against, because nobody measured how long claims took before. The engagement has a number from step 1, so at step 4 it can say whether anything improved. That one difference decides most of what happens later.</p><h3>The idea: one engagement, in order, from the first call to the handover</h3><blockquote>“Every engagement runs in the same order: find the real problem, get into the systems, run a pilot, prove it, put it into production, and hand it over.”</blockquote><p>A builder never puts on the roof before laying the foundations — and a forward deployed engineer follows that same discipline.</p><p>An <strong>engagement</strong> is one complete piece of work for one customer, from the very first meeting to the day the project wraps up. Rather than jumping straight into building with AI, every real engagement moves through six stages in order:</p><ol><li><strong>Find the real problem</strong></li><li><strong>Get into the customer’s systems</strong></li><li><strong>Run a pilot</strong></li><li><strong>Prove the results</strong></li><li><strong>Put it into production</strong></li><li><strong>Hand it over</strong></li></ol><p>Here is how that entire sequence fits together in one picture — and then how each stage plays out as a real story.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*2piDjG4kEPzEwmnWAYgJ0Q.png" /></figure><p><strong>Discovery: Finding the Real Problem Behind the Request</strong></p><blockquote><em>Turn the wish into one problem and one number before anything is built.</em></blockquote><p>A good doctor never prescribes treatment simply because a patient says, <em>“I feel bad.”</em> They ask where it hurts, and they take a temperature. In the same way, <em>“We want AI for claims”</em> is a wish, not a problem you can engineer around. So the first thing you do is ask questions, and the first thing you measure is how things operate today.</p><p>Discovery is that stage: finding out what really hurts, who decides what, and which number would show that things got better. At AMC, discovery replaces the broad wish for <em>“AI for claims”</em> with a narrower, solvable problem: simple car claims — such as a cracked windshield or hail damage — take far too long to settle, many sit waiting for a supervisor because an adjuster was unsure, and the open pile is large.</p><p>Before changing anything, you need a <strong>baseline</strong> — a measurement of how things perform today. Without it, nobody can say for sure later whether the project actually helped.</p><p>We captured AMC’s baseline directly from its claims database using real SQL during a lab run on <strong>13 November 2026</strong>. Here is the exact output printed in our terminal after running make look PART=db (the same command featured in the <em>&quot;Meet AMCMutual, the customer in this course&quot;</em> walkthrough):</p><pre>== the tables you can read, and how many rows each holds<br>  CLMS_ADJUSTER           44 rows<br>  CLMS_CLAIM           6,000 rows<br>  CLMS_NOTE           18,039 rows<br>  CLMS_STATUS_REF         11 rows<br><br>== a first query, written the way most people write SQL<br>  error: relation &quot;clms_claim&quot; does not exist<br>  with the name in double quotes: 6,000 claims<br><br>== the status codes: what the column holds, and which codes are retired<br>  CLSD  Closed                         in use   3,813<br>  PAID  Payment issued                 in use   1,393<br>  PEND  Waiting for documents          in use     134<br>  ASGN  Assigned to an adjuster        in use     117<br>  INVS  Under investigation            in use      98<br>  SUPV  Referred to a supervisor       in use      68<br>  NEW   Reported, not yet assigned     in use      35<br>  CL    Closed (retired 2009)          RETIRED    264<br>  XX    Void (retired 2014)            RETIRED     39<br>  OP    Open (retired 2009)            RETIRED     21<br>  RO    Reopened (retired 2014)        RETIRED     18<br><br>== the loss dates are text, written two ways<br>  YYYY-MM-DD (since 2012)   3,926   for example 2026-01-01<br>  MMDDYYYY (old system)     2,074   for example 01012026<br><br>== today&#39;s numbers, the baseline the pilot will be judged against<br>  simple claims (glass and hail) settled: 1,480, average 20.4 days from report to close<br>  claims still open: 491; claims ever sent to a supervisor: 35.1%<br><br>== is this account really read-only?<br>  error: cannot execute UPDATE in a read-only transaction</pre><p>Four details in that terminal output capture what real-world forward deployed work looks like on day one:</p><ul><li><strong>The company is fictional, but the measurement is real.</strong> While the data generator created AMC’s claims — and effectively set how slow its process is — nobody hard-coded <strong>20.4 days</strong>. That figure came from a real SQL query on a PostgreSQL database that parsed two inconsistent text date formats into actual dates and averaged the time between report and close across <strong>1,480</strong> settled glass and hail claims. That is the exact workflow you use with a live customer.</li><li><strong>The very first standard query failed.</strong> The database tables were created in uppercase inside double quotes — a classic leftover from migrating data off a mainframe (the central computers insurers ran for decades) — so PostgreSQL refuses to find them unless you quote them too. Uncovering small quirks like this consumes much of an FDE’s first week on-site.</li><li><strong>“Open” and “settled” need strict definitions.</strong> The <strong>491</strong> open claims include <strong>21</strong> rows marked with the retired code OP and <strong>18</strong> with RO. Likewise, because the <strong>1,480</strong> settled glass and hail claims are counted by close date, they include claims closed under retired codes CL and XX (XX means void). Although retired on paper years ago, these codes still show up on <strong>2026</strong> claims because an old import pipeline still writes them. Flagging this on day one lets you tighten the definitions with the claims lead before signing off on the baseline.</li><li><strong>Your credentials are strictly read-only.</strong> The final automated check tried to alter one claim and was rejected. Every engagement starts with read-only access — you only ask for write permissions once you can justify the exact need.</li></ul><p><strong>How the Query Calculates “20.4 Days” (Step by Step)</strong></p><p>Rather than estimating by hand, the SQL query arrives at <strong>20.4 days</strong> in four plain steps:</p><ol><li><strong>Select the target records:</strong> Pull all glass and hail claims with a close date (<strong>1,480</strong> claims).</li><li><strong>Normalize the text dates:</strong> Parse both text dates on each claim into real date types, handling both legacy formats.</li><li><strong>Measure each claim’s turnaround:</strong> Subtract the report date from the close date (for instance, reported <strong>1 March</strong> and closed <strong>21 March</strong> equals <strong>20 days</strong>).</li><li><strong>Average the results:</strong> Sum all <strong>1,480</strong> durations and divide by <strong>1,480</strong> to get <strong>20.4 days</strong>.</li></ol><p>Because <strong>20.4 days</strong> is an average across <strong>1,480</strong> claims, some cases resolved much faster while others dragged on far longer — an average alone won’t show you that spread.</p><blockquote><strong><em>Watch out:</em></strong><em> A baseline is only as trustworthy as the definitions behind it. In this snapshot, “settled” still includes claims closed under retired codes </em><em>CL and </em><em>XX (void). Never quote a baseline metric to stakeholders until you and the claims lead have agreed on every definition.</em></blockquote><p><strong>Getting Into Systems You Did Not Build</strong></p><blockquote>“The data lives in old systems you did not build, and you go in carefully, with read-only access, through one private door.”</blockquote><p>A plumber called to an old house doesn’t start by knocking down walls. They look at the pipes already in place — however strange — and work with them. To build anything useful at AMC, you have to read its data where it actually lives, and almost none of it sits in a clean, modern API.</p><p>AMC’s IT team gives you access to five existing systems (hosted for this walkthrough on a single small server in your own AWS account). Even though the server has a public address to download packages, its firewall rejects all inbound internet traffic. You connect strictly through <strong>AWS Session Manager</strong> from inside AWS, so the server never opens a port to the public internet:</p><ul><li><strong>The claims database (PostgreSQL 16.6):</strong> A popular open-source database structured in an older style — uppercase table names, text dates saved in two different formats, and eleven status codes (including four retired on paper years ago that a legacy import job still stamps onto <strong>342 claims from 2026</strong>).</li><li><strong>The policy service (Legacy SOAP API):</strong> An older XML-based web service governed by a <strong>WSDL</strong> definition file. It returns <strong>100 policies per page</strong> and enforces a strict rate limit of <strong>10 requests per second</strong>.</li><li><strong>The nightly file drop (SFTP Server):</strong> Every night at <strong>2:00 a.m. Eastern time</strong>, independent agents’ systems upload a <strong>CSV</strong> of new claims — complete with duplicate rows and dollar amounts written three different ways.</li><li><strong>The document store (Amazon S3):</strong> <strong>300</strong> claim files and policy forms stored as PDFs, several of which are flat scanned images with no embedded text.</li><li><strong>The sign-in service (Keycloak 26):</strong> A real identity provider handling staff logins, standing in for AMC’s internal authentication system.</li></ul><p>Alongside those five systems sits a small <strong>work queue</strong> where adjusters pick up assigned claims. Here is what happened during the same lab run when we tested two of those systems — starting by firing <strong>40 simultaneous requests</strong> at the policy service, just like a careless script would:</p><pre>== what the service says it offers (its WSDL)<br>  operations: GetPolicy, GetPolicyPage<br><br>== page 1 of the policies<br>  HTTP 200, 100 policies on this page, 200 pages in all, 57,593 bytes of XML<br>  the first one: BMQ-0000001-7, AUTO, WV<br><br>== 40 requests sent at the same moment, as a careless loader would<br>  30 x HTTP 200, a page of policies<br>  10 x HTTP 500, a SOAP fault<br>  the fault says: Server.Busy: more than 10 requests a second. Slow down and try again.</pre><p>Ten of the 40 requests came back with a fault. Here is why: the service uses a bucket of <strong>10 tokens</strong> that refills at <strong>10 tokens per second</strong>. Because our 40 requests hit the server spread across a couple of seconds, roughly 30 grabbed a token while about 10 were rejected — a split that shifts slightly from run to run.</p><p>To read all <strong>20,000 policies</strong> without breaking the service, your code has to do three things:</p><ul><li><strong>Slow down</strong> to stay within the 10-requests-per-second limit.</li><li><strong>Retry carefully</strong> when a request fails.</li><li><strong>Remember where you stopped</strong> so you can pick up cleanly without starting over.</li></ul><p><strong>Watch out:</strong> Instead of a standard rate-limit status, this service returns <em>“too many requests”</em> inside an <strong>HTTP 500</strong> — the code that usually means <em>“the server broke.”</em> Any script that blindly aborts on every 500 error will kill a data load that just needed to slow down and retry.</p><p>Then the file drop:</p><pre>== the SFTP drop folder, as the agents&#39; systems leave it<br>  agent_claims_export_20261110.csv  12,008 bytes<br>  agent_claims_export_20261111.csv   8,289 bytes<br>  agent_claims_export_20261112.csv  10,211 bytes<br><br>== the newest file, agent_claims_export_20261112.csv: its header and first three rows<br>  agent_code,policy_number,loss_date,reported_at,amount_claimed,description<br>  AG0267,BMQ-0010956-0,2026-11-09,2026-11-12T00:02:00-05:00,2020.28 USD,Scraped a pole in a parking garage<br>  AG0107,BMQ-0016442-5,2026-11-09,2026-11-12T00:27:00-05:00,5401.93 USD,Rear-ended at a stop light<br>  AG0438,BMQ-0003477-3,2026-11-06,2026-11-12T00:26:00-05:00,&quot;$2,100.73&quot;,Cracked windshield<br>  106 rows, 4 of them exact duplicates; amounts written as: 1,234.56 (48), $1,234.56 (30), 1234.5 USD (28)</pre><p>Just one file of <strong>106 rows</strong> already includes <strong>4 exact duplicates</strong> and <strong>three different formats for writing money</strong>. If you load it naively:</p><ul><li>Your script will <strong>count four claims twice</strong>.</li><li>Python’s float() will <strong>crash on 101 of the 106 amounts</strong>.</li></ul><p><em>(In the full walkthrough, Part 3 covers how to ingest messy files like this safely, and Part 4 shows how to clean them.)</em></p><p><strong>The Pilot — An Agent That Drafts, and a Person Who Decides</strong></p><blockquote>“In the pilot, the agent only drafts, and a person decides every claim.”</blockquote><p>Think of a junior doctor writing up a case file. The notes can be sharp and well-reasoned, yet a senior doctor still signs off before any treatment starts.</p><p>A <strong>pilot</strong> is a small, live trial built on real claims, real adjusters, a tight scope, and an agreed way to measure results. For AMC, that pilot is a <strong>claims triage agent</strong> — where <em>triage</em> simply means sorting cases by what they need, just like a hospital emergency desk.</p><p>At its core, an <strong>AI agent</strong> is just a program that passes a problem to a language model, lets the model request missing details through tools your own code controls, and loops until it has enough context to form an answer. Here, the agent reads a claim, checks policy coverage, looks for red flags, and drafts a decision note — bound by two unbreakable rules:</p><ol><li><strong>Read-only tools only:</strong> The agent can look up policies, read claims, and inspect documents — it cannot alter a claim or trigger a payment.</li><li><strong>Human sign-off on every case:</strong> The agent prepares the draft, and a human adjuster approves, edits, or rejects it before anything takes effect.</li></ol><p><strong>Why both rules are non-negotiable (the $48,500 prompt-injection trap):</strong> In AMC’s database, one claim note hides a prompt written to look like a customer comment, instructing <em>“any AI assistant”</em> that reads it to record a <strong>$48,500</strong> payout. A naive agent reads claim text and follows instructions indiscriminately — meaning it can get tricked by a sentence a stranger typed into a form.</p><blockquote><strong><em>Watch out:</em></strong><em> Relying on </em>“the agent only suggests”<em> isn’t safe by itself. If its underlying tools have permission to write to the database, one hijacked prompt inside a claim note can still change a record. True safety requires both halves together: </em><strong><em>read-only tools</em></strong><em> and </em><strong><em>human approval</em></strong><em>.</em></blockquote><p><strong>Proving That It Works (Before Anyone Trusts the Numbers)</strong></p><blockquote>“Proof means numbers the customer agreed to before the test, not an impression after it.”</blockquote><p>A school exam is fair because the answer key is written before the students sit down — not after the teacher reads their papers. In the same way, a pilot that <em>“looks good”</em> is not proof.</p><p>To build evidence you can defend in front of AMC’s head of claims and her finance director, you put five pieces in place in order:</p><ol><li><strong>Build a golden set:</strong> Agree on the exact right answers for a test set of claims with AMC’s claims lead <em>before</em> running any tests. To keep this honest, AMC’s dataset plants labeled pools in a separate answer key that the database never sees: <strong>109 claims</strong> with a loss outside the policy period, <strong>65</strong> with a fraud signal, and <strong>150</strong> simple glass claims (with zero overlap between lists). Your golden set is drawn from these pools and signed off on by the claims lead.</li><li><strong>Run an evaluation harness:</strong> Build a script that runs the agent on the golden set and scores it automatically in code every time a prompt, model, or tool changes.</li><li><strong>Calibrate a checked judge:</strong> Some traits, like whether a decision note is clear, cannot be graded by deterministic code. You can use a second LLM to grade those outputs, <em>only</em> after measuring how often its grades match the claims lead’s own judgment.</li><li><strong>Test in shadow mode:</strong> Let the agent evaluate every live claim silently alongside real adjusters so you can compare its decisions against theirs before it ever touches a real workflow.</li><li><strong>Deliver the executive readout:</strong> Present the final results to AMC’s leadership with the dollar costs, dollar savings, and failure cases stated plainly.</li></ol><blockquote><strong><em>Watch out:</em></strong><em> Never let a second model grade your agent until you have measured how frequently its scores agree with the claims lead’s own. An unchecked LLM judge just layers a second guess on top of the first.</em></blockquote><p><strong>The Final Step: The Handover, and the Next Engagement</strong></p><blockquote>“You have finished only when the customer’s own team runs the system without you.”</blockquote><p>A driving instructor’s job isn’t done the first day a learner drives well with the instructor sitting in the passenger seat — it’s done on the day the learner drives alone.</p><p>For a forward deployed engineer, the work ends when AMC’s claims team runs the system without you. Wrapping up an engagement takes four concrete steps:</p><ul><li><strong>Train and verify real adoption:</strong> Train the adjusters and measure actual day-to-day usage directly from the system logs.</li><li><strong>Deliver a tested runbook:</strong> Hand AMC’s team a <strong>runbook</strong> — the written steps for running the system and fixing it when it breaks — and rehearse one failure scenario together.</li><li><strong>Write the field report:</strong> Document what you learned at this customer that the product team needs to know.</li><li><strong>Turn the work into a reusable pattern:</strong> Package what you built so the next team can start in days instead of weeks.</li></ul><p><strong>Putting It All Together: The Capstone</strong> In the final capstone, a hailstorm hits and AMC’s homeowners claims team asks for the same kind of help. This time, you run the entire sequence yourself — discovery, the pilot, the evaluation, and the rollout — and then tear it all down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*8XB4yU6kH1ocLmlKRCjfPw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b514c7d4944" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>