<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stephen Jarso</title>
    <description>The latest articles on DEV Community by Stephen Jarso (@stephen_jarso).</description>
    <link>https://dev.to/stephen_jarso</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3831376%2F453ec16f-9d7a-4dfb-8506-86c1c1a98749.jpg</url>
      <title>DEV Community: Stephen Jarso</title>
      <link>https://dev.to/stephen_jarso</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stephen_jarso"/>
    <language>en</language>
    <item>
      <title>The Buffet and the Guy With Five Plates</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Tue, 24 Nov 2026 21:00:00 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/the-buffet-and-the-guy-with-five-plates-3cik</link>
      <guid>https://dev.to/stephen_jarso/the-buffet-and-the-guy-with-five-plates-3cik</guid>
      <description>&lt;p&gt;Picture an all-you-can-eat buffet. It's a good deal, the food is great, and most people behave: they take a plate, eat, maybe go back for seconds.&lt;/p&gt;

&lt;p&gt;Then one guy shows up with five plates, a tray, and a very determined look. He's not breaking any rule you wrote down. But while he's loading up, a whole line of regular customers is standing there, hungry, watching the food disappear.&lt;/p&gt;

&lt;p&gt;A sensible restaurant doesn't ban buffets. It just adds a gentle rule: &lt;em&gt;one plate at a time, please.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's rate limiting. It's the polite way an app says: &lt;strong&gt;"You're welcome here, but you can only ask so many times, so everyone gets a turn."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Part 5 we talked about caching, which keeps your servers from doing the same work twice. Rate limiting is the other half of protecting them: it keeps any single visitor from asking for &lt;em&gt;too much&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Would an App Limit Its Own Users?
&lt;/h2&gt;

&lt;p&gt;It sounds backwards. Don't we &lt;em&gt;want&lt;/em&gt; traffic? Yes, but not all traffic is equal, and your servers are not infinite. Here's what rate limiting protects you from.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accidents.&lt;/strong&gt; A frontend developer writes a loop that calls your API in a tight cycle by mistake. Suddenly one buggy app is sending ten thousand requests a minute. Nobody's evil, but your server is on fire.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attacks.&lt;/strong&gt; Someone tries thousands of passwords against a login form (a &lt;em&gt;brute-force attack&lt;/em&gt;), or floods your site to knock it offline (a &lt;em&gt;denial-of-service attack&lt;/em&gt;). A limit slows them to a crawl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scrapers and abusers.&lt;/strong&gt; Bots that copy your whole catalog, or users who hammer your free tier as if it were unlimited.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unfairness.&lt;/strong&gt; One heavy user hogging capacity so everyone else gets slower service. Limits keep things fair, like the one-plate rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your own bill.&lt;/strong&gt; If every request costs you money (database calls, third-party APIs, SMS messages), unlimited requests means an unlimited bill.&lt;/p&gt;

&lt;p&gt;So rate limiting isn't about distrust. It's about keeping the lights on for everyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rate Limiting vs Throttling (They're Cousins)
&lt;/h2&gt;

&lt;p&gt;You'll hear both words, often used interchangeably. There's a small difference worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rate limiting&lt;/strong&gt; is a hard line. Go past it and you get turned away: &lt;em&gt;"Too many requests. No more for now."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Throttling&lt;/strong&gt; is a slowdown. Instead of refusing you, the system slows you down, queues your requests, or serves you at a reduced speed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of a highway: a rate limit is a bouncer saying "no more cars right now," while throttling is traffic lights that make everyone slow down but keep moving. Many real systems use both.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do You Actually Count Requests? (The Four Classic Methods)
&lt;/h2&gt;

&lt;p&gt;Every rate limiter needs to answer one question: &lt;em&gt;"Has this visitor asked too many times recently?"&lt;/em&gt; The clever part is how you define "recently." Here are the four common ways, in plain language.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Fixed window: the simple one
&lt;/h3&gt;

&lt;p&gt;Divide time into blocks, like each minute on the clock. Allow, say, 100 requests per block. When the minute ends, the counter resets to zero.&lt;/p&gt;

&lt;p&gt;It's easy to build and easy to understand. But it has a quirky flaw. Someone can send 100 requests in the last second of one minute, and another 100 in the first second of the next. That's 200 requests in two seconds, while technically following the rules. It's a burst loophole at the edge of every window.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Sliding window: the fairer one
&lt;/h3&gt;

&lt;p&gt;Instead of resetting at fixed clock boundaries, look at the &lt;em&gt;last 60 seconds from right now&lt;/em&gt;, whenever the request arrives. The "minute" slides along with time, so there's no sneaky boundary to exploit.&lt;/p&gt;

&lt;p&gt;It's more accurate and fairer, though it takes a bit more memory and effort to track. Many production systems prefer it.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Token bucket: the friendly one (very popular)
&lt;/h3&gt;

&lt;p&gt;Imagine a bucket that holds tokens. Every request costs one token. Tokens drip back into the bucket at a steady rate, say 10 per second, up to a maximum capacity.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If there's a token, your request goes through.&lt;/li&gt;
&lt;li&gt;If the bucket is empty, you wait (or get refused) until more tokens drip in.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The beauty: it allows &lt;strong&gt;short bursts&lt;/strong&gt; (a full bucket lets you send a quick flurry) while still enforcing a steady average. It feels natural to real users, who tend to be bursty: nothing for a while, then a few quick clicks.&lt;/p&gt;

&lt;p&gt;In rough pseudocode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;allowRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;refillTokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              &lt;span class="c1"&gt;// add tokens based on time passed&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              &lt;span class="c1"&gt;// spend one token&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                   &lt;span class="c1"&gt;// allowed&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                    &lt;span class="c1"&gt;// bucket empty: too many requests&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Leaky bucket: the smoothing one
&lt;/h3&gt;

&lt;p&gt;Picture a bucket with a small hole in the bottom. Requests pour in at the top (as fast or slow as they like), but they leak out the bottom at a fixed, steady speed. If the bucket overflows, the extra requests are dropped.&lt;/p&gt;

&lt;p&gt;The result is a perfectly even flow, no matter how bursty the input. It's great when the thing &lt;em&gt;behind&lt;/em&gt; your limiter needs a calm, constant pace, like a payment provider or an SMS gateway that can't handle spikes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick way to tell the buckets apart:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Token bucket: &lt;em&gt;"you may spend saved-up tokens, so bursts are okay."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Leaky bucket: &lt;em&gt;"no matter how you pour, it comes out at one steady speed."&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who Are You Limiting? (Choosing the "Who")
&lt;/h2&gt;

&lt;p&gt;Before counting, you have to decide &lt;em&gt;who&lt;/em&gt; the counter belongs to. Common choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;By IP address:&lt;/strong&gt; easy, but many people can share one IP (an office, a school, a phone network), so you might punish innocent users. And attackers can switch IPs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;By user account or ID:&lt;/strong&gt; fairer for logged-in users, because the limit follows the person.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;By API key:&lt;/strong&gt; the standard for APIs, where each customer gets their own allowance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;By endpoint:&lt;/strong&gt; different limits for different routes. Login might allow 5 attempts per minute, while reading public data allows 100.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good designs often combine these: a gentle limit per IP for anonymous visitors, a more generous one per logged-in user, and a very strict one on sensitive actions like login and password reset.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the User Sees: Saying No Politely
&lt;/h2&gt;

&lt;p&gt;How you refuse matters just as much as whether you refuse. The standard way is an HTTP status code, &lt;strong&gt;429 Too Many Requests&lt;/strong&gt;. It tells the client, in a universal language: &lt;em&gt;"Not an error on your end. You're just going too fast."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A good response also tells the client &lt;strong&gt;when to try again&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt; &lt;span class="nc"&gt;Too&lt;/span&gt; &lt;span class="nc"&gt;Many&lt;/span&gt; &lt;span class="nc"&gt;Requests&lt;/span&gt;
&lt;span class="nc"&gt;Retry&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;After&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Too many requests. Please try again in 30 seconds."&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many APIs also send helpful headers on &lt;em&gt;every&lt;/em&gt; response, so well-behaved clients can pace themselves before hitting the wall:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how many requests you're allowed&lt;/li&gt;
&lt;li&gt;how many you have left&lt;/li&gt;
&lt;li&gt;when the counter resets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the difference between a bouncer who silently shoves you out and one who says, "Come back in half an hour." Both enforce the rule. Only one leaves you feeling respected.&lt;/p&gt;

&lt;p&gt;And if &lt;em&gt;you're&lt;/em&gt; the one calling someone else's API and you get a 429, the grown-up response is to &lt;strong&gt;wait and retry with a growing delay&lt;/strong&gt; (try after 1 second, then 2, then 4, and so on). This is called &lt;em&gt;exponential backoff&lt;/em&gt;, and it's how well-behaved clients avoid making things worse.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Does the Limiter Live?
&lt;/h2&gt;

&lt;p&gt;Remember our layers from earlier in the series? Rate limiting can live at several of them, and each has its place:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;At the edge or CDN:&lt;/strong&gt; blocks floods before they even reach you (this is where DDoS protection lives).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;At the API gateway (Part 4):&lt;/strong&gt; the most common spot. One consistent set of rules at the front door, applied before any service does work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inside your application:&lt;/strong&gt; useful for fine-grained, business-specific rules ("5 password attempts per account," "3 coupon redemptions per day").&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The earlier you stop a bad request, the less it costs you. Turning someone away at the front door is far cheaper than letting them walk through the whole building first.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "Many Servers" Problem
&lt;/h2&gt;

&lt;p&gt;Here's a subtle one that catches people out. Remember from Part 2 that you probably have several servers behind a load balancer? If each server keeps its own count in its own memory, a user can get a fresh allowance on every server.&lt;/p&gt;

&lt;p&gt;Say your limit is 100 requests per minute, and you have 4 servers. If each tracks separately, one user could effectively make 400 requests a minute. The limit is meaningless.&lt;/p&gt;

&lt;p&gt;The fix connects back to Part 5: &lt;strong&gt;keep the counters in a shared place that all servers can see&lt;/strong&gt;, like Redis. Fast, shared, and it can automatically expire counters when the time window ends. That's one of the best everyday uses for Redis, beyond just caching.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Mistakes That Bite Teams
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Limiting everyone the same.&lt;/strong&gt; A regular user and a paying enterprise customer shouldn't share an allowance. Tier your limits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limits so strict they hurt real users.&lt;/strong&gt; If a normal person doing normal things hits the wall, your limit is wrong. Watch real usage before choosing numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limiting only by IP.&lt;/strong&gt; Shared networks mean innocent people get blocked together. Combine signals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No helpful error message.&lt;/strong&gt; A bare "403 Forbidden" with no explanation leaves developers guessing. Use 429 and say when to retry.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forgetting the sensitive routes.&lt;/strong&gt; Login, signup, password reset, and OTP or SMS endpoints are prime targets, and each message may cost you money. Give them their own strict limits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting it and forgetting it.&lt;/strong&gt; Traffic changes. Review your limits, and track how often they trigger.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Design One (A Simple Checklist)
&lt;/h2&gt;

&lt;p&gt;Same spirit as the cache checklist from Part 5. Ask yourself these seven questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;What am I protecting?&lt;/strong&gt; Servers, money, a fragile third-party service, user accounts?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who am I counting?&lt;/strong&gt; IP, user, API key, or a mix?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What's a normal amount?&lt;/strong&gt; Look at real usage, then set the limit comfortably above it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which method fits?&lt;/strong&gt; Token bucket for friendly bursts, leaky bucket for steady output, sliding window for fairness, fixed window for simplicity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where does it live?&lt;/strong&gt; Edge, gateway, app, or several layers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How do I say no?&lt;/strong&gt; A 429 status, a clear message, and a retry hint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How will I watch it?&lt;/strong&gt; Track how often limits trigger and who triggers them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Protect, who, normal, method, where, refusal, watch.&lt;/em&gt; That's the whole recipe.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting the Series Together
&lt;/h2&gt;

&lt;p&gt;Notice the pattern across all six parts. Each one is really about &lt;em&gt;protecting something precious&lt;/em&gt; (your users' time, your servers' capacity) with a small, sensible rule:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CDN (Part 1):&lt;/strong&gt; keep content close to users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load balancer (Part 2):&lt;/strong&gt; spread the load&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reverse proxy (Part 3):&lt;/strong&gt; stand guard in front of servers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API gateway (Part 4):&lt;/strong&gt; one smart front door&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching (Part 5):&lt;/strong&gt; don't repeat work&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limiting (this post):&lt;/strong&gt; don't let anyone take more than a fair share&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good infrastructure isn't about being clever. It's about being fair and calm under pressure.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to Take Away
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Rate limiting is fairness, not hostility.&lt;/strong&gt; It keeps one visitor from spoiling it for everyone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limit = hard stop; throttle = slow down.&lt;/strong&gt; Many systems do both.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Know the four methods:&lt;/strong&gt; fixed window (simple), sliding window (fairer), token bucket (allows bursts), leaky bucket (smooths the flow).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decide who you're counting:&lt;/strong&gt; IP, user, API key, or endpoint, ideally a mix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Say no kindly:&lt;/strong&gt; return 429 with a &lt;code&gt;Retry-After&lt;/code&gt;, and as a client, back off and retry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Share the counters&lt;/strong&gt; across servers (Redis is the usual choice).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put strict limits on sensitive routes&lt;/strong&gt; like login and SMS.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The next time an API politely tells you to wait 30 seconds, don't be annoyed. It's just the buffet owner making sure there's still food left for the person behind you.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Next in this series: DNS, the internet's phone book, and how a friendly name like a website address turns into the number computers actually use.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you ever been rate limited by an API in the middle of building something? How did you find out? Tell me in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>api</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Question You've Answered a Hundred Times</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Sun, 22 Nov 2026 05:13:00 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/the-question-youve-answered-a-hundred-times-jaa</link>
      <guid>https://dev.to/stephen_jarso/the-question-youve-answered-a-hundred-times-jaa</guid>
      <description>&lt;p&gt;Imagine a friend asks you: &lt;em&gt;"Hey, what's your phone number?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You say it. No problem.&lt;/p&gt;

&lt;p&gt;Now imagine they ask again the next day. And the next. And the day after that. Fifty different times, fifty different friends.&lt;/p&gt;

&lt;p&gt;At some point you stop digging through your contacts to find it. You just &lt;em&gt;know&lt;/em&gt; it. It lives in your head, ready to go.&lt;/p&gt;

&lt;p&gt;Congratulations, you just invented caching.&lt;/p&gt;

&lt;p&gt;Caching is one of the simplest ideas in all of computing, and one of the most powerful: &lt;strong&gt;if you've already worked out an answer, remember it instead of working it out again.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's the whole idea. This post is about how it works, where it lives, and the one thing about it that makes even experienced developers grumpy.&lt;/p&gt;

&lt;p&gt;In Part 4 we looked at API gateways, the front door of your backend. Today we're going &lt;em&gt;behind&lt;/em&gt; the door, to the places where your app quietly keeps its memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Bother? Because Work Is Expensive
&lt;/h2&gt;

&lt;p&gt;Every time your app answers a question, it does work. Sometimes a lot of it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Asking the database to dig through millions of rows&lt;/li&gt;
&lt;li&gt;Calling another service across the network&lt;/li&gt;
&lt;li&gt;Running a heavy calculation&lt;/li&gt;
&lt;li&gt;Building a page from a dozen pieces&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now think about how often people ask for the &lt;em&gt;same thing&lt;/em&gt;. The homepage. A popular product. Today's exchange rate. A trending post. Thousands of people want identical answers.&lt;/p&gt;

&lt;p&gt;Doing all that work from scratch every single time is like walking to the library to look up the same fact for every person who asks. A cache is a sticky note on your desk with the answer already written on it.&lt;/p&gt;

&lt;p&gt;The payoff is real:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Faster:&lt;/strong&gt; reading from memory takes microseconds, while a database trip takes milliseconds or more&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cheaper:&lt;/strong&gt; fewer database queries, fewer API calls, smaller bills&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sturdier:&lt;/strong&gt; your database survives traffic spikes because most questions never reach it&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Caches Live Everywhere (Layers of Memory)
&lt;/h2&gt;

&lt;p&gt;Here's something that surprised me when I first learned it: caching doesn't happen in &lt;em&gt;one&lt;/em&gt; place. It happens at almost every step between a user and your data. Think of it like a series of shortcuts, each one closer to the person asking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The browser cache.&lt;/strong&gt; Your own browser saves images, scripts, and styles so it doesn't re-download them on every visit. This is the closest cache to the user, and the fastest, because there's no network trip at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The CDN cache.&lt;/strong&gt; Back in Part 1, we saw copies of your content sitting on servers around the world. Same idea, one step further back.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The reverse proxy / gateway cache.&lt;/strong&gt; From Parts 3 and 4: your front door can remember responses and answer repeat questions itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. The application cache.&lt;/strong&gt; This is the one this post focuses on. Your app keeps frequently needed data in fast memory so it doesn't keep asking the database. It's where tools like Redis come in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. The database's own cache.&lt;/strong&gt; Even your database remembers recent results internally. You get this one for free.&lt;/p&gt;

&lt;p&gt;A request travels down this chain and stops at the &lt;em&gt;first place that already knows the answer&lt;/em&gt;. The earlier it stops, the faster the user gets their response. A really good cache setup means most requests never get past the first couple of layers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Sticky Note Pattern
&lt;/h2&gt;

&lt;p&gt;Now, how does application caching actually work? The most common approach is so simple it almost feels like cheating. It's called &lt;strong&gt;cache-aside&lt;/strong&gt; (or lazy loading), and it goes like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A request comes in: &lt;em&gt;"Get me user 42's profile."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Check the cache first. Is it there?

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Yes (a "cache hit"):&lt;/strong&gt; hand it back immediately. Done.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No (a "cache miss"):&lt;/strong&gt; go ask the database, then &lt;strong&gt;save the answer in the cache&lt;/strong&gt;, then hand it back.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Next time someone asks for user 42, it's already there.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In rough pseudocode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;cached&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`user:${id}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;               &lt;span class="c1"&gt;// hit: fast!&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// miss: do the real work&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`user:${id}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// remember it for 5 minutes&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. The first person pays the full price. Everyone after them gets the express lane. If you remember the CDN article, it's the exact same "first visitor warms it up" pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Words You'll Hear (In Plain English)
&lt;/h2&gt;

&lt;p&gt;Caching has its own little vocabulary. Here's the cheat sheet, so nobody can fluster you in a meeting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cache hit:&lt;/strong&gt; the answer was already in the cache. Fast and cheap. This is what you want.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache miss:&lt;/strong&gt; the answer wasn't there, so the app had to do the real work. Slower, but it's how the cache fills up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hit rate (or hit ratio):&lt;/strong&gt; the percentage of requests that are hits. If 90 out of 100 requests are answered from the cache, your hit rate is 90%. This is the single best number for judging whether your cache is worth having.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TTL (time to live):&lt;/strong&gt; the countdown timer on a cached item. When it hits zero, the item is thrown away.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eviction:&lt;/strong&gt; when the cache is full and has to throw something out to make room. More on this in a moment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cold cache vs warm cache:&lt;/strong&gt; a cold cache is empty (just started, or just restarted), so almost everything misses. A warm cache has been filled up by real traffic and mostly hits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Invalidation:&lt;/strong&gt; deliberately removing or updating a cached item because the real data changed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stale data:&lt;/strong&gt; a cached answer that is no longer true.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you only remember one pair, make it hit and miss. Almost every caching conversation is secretly about how to get more of the first and fewer of the second.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Redis, and Why Does Everyone Mention It?
&lt;/h2&gt;

&lt;p&gt;You'll hear "just put it in Redis" constantly. Here's what that means in plain words.&lt;/p&gt;

&lt;p&gt;Redis is a database that lives in &lt;strong&gt;memory&lt;/strong&gt; (RAM) instead of on disk. Memory is dramatically faster than disk, which is why it's perfect for caching. It stores simple key-value pairs, like a giant dictionary: &lt;em&gt;"user:42" → {their profile}&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Why people love it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Blazing fast&lt;/strong&gt; for reads and writes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shared:&lt;/strong&gt; all your app servers can talk to the same Redis, which matters a lot once you have multiple servers (remember the stateless-server lesson from Part 2?)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in expiry:&lt;/strong&gt; you can tell it "forget this after 5 minutes" and it just does&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does more than caching:&lt;/strong&gt; sessions, rate limiting counters, queues, leaderboards&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two honest notes. First, memory is more expensive than disk, so you cache the &lt;em&gt;valuable&lt;/em&gt; stuff, not everything. Second, a cache is allowed to forget. If Redis restarts and loses everything, your app should just fall back to the database and refill it. &lt;strong&gt;A cache is a convenience, never your only copy of anything important.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Part Everyone Dreads: When Is the Answer Wrong?
&lt;/h2&gt;

&lt;p&gt;There's an old joke in programming: &lt;em&gt;"There are only two hard things in computer science: naming things and cache invalidation."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here's why. A cache remembers an answer. But the real world keeps changing. Imagine you cache a product's price at $20. Then the shop updates it to $25. Your cache doesn't know. For a while, some users still see $20.&lt;/p&gt;

&lt;p&gt;That's &lt;strong&gt;stale data&lt;/strong&gt;: a remembered answer that stopped being true. And deciding &lt;em&gt;when to forget&lt;/em&gt; is genuinely tricky, because you're balancing two things that pull in opposite directions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remember longer → faster, cheaper, but riskier to show outdated info&lt;/li&gt;
&lt;li&gt;Remember shorter → fresher, but you do more work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's no perfect answer. There are only sensible strategies. Here are the main ones, in plain language.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Expire after a set time (TTL)
&lt;/h3&gt;

&lt;p&gt;Give every cached item a countdown. After 5 minutes, it's discarded and gets fetched fresh next time. Simple, predictable, and good enough for most things. A trending list that's 2 minutes out of date hurts nobody.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Delete it when the data changes
&lt;/h3&gt;

&lt;p&gt;When someone updates a product, your code also removes the cached version. Next request, the cache misses, and the fresh data gets loaded. This keeps things much more accurate, but you have to remember to do it &lt;em&gt;everywhere&lt;/em&gt; data changes. Forget one spot, and you've got a sneaky bug.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Update the cache at the same time as the database
&lt;/h3&gt;

&lt;p&gt;Called &lt;strong&gt;write-through&lt;/strong&gt;. Every change goes to both places together. The cache is always current, at the cost of slightly slower writes.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Write to the cache first, the database later
&lt;/h3&gt;

&lt;p&gt;Called &lt;strong&gt;write-behind&lt;/strong&gt;. Super fast for writes, but risky: if the cache dies before it saves to the database, you can lose data. Use it carefully, and not for anything like payments.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Serve slightly old data while refreshing quietly
&lt;/h3&gt;

&lt;p&gt;Called &lt;strong&gt;stale-while-revalidate&lt;/strong&gt;. The user instantly gets the old answer, while the app fetches a fresh one in the background for the next person. Nobody waits, and the cache heals itself.&lt;/p&gt;

&lt;p&gt;A good rule of thumb: &lt;strong&gt;match the freshness to the stakes.&lt;/strong&gt; A "like" count being a few seconds behind? Nobody cares. An account balance or a stock level? Be much more careful, or don't cache it at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Mistakes That Bite Everyone Once
&lt;/h2&gt;

&lt;p&gt;If you build with caching long enough, you'll meet these. Better to meet them here first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caching things that are personal.&lt;/strong&gt; If you cache a page that includes &lt;em&gt;one user's&lt;/em&gt; data and then serve it to everyone, Alice sees Bob's account. It's a real, embarrassing, sometimes serious bug. Be careful about what goes into a shared cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cache avalanche ("everything expired at once").&lt;/strong&gt; Say you load a thousand items into the cache at the same moment, all with a 10-minute TTL. Ten minutes later, they all vanish together, and your database suddenly gets hit by a thousand requests at once. Picture a whole crowd leaning on a door that was holding them back. The classic fix: add a little random wiggle to your expiry times (say 10 minutes, plus or minus a bit) so they don't all disappear in the same second.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cache stampede, also called "thundering herd" ("one popular thing just vanished").&lt;/strong&gt; This is the avalanche's close cousin, but about a &lt;em&gt;single&lt;/em&gt; item. Imagine your homepage data is cached and thousands of people are asking for it every second. The moment it expires, every one of those requests sees a miss at the same time, and every one of them rushes to the database to rebuild the same answer. Thousands of identical, expensive queries, all at once, for something only one of them needed to do. This is how a fast site suddenly falls over.&lt;/p&gt;

&lt;p&gt;Ways to calm the herd:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lock the rebuild:&lt;/strong&gt; let only &lt;em&gt;one&lt;/em&gt; request go rebuild it, while the others wait a moment and then read the fresh result&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refresh early:&lt;/strong&gt; quietly rebuild a popular item just &lt;em&gt;before&lt;/em&gt; it expires, so it never actually goes missing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serve stale briefly:&lt;/strong&gt; hand out the slightly old answer while one request refreshes it in the background (the stale-while-revalidate idea from earlier)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cache penetration ("asking for things that don't exist").&lt;/strong&gt; Someone (or some bot) keeps requesting items that aren't real, like user ID 99999999. The cache never has them, so every request misses and goes to the database, which finds nothing. Since there's nothing to cache, it happens again and again. A simple fix: cache the "not found" answer too, for a short time. Fancier fixes exist, but that one handles most cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Never expiring anything.&lt;/strong&gt; "I'll just cache it forever" is how you end up debugging at midnight, wondering why an old value won't go away.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caching without measuring.&lt;/strong&gt; If you don't know your &lt;strong&gt;hit rate&lt;/strong&gt; (what percentage of requests are answered from cache), you don't know if your cache is helping. A cache with a 5% hit rate is mostly just extra complexity.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Design a Cache (A Simple Checklist)
&lt;/h2&gt;

&lt;p&gt;Okay, so how do you actually &lt;em&gt;plan&lt;/em&gt; one, rather than just sprinkling it everywhere and hoping? Here's the order I'd think through it. Each step is just a question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. What am I caching, and is it worth it?&lt;/strong&gt;&lt;br&gt;
Pick the things that are read often, change rarely, and are expensive to produce. Look for the slow spots first, then cache those. If you can't point to something slow, you don't need a cache yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. What should the key look like?&lt;/strong&gt;&lt;br&gt;
The key is the label on the sticky note. It has to be unique and predictable, or you'll pull out the wrong note. A good habit is a clear pattern like &lt;code&gt;user:42:profile&lt;/code&gt; or &lt;code&gt;product:991:v2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The most important part: &lt;strong&gt;include everything that changes the answer in the key.&lt;/strong&gt; If the page looks different per language, put the language in the key (&lt;code&gt;home:en&lt;/code&gt;, &lt;code&gt;home:sw&lt;/code&gt;). If you forget, a Swahili reader gets the English page, and you spend an evening confused. Adding a version (&lt;code&gt;v2&lt;/code&gt;) also lets you "invalidate" everything at once by simply changing the version number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. How long should it live?&lt;/strong&gt;&lt;br&gt;
Pick a TTL based on how bad it would be to show old data. Seconds for fast-moving things, minutes or hours for slow-moving ones. When in doubt, start short and lengthen it once you trust it. And remember the wiggle: add a little randomness so things don't all expire together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. What happens when it fills up?&lt;/strong&gt;&lt;br&gt;
Memory is limited, so eventually the cache is full and something has to go. That's called &lt;strong&gt;eviction&lt;/strong&gt;, and the rule for choosing what to throw out is called an &lt;strong&gt;eviction policy&lt;/strong&gt;. The common ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LRU (least recently used):&lt;/strong&gt; throw out whatever hasn't been touched for the longest time. Like clearing out a desk drawer by tossing the stuff you haven't reached for in ages. This is the most popular default, and it works well for most apps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LFU (least frequently used):&lt;/strong&gt; throw out whatever is asked for the least often overall. Good when some items are consistently popular.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FIFO (first in, first out):&lt;/strong&gt; throw out the oldest thing, no matter how popular. Simple, but it can evict a favorite just because it's old.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TTL-based:&lt;/strong&gt; let the timers do the clearing, and only evict early if memory runs out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't need to memorize the details. Just know that "LRU" is the answer you'll see most often, and that your cache &lt;em&gt;will&lt;/em&gt; need a rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. How big should it be?&lt;/strong&gt;&lt;br&gt;
Here's the happy surprise: a cache usually doesn't need to hold everything. In most apps, a small slice of the data gets most of the requests (people tend to ask for the same popular things). So a modest cache can give you a high hit rate. Start small, watch the hit rate, and grow only if it helps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. What if the cache disappears?&lt;/strong&gt;&lt;br&gt;
Design for it. Your app should still work if the cache is empty or down, just slower, by falling back to the database. And since an empty cache means a flood of misses, make sure your database (and the stampede protections above) can survive the "cold start" moment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. How will I know it's working?&lt;/strong&gt;&lt;br&gt;
Track your hit rate, how much memory you're using, how many items are being evicted, and how fast reads are. If the hit rate is low, the cache isn't earning its keep. If evictions are constant, it's probably too small. Numbers beat guessing every time.&lt;/p&gt;

&lt;p&gt;That's the whole checklist: &lt;em&gt;what, key, how long, eviction, size, fallback, measure.&lt;/em&gt; Walk through those seven questions and you've designed a cache.&lt;/p&gt;

&lt;h2&gt;
  
  
  So Should You Cache Everything?
&lt;/h2&gt;

&lt;p&gt;No. And this might be the most useful sentence in this whole post.&lt;/p&gt;

&lt;p&gt;Caching adds a second place where data lives, and any time the same fact lives in two places, they can disagree. That's a real cost.&lt;/p&gt;

&lt;p&gt;A good habit: &lt;strong&gt;don't cache first, measure first.&lt;/strong&gt; Find what's actually slow or expensive. Then cache &lt;em&gt;that&lt;/em&gt;. Good candidates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data that's read &lt;strong&gt;often&lt;/strong&gt; but changes &lt;strong&gt;rarely&lt;/strong&gt; (settings, product catalogs, public profiles)&lt;/li&gt;
&lt;li&gt;Results that are &lt;strong&gt;expensive&lt;/strong&gt; to compute (reports, aggregations)&lt;/li&gt;
&lt;li&gt;Things where being a &lt;strong&gt;little&lt;/strong&gt; out of date is acceptable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Poor candidates: things that change constantly, things that must always be exact, and anything you haven't proven is slow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting the Whole Series Together
&lt;/h2&gt;

&lt;p&gt;Look at how far we've come, and notice how every part is really the same instinct wearing different clothes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CDN (Part 1):&lt;/strong&gt; keep copies of content close to users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load balancer (Part 2):&lt;/strong&gt; spread the work across many servers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reverse proxy (Part 3):&lt;/strong&gt; stand in front of servers to protect and simplify them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API gateway (Part 4):&lt;/strong&gt; one smart front door for many services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching (this post):&lt;/strong&gt; don't repeat work you've already done&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Underneath it all is one simple belief: &lt;strong&gt;the fastest request is the one that never has to travel far, or never has to be computed twice.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What to Take Away
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A cache is a remembered answer.&lt;/strong&gt; Same idea as memorizing a phone number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caches exist in layers&lt;/strong&gt;, from your browser all the way down to your database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache-aside is the friendly default:&lt;/strong&gt; check the cache, fall back to the database, then save the result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redis is just fast memory&lt;/strong&gt; that all your servers can share.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The hard part is knowing when to forget.&lt;/strong&gt; Match how fresh the data must be to how much it matters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hits and misses decide everything.&lt;/strong&gt; Watch your hit rate, because it tells you if the cache is worth having.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Know the herd problems:&lt;/strong&gt; avalanche (many things expire together), stampede (one hot thing expires and everyone rushes in), and penetration (requests for things that don't exist).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design it with a checklist:&lt;/strong&gt; what to cache, the key, the TTL, the eviction rule (LRU is the usual start), the size, the fallback, and how you'll measure it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure before you cache.&lt;/strong&gt; Don't add memory where nothing was slow.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The next time an app feels instant, even though it must be handling millions of users, you'll know part of the secret: it's not working that hard. It's just remembering really well.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Next in this series: rate limiting, or how apps say "slow down, friend" without ever being rude about it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What's the strangest stale-cache bug you've ever debugged? I'd love to hear it in the comments. Everyone has one.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>performance</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Day Your One App Became Twelve</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Fri, 20 Nov 2026 05:20:00 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/the-day-your-one-app-became-twelve-1cea</link>
      <guid>https://dev.to/stephen_jarso/the-day-your-one-app-became-twelve-1cea</guid>
      <description>&lt;p&gt;At the start, your backend is one app.One codebase,one deployment,one address.The frontend knows exactly where to send every request,because there's only one place it can send them.&lt;br&gt;
Then the project grows.Someone splits out the payments logic into its own service.Then notifications,.Then user profiles,then search,then the thing that resizes images.A year later you have a dozen small services,each doing one job,each living at its own address.&lt;/p&gt;

&lt;p&gt;And now your mobile app has a problem it never used to have:&lt;br&gt;
&lt;em&gt;To load the homescreen,which of these twelve things do i need to talk to?And where do they all live?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Without something in the middle,the honest answer is:Frontend has to know all of it.Every address,every auth rule,every quirk.And every time you move or rename a service ,every client breaks.&lt;br&gt;
That something in the middle is called an API gateway.Think of it as the front door of your whole backend.&lt;br&gt;
In Part 3 we looked at reverse proxies,the receptionist standing in front of your server.An Api gateway is that receptionist after a promotion:same basic job,but much smarter about what's going on behind the desk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Hotel Analogy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Picture a big hotel.&lt;/p&gt;

&lt;p&gt;Guests don't wander the building looking for the kitchen, the laundry, the spa, and the maintenance team. They go to &lt;strong&gt;one front desk&lt;/strong&gt;. They say what they need, and the front desk:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Checks who they are (are you a guest?)&lt;/li&gt;
&lt;li&gt;Figures out which department handles the request&lt;/li&gt;
&lt;li&gt;Passes it along&lt;/li&gt;
&lt;li&gt;Brings the answer back&lt;/li&gt;
&lt;li&gt;Politely says "no" to anyone trying to wander into the staff-only areas
The departments behind the desk can be reorganized, moved to different floors, or even replaced entirely. Guests never notice, because they only ever deal with the front desk.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's an API gateway. One entry point for every client, and a lot of quiet responsibility behind it.&lt;/p&gt;

&lt;h2&gt;
  
  
  So What Does a Gateway Actually Do?
&lt;/h2&gt;

&lt;p&gt;Let's go through the job list in plain language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Routing.&lt;/strong&gt; The most basic job. A request for &lt;code&gt;/payments&lt;/code&gt; goes to the payments service. &lt;code&gt;/search&lt;/code&gt; goes to the search service. The client only knows one address, and the gateway handles the map.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Authentication.&lt;/strong&gt; Instead of every one of your twelve services separately checking "is this person logged in and allowed to do this?", the gateway checks once, at the door. Requests that fail never get inside. Requests that pass get stamped with who the user is, so internal services can trust it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Rate limiting.&lt;/strong&gt; One misbehaving client (or one attacker) hammering your API can bring down services that were never built to defend themselves. The gateway can say "100 requests a minute per user, then slow down" before any of that traffic reaches your actual code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Combining responses.&lt;/strong&gt; Remember that home screen needing data from five services? Without a gateway, the phone makes five separate network calls over a mobile connection. With one, the phone makes &lt;strong&gt;one&lt;/strong&gt; call, and the gateway talks to the five services behind the scenes (over a fast internal network) and stitches the answer together. Fewer round trips on a slow connection is a huge win.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Translating between worlds.&lt;/strong&gt; Maybe your frontend speaks REST and one old internal service speaks something else entirely. The gateway can translate, so clients never have to care.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Logging and monitoring.&lt;/strong&gt; Because every request passes through one place, it's the perfect spot to record who called what, how long it took, and what failed. You get a bird's-eye view for free.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Caching.&lt;/strong&gt; Same idea as everything earlier in this series: if ten thousand people ask for the same thing, answer from memory instead of bothering the services ten thousand times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Versioning.&lt;/strong&gt; Want to roll out &lt;code&gt;/v2/&lt;/code&gt; of your API without breaking old mobile apps still calling &lt;code&gt;/v1/&lt;/code&gt;? The gateway can route each to the right place.&lt;/p&gt;

&lt;p&gt;Notice something? Many of these sound familiar. That's because a gateway is built on the same ideas as the reverse proxy and load balancer from the earlier parts. The difference is &lt;em&gt;awareness of your API&lt;/em&gt;. A reverse proxy mostly shuffles bytes. A gateway understands that this is a request for the payments API from user #4821, and acts accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gateway vs Reverse Proxy vs Load Balancer
&lt;/h2&gt;

&lt;p&gt;This is where people get confused, so here's the cleanest way to think about it. They're &lt;strong&gt;layers of intelligence&lt;/strong&gt;, not rivals:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Mostly cares about&lt;/th&gt;
&lt;th&gt;Example job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Load balancer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Which &lt;em&gt;copy&lt;/em&gt; of a server gets this request&lt;/td&gt;
&lt;td&gt;"Server 2 is least busy, send it there"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reverse proxy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hiding and protecting the servers behind it&lt;/td&gt;
&lt;td&gt;"Handle HTTPS, serve static files, forward the rest"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;API gateway&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What this &lt;em&gt;API request&lt;/em&gt; means&lt;/td&gt;
&lt;td&gt;"Is this user allowed to call /payments, and have they hit their limit?"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In real systems, you'll often see all three stacked: a load balancer in front, spreading traffic across several gateway instances, each of which routes to services that are &lt;em&gt;themselves&lt;/em&gt; load balanced. Each layer does the one job it's best at.&lt;/p&gt;

&lt;p&gt;(And to make it more confusing: many tools do more than one job. nginx can act as all three if configured to. The &lt;em&gt;roles&lt;/em&gt; are separate even when the software isn't.)&lt;/p&gt;

&lt;h2&gt;
  
  
  A Day in the Life of One Request
&lt;/h2&gt;

&lt;p&gt;Let's follow a single request so this feels real. A user opens the app and taps "My Orders."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The app sends &lt;strong&gt;one&lt;/strong&gt; request to &lt;code&gt;api.yourapp.com/orders&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A load balancer hands it to one of several gateway instances&lt;/li&gt;
&lt;li&gt;The gateway checks the token: valid, and it belongs to user 4821&lt;/li&gt;
&lt;li&gt;The gateway checks the rate limit: well under, fine&lt;/li&gt;
&lt;li&gt;It routes the request to the orders service, adding "this is user 4821" so the service doesn't have to re-verify anything&lt;/li&gt;
&lt;li&gt;The orders service responds. Maybe the gateway also quietly asks the products service for item names and merges them in&lt;/li&gt;
&lt;li&gt;The gateway logs the request and sends one tidy response back
The user saw a screen load. The app made one call. Behind the curtain, five or six things collaborated. That's the whole magic trick.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Honest Downsides
&lt;/h2&gt;

&lt;p&gt;I'd be doing you a disservice if I made gateways sound like pure upside. They come with real trade-offs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's a single point of failure.&lt;/strong&gt; If every request goes through the gateway and the gateway dies, &lt;em&gt;everything&lt;/em&gt; dies. The fix is running multiple gateway instances behind a load balancer (see Part 2), but it's something you have to deliberately plan for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It can become a bottleneck.&lt;/strong&gt; All your traffic funnels through one layer. If it's slow, everything is slow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It can become a dumping ground.&lt;/strong&gt; This one bites teams the most. Gateways are so convenient that people keep stuffing business logic into them: "just one more transformation," "just one more special case." Over time, your gateway turns into a tangled monolith that everyone's afraid to touch, which is exactly what you were trying to escape by splitting into services. The rule of thumb: &lt;strong&gt;keep it about traffic, not business decisions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's one more thing to run.&lt;/strong&gt; More components means more to deploy, monitor, and debug. For a small project, that cost can outweigh the benefit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do You Actually Need One?
&lt;/h2&gt;

&lt;p&gt;Honest answer: &lt;strong&gt;probably not yet.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have one backend, or two or three services, a plain reverse proxy like nginx is usually plenty. A gateway earns its place when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have &lt;strong&gt;many services&lt;/strong&gt; and clients shouldn't need to know about each one&lt;/li&gt;
&lt;li&gt;You want &lt;strong&gt;consistent auth and rate limiting&lt;/strong&gt; in one place instead of copy-pasted twelve times&lt;/li&gt;
&lt;li&gt;You serve &lt;strong&gt;mobile or slow-network clients&lt;/strong&gt; that benefit from fewer round trips&lt;/li&gt;
&lt;li&gt;You have &lt;strong&gt;multiple teams&lt;/strong&gt; who need a stable, shared front door while they change things behind it
Starting with a gateway on day one of a tiny project is like hiring a hotel front desk team for a two-room guesthouse. Add it when the building grows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools You'll Run Into
&lt;/h2&gt;

&lt;p&gt;You don't have to build one from scratch. Popular options include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Managed cloud gateways:&lt;/strong&gt; AWS API Gateway, Google Cloud API Gateway, Azure API Management. You configure them, the provider runs them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open source you run yourself:&lt;/strong&gt; Kong, Traefik, KrakenD, Envoy-based gateways&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do-it-yourself:&lt;/strong&gt; a small service in your language of choice (Go is great at this) that routes and authenticates. For small setups, this is often the simplest honest answer
If you've used Cloudflare or a platform like Vercel with rewrites and middleware, you've already touched gateway-style ideas without necessarily calling them that.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where This Fits in the Series
&lt;/h2&gt;

&lt;p&gt;Zooming out across everything so far:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CDN (Part 1):&lt;/strong&gt; bring content physically closer to users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load balancer (Part 2):&lt;/strong&gt; spread traffic across many servers so none drown&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reverse proxy (Part 3):&lt;/strong&gt; stand in front of servers, hiding and protecting them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API gateway (this post):&lt;/strong&gt; give a growing backend one smart, consistent front door
Each one answers a question that only appears once the previous layer exists. That's how real architecture grows: not designed all at once, but earned one problem at a time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to Take Away
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A gateway is a front door.&lt;/strong&gt; Clients talk to one address, and everything behind it can change freely.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It handles the repetitive stuff&lt;/strong&gt; (auth, rate limits, routing, logging) once, at the edge, instead of twelve times inside.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's an evolved reverse proxy&lt;/strong&gt;: same family, but it understands your API, not just bytes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't let it become a junk drawer.&lt;/strong&gt; Keep business logic in your services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wait until you need one.&lt;/strong&gt; Complexity you add too early is complexity you maintain forever.
The next time an app loads a screen full of data from a dozen places in a single smooth tap, you'll know there's probably a front desk somewhere, calmly handling the whole hotel.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;Next in this series: caching beyond the CDN. Redis, in-memory caching, and the hardest question in computing: "when is this stored answer no longer true?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Are you running a gateway today, or still happily on plain nginx? Tell me in the comments; I'm curious where people draw that line.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>webdev</category>
      <category>backend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What nginx Is Actually Doing: Reverse Proxies vs Forward Proxies Explained</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Thu, 19 Nov 2026 10:14:06 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/what-nginx-is-actually-doing-reverse-proxies-vs-forward-proxies-explained-3451</link>
      <guid>https://dev.to/stephen_jarso/what-nginx-is-actually-doing-reverse-proxies-vs-forward-proxies-explained-3451</guid>
      <description>&lt;p&gt;&lt;strong&gt;Stop nodding along in meetings. Here is the dead-simple, no-jargon breakdown of what proxies actually do and why nginx is at the front door of every app.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hey fellow devs! Let’s talk about something we’ve all done: nodding along in a meeting when someone mentions a "proxy," while secretly having only a vague idea of how it actually works. &lt;/p&gt;

&lt;p&gt;For a long time, it was just filed under the "networking magic" folder in my brain. I knew nginx sat "in front of" my app somehow, and I knew VPNs hid my location. I just assumed they were basically the same thing.&lt;/p&gt;

&lt;p&gt;They aren't. They’re actually closer to opposites. &lt;/p&gt;

&lt;p&gt;Once the distinction clicks, a ton of tools you use every day suddenly make complete sense. Let's break it down without the academic jargon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start With the Word Itself&lt;/strong&gt;&lt;br&gt;
A proxy, at its simplest form is a stand-in.Something that acts on behalf of someone else.&lt;br&gt;
That's it.That's the whole concept.Everything else is just:on behalf of whom,exactly?&lt;br&gt;
That single question splits proxies into two completely different tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forward Proxy:Standing in for the User&lt;/strong&gt;&lt;br&gt;
A forward proxy sits infront of a client(you,your laptop,your browser) and makes requests to the internet on your behalf.&lt;/p&gt;

&lt;p&gt;Picture sending a friend to buy something for you instead of you going yourself.The shop only sees your friend ,it doesn't know who actually wants the item or why.&lt;/p&gt;

&lt;p&gt;Thats a forward proxy.Your request goes to the proxy first.The proxy forwards it to the actual destination,gets the response, and hands it back to you.From the destination's point of view,the proxy is the one asking not you.&lt;/p&gt;

&lt;p&gt;This is the set up behind things like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Corporate networks - a company routes all employee traffic through a proxy to monitor or restrict what sites are accessible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;VPNs - functionally a forward proxy with encryption layered on top;your traffic exits from the VPN,s location, not your actual one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bypassing geo-restrictions - routing your request through a proxy in another country makes you appear to be browsing from there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anonymity tools - services designed to hide the original requesters identity from the destination.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The theme across all these:The proxy hides the client from the server.The destination sees the proxy,it doesnt see you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reverse Proxy:Standing In for The Server&lt;/strong&gt;&lt;br&gt;
A reverse proxy does the mirror-image job.It sits in front of a server(or a group of servers) and receives requests on the server's behalf.&lt;br&gt;
Same shopping analogy,flipped.Now imagine a single receptionist standing infront of an office building,taking every visitors request and deciding which internal department actually handles it.Visitors talk to the receptionist.They never learn or need to know which specific desk,floor or person is doing the actual work behind the scenes.&lt;br&gt;
That receptionist is your reverse proxy.Requests arrive at it first.It decides where they actually go(which backend server,which service)fetches the response and hands it back to the user.From the user's point of view,they were just talking to the website.They have no idea a reverse proxy was involved,let alone how many real servers exist behind it.&lt;br&gt;
This time, the them flips:The proxy hides the server from the client.&lt;/p&gt;

&lt;p&gt;This is exactly what nginx is doing in most setups.Its the receptionist standing in front of your actual application,deciding what happens to each incoming request before your app code ever sees it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The One -Line Way to Never Confuse Them Again&lt;/strong&gt;&lt;br&gt;
Here's the distinction i wish someone had just said to me plainly,instead of making me piece it together from documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Forward proxy&lt;/em&gt;&lt;/strong&gt; -&amp;gt; works fro the client,hides the client from the internet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Reverse proxy&lt;/em&gt;&lt;/strong&gt; -&amp;gt; works for the server,hides the server from the internet.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same mechanisms,sits in the middle,forward the request,pointed in opposite directions.Thats genuinely the entire conceptual difference.Everything below is just what you do with it once its in place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So what is Nginx Actually doing All Day?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have deployed literally anything, you've probably had nginx (or something like it) sitting in front of your app without fully knowing why it needed to be there. Here's the job list:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hiding your real server setup. Users hit nginx. nginx decides, silently, which backend actually handles it. You could have one server or fifty behind it, nobody outside can tell, and that's the point.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load balancing. This is where reverse proxies and load balancers overlap so much people use the terms interchangeably. nginx can distribute incoming requests across multiple backend instances, everything from Part 2, implemented via a reverse proxy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SSL/TLS termination. Handling HTTPS encryption is genuinely expensive computationally. Reverse proxies commonly handle the encryption/decryption once, at the edge, then talk to internal servers over plain, unencrypted HTTP inside your own trusted network. Your app code doesn't have to think about certificates at all.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Serving static files directly. Images, CSS, JS, nginx can hand these out itself without ever bothering your actual application server. Faster, and it keeps your app free to focus on real logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Caching responses. Similar spirit to the CDN from Part 1, but local, nginx can cache responses itself and skip hitting your backend for repeat requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compression. Squeezing responses with gzip or brotli before they leave the server, cutting how much data has to travel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Routing based on the URL. /api/* goes to your backend service. / goes to your frontend. /admin goes to a completely different internal service. One entry point, many destinations, invisible to the visitor.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice how many of these have nothing to do with "picking a server", that's only the load-balancing use case. A reverse proxy is a much broader tool that load balancing happens to be one job for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Concrete Before-and-After&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Without a reverse proxy&lt;/em&gt;&lt;/strong&gt;, your Node/Go/whatever app server talks directly to the internet. It has to handle HTTPS itself, serve its own static files, deal with malicious traffic directly, and has no protection if a specific server instance goes down. Every one of those is a job your app was never really designed to do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;With a reverse proxy&lt;/em&gt;&lt;/strong&gt; in front of it, your app only ever talks to nginx, on your own internal network, over plain HTTP, and only receives requests nginx has already decided are legitimate and ready to be handled. Your app gets to just be an app. Everything else — encryption, routing, static files, load distribution, is handled by something built specifically for that job.&lt;/p&gt;

&lt;p&gt;This is a big part of why "put nginx in front of it" is such a common, almost automatic step in production deployments. It's not tradition for tradition's sake. It's genuinely doing a lot of quiet, necessary work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where You've Actually Been Using Both, Already&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Forward proxy, in disguise:&lt;/em&gt;&lt;/strong&gt; if you've ever used a VPN to watch something unavailable in your region, or a company laptop that mysteriously can't reach certain sites, you've used a forward proxy. It stood between you and the internet, and the destination only ever saw it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Reverse proxy, in disguise:&lt;/em&gt;&lt;/strong&gt; if you've ever deployed a Next.js app behind nginx, put a Go backend behind Caddy, or used Cloudflare in front of any website, you've used a reverse proxy. Cloudflare, in fact, is really a giant reverse proxy network with CDN and security features bolted on. Same core idea from Part 1's CDN discussion, extended.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where This Sits Next to Everything Else in This Series&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Zooming out across the series so far:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;CDN (Part 1): copies your content geographically closer to users, so requests travel less distance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load balancer (Part 2): spreads requests across multiple servers, so no single machine drowns&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reverse proxy (this post): sits in front of your server(s), doing routing, SSL, caching, and yes often load balancing too&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They're not competing tools. In a real production system, they typically all exist at once, layered on top of each other. A request might hit a CDN edge node first, which is really a reverse proxy, which might forward it to an origin server that itself sits behind another reverse proxy doing load balancing across several app instances.&lt;/p&gt;

&lt;p&gt;It sounds like a lot of moving parts, and it is — but each one is solving one specific, understandable problem. Once you can name each layer, "the internet" stops being one big blur of magic and starts looking like a stack of individually sensible decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to Take Away&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;A proxy is a stand-in&lt;/em&gt;&lt;/strong&gt; — the only real question is who it's standing in for.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Forward proxy = for the client&lt;/em&gt;&lt;/strong&gt;, hiding the client from the destination.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Reverse proxy = for the server,&lt;/em&gt;&lt;/strong&gt; hiding the server (and its internal structure) from the client.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;nginx's job is much bigger than load balancing&lt;/em&gt;&lt;/strong&gt;  routing, SSL termination, caching, compression, and serving static files are all part of the same role.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Next time you write &lt;em&gt;server_name&lt;/em&gt; in an nginx config, you'll know exactly whose interests that block of text is representing, and whose it's quietly hiding.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How the Internet Feels Instant: CDNs, Load Balancers, and the Invisible Infrastructure Behind Every Fast App</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Fri, 18 Sep 2026 16:00:02 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/how-the-internet-feels-instant-cdns-load-balancers-and-the-invisible-infrastructure-behind-every-5gn</link>
      <guid>https://dev.to/stephen_jarso/how-the-internet-feels-instant-cdns-load-balancers-and-the-invisible-infrastructure-behind-every-5gn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Your Server Doesn't Hate You.It's Just Miles Away.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Picture this:you just finished building a website.&lt;/p&gt;

&lt;p&gt;Testing it on your own computer feels amazing.It is snappy-meaning it responds instantly,loading images and text in the blink of an eye.&lt;/p&gt;

&lt;p&gt;Excited you launch it on the internet.Then your friend on the other side of the world tries to open it..It takes three painful seconds just to load the homepage.&lt;/p&gt;

&lt;p&gt;Before you panic,take a breath:you didn't build a bad website.Your main computer systems(the server)is just physically far away, and the internet still has to obey the laws of physics.&lt;/p&gt;

&lt;p&gt;Data doesn't teleport.It is a physical signal.To get from a computer center in Virginia to a phone in Singapore, your website's data has to pack its bags.It travels through thousands of miles of glass cables buried underground,dives deep water under the pacific ocean, and bounces across continents.Every single miles adds a tiny delay.&lt;br&gt;
This is the exact problem a massive,hidden layer of global infrastructure exists to solve.&lt;/p&gt;

&lt;p&gt;The engineers who built the internet didn't figure out how to make data travel faster than the speed of light.Nobody has cracked that yet.Instead, they did something cleverer:they figured out how to make the data travel less far.&lt;/p&gt;

&lt;p&gt;This is the story of CDNs, edge servers, and load balancers.It is the invisible delivery system that quietly decides whether your favorite app feels instant or broken.&lt;/p&gt;

&lt;p&gt;Let's actually try to understand how it works,without getting lost in the heavy tech jargon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Core Problem:Distance Equals Delay(latency)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Everytime you click a button or open a page on an app,your phone has to send a physical message to a computer(the server) on the other side of the world, and that server has to send a message back.&lt;/p&gt;

&lt;p&gt;If your website's main server sits in Virginia and a user is browsing from Nairobi,that round trip across the globe takes time.Even if everything goes perfectly,the physical journey alone takes about a quarter of a second before the computer has even begun to process what you asked for.&lt;/p&gt;

&lt;p&gt;That might sound fast,but think about everything on a modern webpage.A single page isn't just one file.It is made up of dozens of pieces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Individual image and photos&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The styling rules that make it look pretty&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The hidden code instructions that make buttons work&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requests for live updates like prices or weather&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your phone has to make that massive global round trip for every single one of those pieces, it doesn't matter how well-written your website is.You are completely trapped by geography.&lt;/p&gt;

&lt;p&gt;So, the tech world came up with a beautifully simple answer:stop making every single person talk to one lonely server on the other side of the planet.Instead, let's put copies of the website everywhere.&lt;/p&gt;

&lt;p&gt;That is exactly what a CDN(Content Delivery Network) does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CDNs: Your Content, Cloned Across the Planet&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A CDN (Content Delivery Network) is simply a global team of helper computers spread across cities, countries, and continents. Each one holds a saved copy of your website.&lt;/p&gt;

&lt;p&gt;When someone visits your site, they don't have to reach all the way back to your main computer (the origin server). Instead, they connect to the helper computer closest to their house.&lt;/p&gt;

&lt;p&gt;Think of it like buying coffee. If you want a morning latte, you don't drive hundreds of miles to a central coffee bean factory. You go to the local coffee shop down the street that already has the beans roasted, ground, and ready to go. The CDN is that neighborhood shop, serving up your website from local stock.&lt;/p&gt;

&lt;p&gt;In the tech world, these neighborhood shops are called PoPs (Points of Presence). A large CDN provider might have hundreds of these locations scattered around the globe, each packed with a small army of edge servers (the helper computers) waiting to hand out your content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Happens Behind the Scenes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user clicks on your site to see a picture, a silent game of telephone happens in milliseconds:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Request: The user asks to see a photo on your site.&lt;/li&gt;
&lt;li&gt;The Smart Shortcut:The internet automatically redirects their phone to the closest helper computer in their city.&lt;/li&gt;
&lt;li&gt;The Quick Win (Cache Hit): If the helper computer already has a copy of that photo saved, it hands it over instantly. Total speed victory.&lt;/li&gt;
&lt;li&gt;The Backup Plan (Cache Miss): If the helper computer doesn't have the photo yet, it quickly sprints back to your main origin server, grabs a copy, saves it for later, and hands it to the user.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The very first user who visits your site from a new city has to wait a tiny bit longer while the helper computer fetches the original file. But every single user after them gets the express lane, because the local shop now has it fully in stock.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edge Servers: The Actual Machines Doing the Work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"Edge" is one of those tech words that sounds way more mysterious than it actually is. An edge server is simply a computer that is physically close to the person browsing your site. It sits at the outer "edge" of the global internet map, right where the users are, instead of being buried deep in a single, faraway data center.&lt;br&gt;
These days, edge servers do a lot more than just hold onto static photos. Modern systems let you run actual code right there next to the user. Without making a giant trip back to your main server, an edge server can instantly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check if a user is logged in&lt;/li&gt;
&lt;li&gt;Redirect someone to a different page&lt;/li&gt;
&lt;li&gt;Show a user a new experimental feature to test if they like it&lt;/li&gt;
&lt;li&gt;Custom-build a webpage on the fly&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you have ever used popular modern hosting tools like Vercel or Cloudflare, you have already put code onto the edge without even realizing it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caching: The Art of Not Doing Work Twice&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All of this speed is powered by a concept called caching. The idea is beautifully simple: save the results of hard or expensive work, and hand out that saved copy instead of doing the work all over again.&lt;/p&gt;

&lt;p&gt;The tricky part isn't saving the file—it's knowing when that file has become old and outdated. In fact, knowing when to stop trusting a saved copy is famously one of the hardest problems in all of computer science.&lt;/p&gt;

&lt;p&gt;Here are the real-world strategies developers use to solve it, explained simply:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Timer (TTL / Time To Live): You put a countdown timer on a saved file (like setting it to expire in one hour). Once the timer hits zero, the helper computer throws it away and grabs a fresh copy from the main server.&lt;/li&gt;
&lt;li&gt;The Name Change (Cache Busting): If you update your website's code, instead of trying to delete the old file from millions of computers, you just give the new file a brand new name (like changing website-code.js to website-code-v2.js). The internet sees the new name, realizes it's a totally new file, and loads it instantly with zero glitches.&lt;/li&gt;
&lt;li&gt;The Manual Panic Button (Purge APIs): If you make an urgent fix and absolutely cannot wait for a timer to run out, you click a button to manually tell the global network: "Drop the old copies right now."&lt;/li&gt;
&lt;li&gt;The "Fix It Later" Trick (Stale-While-Revalidate): When a user asks for a page, the helper computer gives them the slightly old, saved version immediately so they don't have to wait. Then, while the user is happily reading, the computer quietly updates itself in the background so it's perfectly fresh for the next person.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have ever changed a setting to tell a server to save a file for an hour and then moved on with your day, congratulations: you were doing complex global systems engineering without even knowing it!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Load Balancing: Don't Let One Server Take the Whole Hit&lt;/strong&gt;&lt;br&gt;
While CDNs solve the "content is too far away" problem, load balancing solves a completely different nightmare: "too many people are trying to use the same computer at the same time."&lt;/p&gt;

&lt;p&gt;Imagine a video goes viral or a massive online shopping event launches. Millions of people rush to click the exact same button at the exact same moment. If all those requests hit a single computer, that machine will overheat, run out of memory, and completely crash.&lt;/p&gt;

&lt;p&gt;A load balancer is like a host at a wildly popular restaurant. Instead of letting a thousand guests crowd around a single waiter, the host smoothly distributes the guests across hundreds of open tables. It sits in front of a whole group of computers and decides which one is ready to handle the next visitor so that no single machine melts under pressure.&lt;/p&gt;

&lt;p&gt;Here is how they distribute the crowd:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Card Dealer (Round Robin): Requests rotate through the computers in a strict order, exactly like dealing cards around a poker table.&lt;/li&gt;
&lt;li&gt;The "Who is Free?" Check (Least Connections): The system checks to see which computer is currently the least busy and sends the next visitor there.&lt;/li&gt;
&lt;li&gt;The Familiar Face (IP Hash): The system ensures that a specific user consistently lands on the exact same server. This is super helpful so the website doesn't suddenly forget who you are mid-click.&lt;/li&gt;
&lt;li&gt;The Doctor's Visit (Health Checks): The load balancer constantly pings all the computers to make sure they are feeling okay. If one computer quietly stops responding, the load balancer stops sending traffic to it entirely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This health check is how websites survive a server dying at 3:00 AM without anyone noticing until the next morning. One computer goes down, the load balancer instantly reroutes the traffic to healthy computers, and the users never experience a single glitch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Geographic Routing: How the Internet Knows Where You Are&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is the part that feels like a magic trick. How does a request from a user in Nairobi automatically end up at a helper computer in Johannesburg, instead of accidentally flying all the way to a server in Frankfurt?&lt;/p&gt;

&lt;p&gt;The answer is a trick called Anycast routing.&lt;/p&gt;

&lt;p&gt;Instead of giving every computer on Earth a unique digital address, engineers give multiple helper computers around the world the exact same address.&lt;/p&gt;

&lt;p&gt;It works less like a GPS tracking your location and more like the postal service. If you drop a letter into a mailbox addressed to a major grocery chain, the postal system naturally sends it to the closest distribution center, not one on the other side of the country. The internet's routing system naturally prefers the shortest, least congested path. It happens invisibly, before your code even has a chance to run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It All Fits Together&lt;/strong&gt;&lt;br&gt;
Here is the full picture of what happens in the blink of an eye when a user clicks on your website:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Click: A user requests your website.&lt;/li&gt;
&lt;li&gt;The Shortcut: The internet's postal system automatically routes them to the physically closest helper computer.&lt;/li&gt;
&lt;li&gt;The Quick Check: That local helper computer checks its saved files (its cache).&lt;/li&gt;
&lt;li&gt;The Fast Lane (Cache Hit): If it has the file, it hands it to the user instantly. Your main server never even hears about it.&lt;/li&gt;
&lt;li&gt;The Backup Plan (Cache Miss): If it doesn't have the file, the helper computer sprints back to your main server headquarters.&lt;/li&gt;
&lt;li&gt;The Traffic Cop: At headquarters, a load balancer greets the request and hands it to the server that is least busy.&lt;/li&gt;
&lt;li&gt;The Return Journey: The server hands the file back, the helper computer saves a copy for the next person, and the user's page loads.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every single layer exists to answer one question: how do we get this website to the user as fast and as reliably as possible?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Actually Matters to You&lt;/strong&gt;&lt;br&gt;
You don't need to build your own global network to benefit from this knowledge. If you launch your projects on modern web platforms like Vercel, Netlify, or Cloudflare Pages, you are already using CDNs, edge computers, and smart routing without having to configure a single setting.&lt;/p&gt;

&lt;p&gt;But understanding how the foundation works completely changes how you build things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No More Mystery Bugs: You won't be surprised when a bug you "fixed" still shows up for some users. You will know it's just an old, saved copy stuck in a helper computer somewhere (a stale cache), not broken code.&lt;/li&gt;
&lt;li&gt;Smart Choices: You will understand why simple things like photos should be saved everywhere aggressively, while live updates like bank balances shouldn't be.&lt;/li&gt;
&lt;li&gt;No More Shrugging: You can actually think logically about why a website is running slow, instead of just shrugging your shoulders and blaming "the internet."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next time your app feels completely instant to someone living on the other side of the world, remember that it isn't luck. It is a beautiful, silent relay team of helper computers, traffic cops, and smart routing decisions, all working exactly as designed, entirely out of sight.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>performance</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Moving Beyond CRUD: Building a Geofenced Network Engine from Scratch</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Sun, 19 Jul 2026 19:34:36 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/moving-beyond-crud-building-a-geofenced-network-engine-from-scratch-ffd</link>
      <guid>https://dev.to/stephen_jarso/moving-beyond-crud-building-a-geofenced-network-engine-from-scratch-ffd</guid>
      <description>&lt;h2&gt;
  
  
  Why I am Leaving Simple Web Apps Behind
&lt;/h2&gt;

&lt;p&gt;Let’s be completely honest: There are only so many Todo apps, e-commerce clones, and standard REST/CRUD dashboards you can build before you start craving real engineering depth. &lt;/p&gt;

&lt;p&gt;Lately, I have been shifting my focus toward &lt;strong&gt;networking, lower-level protocols, and infrastructure security&lt;/strong&gt;. I wanted my next portfolio project to be a massive learning journey something that forced me to think about raw binary parsing, kernel-space performance, cryptographic handshakes, and data pipeline observability.&lt;/p&gt;

&lt;p&gt;So, I decided to bypass standard application-level programming and design a &lt;strong&gt;Software-Defined, Geofenced Mesh Network with an AI Anomaly Detection Layer&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Here is the architectural blueprint of how I am combining &lt;strong&gt;custom socket programming, cryptographic spatial data, and neural networks&lt;/strong&gt; into an omniscient, real-time "God-View" system.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Architectural Vision
&lt;/h2&gt;

&lt;p&gt;Imagine a secure private network overlay where data routing is strictly bound by physics and geography. Devices acting as nodes connect to an edge broker and transmit real-time telemetry. However, data packets are cryptographically verified based on physical coordinates. &lt;/p&gt;

&lt;p&gt;If a malicious actor steals credentials and attempts to access the network from an unauthorized region, or uses an automated script to spoof their GPS, the infrastructure detects it instantly. A neural network constantly evaluates the physical location claim against raw network characteristics (like latency jitter and packet transit variations). If a discrepancy is found, the connection is instantly severed.&lt;/p&gt;

&lt;p&gt;To monitor this entirely stateful environment, the central control server pipes live infrastructure logs over WebSockets to a web-based &lt;strong&gt;"God-View" dashboard&lt;/strong&gt;. This top-down view visualizes real-time data tunnels lighting up, global traceroute paths, and localized security flags mapped over an interactive geographical grid.&lt;/p&gt;

&lt;h2&gt;
  
  
  The High-Performance Tech Stack
&lt;/h2&gt;

&lt;p&gt;To manage thousands of concurrent streams without high latency or packet drop, the architecture skips generic web frameworks in favor of system-level technologies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;The Core Network Engine (Go):&lt;/strong&gt; I chose &lt;strong&gt;Go (Golang)&lt;/strong&gt; for the ingestion engine. Go’s native network stack (&lt;code&gt;net&lt;/code&gt; package) paired with ultra-lightweight concurrent goroutines allows it to manage thousands of open TCP/UDP sockets out of the box using minimal memory. The engine’s primary job is to strip framing headers, parse raw binary payloads, and handle connection lifecycles.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Cryptographic Tunneling Layer (WireGuard):&lt;/strong&gt; Instead of routing sensitive telemetry through slow, user-space proxy code, the application interfaces directly with &lt;strong&gt;WireGuard&lt;/strong&gt;. WireGuard handles state-of-the-art, kernel-level encrypted virtual interfaces. This allows us to dynamically spin up, configure, and tear down secure tunnels between edge IoT devices and the backend infrastructure programmatically.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Security Brain (Python + PyTorch):&lt;/strong&gt; How do you catch a bad actor faking their GPS coordinates? You use a neural network. I am building a lightweight &lt;strong&gt;Anomaly Detection Autoencoder&lt;/strong&gt; in PyTorch hosted behind a high-speed gRPC interface. The Go engine streams network telemetry metrics such as round-trip time (RTT), Time-to-Live (TTL) changes, and network jitter—to the Python model. The neural net determines if the physical location claim perfectly correlates with the physical realities of the network packet’s transit path.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Telemetry Storage (Redis &amp;amp; VictoriaMetrics):&lt;/strong&gt; Standard relational databases (like MySQL) or document stores (like MongoDB) will choke under thousands of streaming location writes per second. I am utilizing &lt;strong&gt;Redis&lt;/strong&gt; for sub-millisecond coordinate caching and geographical command filtering (&lt;code&gt;GEOADD&lt;/code&gt;/&lt;code&gt;GEORADIUS&lt;/code&gt;), alongside &lt;strong&gt;VictoriaMetrics&lt;/strong&gt; to aggregate long-term time-series network health data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Defining the Protocol Data Blueprint
&lt;/h2&gt;

&lt;p&gt;To optimize performance, we don't send heavy JSON payloads over the raw sockets. Instead, we use a compact, structured binary frame format to keep our network footprint small and predictable. &lt;/p&gt;

&lt;p&gt;Each device telemetry packet is exactly &lt;strong&gt;24 bytes&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Offset (Bytes)&lt;/th&gt;
&lt;th&gt;Field Name&lt;/th&gt;
&lt;th&gt;Data Type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x00 - 0x03&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DeviceID&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;uint32&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Unique tracking identifier for the node.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x04 - 0x11&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Latitude&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;float64&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Encoded high-precision GPS latitude coordinate.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x12 - 0x1F&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Longitude&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;float64&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Encoded high-precision GPS longitude coordinate.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x20 - 0x23&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Timestamp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;uint32&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;UNIX epoch timestamp of packet transmission.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Let’s Discuss!
&lt;/h2&gt;

&lt;p&gt;This project is taking me completely out of my comfort zone, and I am bound to run into significant architectural hurdles especially when trying to keep serialization latency low while piping network metrics into Python for evaluation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you ever designed a custom binary packet system or handled live geospatial multi-node streaming? What tricks do you use to manage persistent state safely across asynchronous networking platforms?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let me know your thoughts, tips, or architecture critiques in the comments below!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>networking</category>
      <category>python</category>
      <category>assembly</category>
    </item>
    <item>
      <title>Confessions of a Dev #2:The Interview Answer That Haunts Me</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Thu, 23 Apr 2026 03:44:43 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/confessions-of-a-dev-2the-interview-answer-that-haunts-me-558p</link>
      <guid>https://dev.to/stephen_jarso/confessions-of-a-dev-2the-interview-answer-that-haunts-me-558p</guid>
      <description>&lt;p&gt;You know that feeling — walking out of an interview, and by the time you hit the elevator, your brain already starts replaying that one question.&lt;/p&gt;

&lt;p&gt;The one where you said something… fine. Acceptable. Professional.&lt;/p&gt;

&lt;p&gt;But deep down, you know you had a killer answer in you. The honest one. The clever one. The one that would've made the interviewer lean in and say, "Tell me more."&lt;/p&gt;

&lt;p&gt;Instead, you played it safe. You gave the textbook response. You talked about "process improvement" and "team collaboration" like a LinkedIn post come to life.&lt;/p&gt;

&lt;p&gt;And now, days later, you're still thinking about what you should have said.&lt;/p&gt;

&lt;p&gt;Not because you lied. But because you held back.&lt;/p&gt;

&lt;p&gt;Here's mine.&lt;/p&gt;

&lt;p&gt;I was interviewing for a Flutter role. Everything was flowing — architecture, state management, animations. Then came the question:&lt;/p&gt;

&lt;p&gt;"What do you use for the backend?"&lt;/p&gt;

&lt;p&gt;What I said:&lt;br&gt;
"Dart."&lt;/p&gt;

&lt;p&gt;Just… Dart. Like it's a backend. Like that's a normal thing a reasonable person would say.&lt;/p&gt;

&lt;p&gt;What I should have said:&lt;br&gt;
"Firebase. Or if I need more control, a custom API with Node or Go. But Dart? Only if I'm using Serverpod or Dart Frog — and even then, I'd clarify that's not the same as 'Dart by itself.'"&lt;/p&gt;

&lt;p&gt;The interviewer paused. Typed something. Moved on.&lt;/p&gt;

&lt;p&gt;And me? I sat there, smile frozen, already replaying the horror in slow motion.&lt;/p&gt;

&lt;p&gt;So here's where I leave you hanging:&lt;/p&gt;

&lt;p&gt;Did I get the job?&lt;/p&gt;

&lt;p&gt;…That's for Dev Confessions #3.&lt;/p&gt;

&lt;p&gt;Now your turn — drop in the comments:&lt;br&gt;
What's one thing you said in an interview that still makes you cringe? And what should you have said instead?&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Confessions of a Dev #1:I Went Blank When Asked "What's an API?"</title>
      <dc:creator>Stephen Jarso</dc:creator>
      <pubDate>Wed, 15 Apr 2026 02:39:43 +0000</pubDate>
      <link>https://dev.to/stephen_jarso/confessions-of-a-dev-1i-went-blank-when-asked-whats-an-api-4e5f</link>
      <guid>https://dev.to/stephen_jarso/confessions-of-a-dev-1i-went-blank-when-asked-whats-an-api-4e5f</guid>
      <description>&lt;p&gt;Last week, a friend asked me something so basic, so fundamental that i should have been able to answer it in my sleep.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Hey, quick question...what exactly is an API?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Not a trick question. Not an interview. Just two devs talking.&lt;/p&gt;

&lt;p&gt;And I went blank.&lt;/p&gt;

&lt;p&gt;I’ve built REST APIs. I’ve authenticated with JWT.&lt;/p&gt;

&lt;p&gt;But in that moment? Nothing.&lt;/p&gt;

&lt;p&gt;So I did the thing we all do when our brain short-circuits:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I mean… I know how they work? Or what they do? You know."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We both laughed. He nodded like he understood. But I knew: I had failed the simplest test of all.&lt;br&gt;
&lt;strong&gt;The Problem (It’s Worse Than You Think)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a non-technical person asks “what’s an API?”, you can use a waiter or a mailman analogy. They’ll be happy.&lt;/p&gt;

&lt;p&gt;But when a technical person asks, they’re not looking for a metaphor. They already know what a server is, what HTTP is, what JSON is. They’re asking for the essential definition – the crisp, precise, almost philosophical answer.&lt;/p&gt;

&lt;p&gt;And that’s way harder.&lt;br&gt;
Because APIs are so obvious to us that we’ve never actually articulated them. We just… use them. The definition lives in our fingertips, not our tongue.&lt;/p&gt;

&lt;p&gt;So after that humiliating moment, I went home and forced myself to answer properly. Here’s what I came up with.&lt;br&gt;
&lt;strong&gt;What I Should Have Said (Technical Edition)&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;The One-Sentence Definition (Crisp &amp;amp; Precise)&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“An API is a defined interface that specifies how one software component can interact with another – including valid requests, expected responses, and the underlying protocol (usually HTTP).”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That’s the technical answer. No fluff. No waiter.&lt;br&gt;
&lt;strong&gt;The Slightly More Technical Answer&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“An API is a contract between a client and a server. It says: ‘If you send me a request in this shape, to this URL, with these headers, I’ll send you back a response in this shape – and here are the status codes to tell you what happened.’”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The “Ah, Right” Analogy (Still Technical)&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“Think of a database query language like SQL. You send a SELECT statement, you get a result set. An API is the same idea, but over HTTP – and instead of tables, you work with resources (users, orders, products).”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The Shortest Possible Answer&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“An API is a layer that abstracts an implementation behind a set of publicly accessible operations.”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That one would have made me sound smart. But I didn’t say it. I said “uh… you know.”&lt;br&gt;
&lt;strong&gt;Why Technical People Go Blank on Basic Definitions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It’s not because we don’t know. It’s because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; We think in use cases, not definitions – “An API is what I call to get user data” is not a definition, it’s an example. But that’s how our brains store it.&lt;/li&gt;
&lt;li&gt;We confuse “how it works” with “what it is” – I could have explained the HTTP request cycle, JSON serialization, status codes, rate limiting, and authentication. But that’s not what an API is. That’s how you use one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;3.We’ve never had to define it – In school, they teach you syntax, not definitions. In work, you just build things. No one ever says “define API” in a sprint planning meeting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Real Lesson (For Devs, By a Dev)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Knowing how to build something is not the same as knowing how to define it.&lt;/p&gt;

&lt;p&gt;The best developers can do both. They can talk about implementation and they can zoom out to the 10,000-foot definition without stumbling.&lt;/p&gt;

&lt;p&gt;So here’s my challenge to you, fellow dev:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Without looking it up, define these terms in one sentence – out loud, right now:

    HTTP

    JSON

    JWT

    DOM

    TCP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you can’t, welcome to the club. Let’s practice together.&lt;br&gt;
&lt;strong&gt;Call to Action (Your Confession)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now it’s your turn.&lt;/p&gt;

&lt;p&gt;What basic technical question made you go blank in front of another developer?&lt;/p&gt;

&lt;p&gt;Drop your confession in the comments. No judgment. Just devs being honest.&lt;/p&gt;

&lt;p&gt;This is Confessions of a Dev. We’ve all been there.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>googleaichallenge</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
