<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bunbunrong on Medium]]></title>
        <description><![CDATA[Stories by Bunbunrong on Medium]]></description>
        <link>https://medium.com/@bunbunrong993?source=rss-8c7c8f5d9108------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GQurwV1NZhj9V70cZ5cXYQ@2x.jpeg</url>
            <title>Stories by Bunbunrong on Medium</title>
            <link>https://medium.com/@bunbunrong993?source=rss-8c7c8f5d9108------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:57:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bunbunrong993/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your API Is Slow. Now What? A Practical Guide to Finding the Real Bottleneck]]></title>
            <link>https://medium.com/@bunbunrong993/your-api-is-slow-now-what-a-practical-guide-to-finding-the-real-bottleneck-e42cf2b00372?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/e42cf2b00372</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 09:50:13 GMT</pubDate>
            <atom:updated>2026-09-05T00:31:56.727Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>“The API is extremely slow. Sometimes it takes eight seconds. Other times, the same endpoint responds in less than 200 milliseconds.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*Xu3iq_drwk5Lm8WYbvn2sA@2x.jpeg" /></figure><p>That message looks simple.</p><p>It isn’t.</p><p>When you’re responsible for a production system, one of the most frustrating incidents is an API that is <strong>sometimes slow</strong>. There is no obvious error. The service is still running. Kubernetes reports that all Pods are healthy. CPU usage looks normal. Memory looks fine. Nothing appears to be broken.</p><p>So you restart the Pods.</p><p>For a few minutes, everything looks better.</p><p>Then the problem comes back.</p><p>This is where many developers start changing things without really knowing what they’re fixing. They increase CPU limits, add more replicas, restart containers, increase database resources, or change a timeout.</p><p>Sometimes those changes appear to help.</p><p>But there is a much more important question to answer first:</p><blockquote><strong><em>Where did the eight seconds actually go?</em></strong></blockquote><p>That question changes the entire way you approach performance problems.</p><p>A slow API is not a root cause. It is a symptom.</p><p>The real engineering problem is finding <strong>which part of the system is responsible for the latency and why</strong>.</p><h3>A Request Is a Journey Through Your System</h3><p>When we think about an API request, it’s easy to imagine something simple:</p><pre>Client → API → Database → Response</pre><p>Real production systems are rarely that simple.</p><p>Consider an e-commerce platform built with Next.js, an API Gateway, several backend services, Redis, PostgreSQL, and external payment services.</p><p>A request for an order might travel through something like this:</p><pre>Customer<br>   │<br>   ▼<br>Next.js<br>   │<br>   ▼<br>Cloudflare<br>   │<br>   ▼<br>Load Balancer<br>   │<br>   ▼<br>Ingress<br>   │<br>   ▼<br>API Gateway<br>   │<br>   ▼<br>Order Service<br>   │<br>   ├───────────────┐<br>   │               │<br>   ▼               ▼<br> Redis         PostgreSQL<br>   │<br>   ▼<br>Product Service<br>   │<br>   ▼<br>External Service</pre><p>Now imagine a customer calls:</p><pre>GET /api/orders/12345</pre><p>and receives a response after eight seconds.</p><p>Which component caused the delay?</p><p>It could be the API Gateway.</p><p>It could be the Order Service.</p><p>It could be PostgreSQL.</p><p>It could be Redis.</p><p>It could be a network connection.</p><p>It could be another microservice.</p><p>It could even be an external API that your application has no control over.</p><p>The request may have spent its time approximately like this:</p><pre>Cloudflare             20ms<br>Ingress                 5ms<br>API Gateway            30ms<br>Order Service          40ms<br>Redis                  10ms<br>Product Service       200ms<br>PostgreSQL           7,700ms<br>                     --------<br>Total                 8,005ms</pre><p>From the customer’s perspective, the API took eight seconds.</p><p>But saying <strong>“the API is slow”</strong> doesn’t tell us much.</p><p>The useful information is that <strong>PostgreSQL consumed almost the entire eight seconds</strong>.</p><p>This is the first important habit to develop when debugging distributed systems:</p><blockquote><strong><em>Don’t ask only how slow the API is. Ask where the request spent its time.</em></strong></blockquote><h3>Before Fixing Performance, Define the Problem</h3><p>There is another problem with saying:</p><blockquote><em>“The API is slow.”</em></blockquote><p>Slow compared to what?</p><p>100 milliseconds?</p><p>500 milliseconds?</p><p>Five seconds?</p><p>And is every request slow, or only a small percentage?</p><p>These questions matter.</p><p>Suppose our monitoring system reports:</p><pre>p50 = 120ms<br>p95 = 300ms<br>p99 = 7.8s</pre><p>If you haven’t worked much with percentiles, these numbers can look confusing at first.</p><p>The <strong>p50</strong>, or 50th percentile, means roughly half of the requests completed faster than 120 milliseconds.</p><p>The <strong>p95</strong> means roughly 95% of requests completed faster than 300 milliseconds.</p><p>The <strong>p99</strong> means roughly 99% completed faster than 7.8 seconds.</p><p>The interesting part is that last number.</p><p>Most requests are relatively fast, but a small percentage are extremely slow.</p><p>That explains a common production situation where developers say:</p><blockquote><em>“It works fine for me.”</em></blockquote><p>while customers are reporting:</p><blockquote><em>“This page takes forever to load.”</em></blockquote><p>Both can be correct.</p><p>The application may perform well for most requests while having terrible tail latency for a smaller group.</p><p>This is why production performance analysis often focuses on percentiles such as <strong>p95 and p99</strong>, rather than looking only at average response time.</p><h3>Why the Average Can Hide a Serious Problem</h3><p>Imagine an API receives 100 requests.</p><p>Ninety-nine requests complete in 100 milliseconds.</p><p>One request takes 10 seconds.</p><p>The average is approximately:</p><pre>(99 × 100ms + 10,000ms) / 100<br>≈ 199ms</pre><p>Someone looking only at the average might conclude:</p><blockquote><em>“The API responds in about 200 milliseconds.”</em></blockquote><p>Technically, that’s true.</p><p>But one customer just waited ten seconds.</p><p>This is one reason performance engineering isn’t simply about finding a single number and trying to make it smaller.</p><p>You need to understand the <strong>distribution of latency</strong>.</p><p>A useful starting point is:</p><pre>p50 → typical experience<br>p95 → slower users<br>p99 → worst-case / tail experience</pre><p>The right target depends heavily on the endpoint and business requirement. A search endpoint, payment operation, internal admin API, and health check may all have very different acceptable latencies.</p><h3>Don’t Change Anything Yet</h3><p>When an API is slow, there is a strong temptation to immediately change infrastructure.</p><p>You might see:</p><pre>API latency → 8 seconds</pre><p>and respond with:</p><pre>Increase CPU<br>Increase memory<br>Add more Pods<br>Restart containers<br>Increase database resources<br>Increase timeout</pre><p>The problem is that none of these actions answer the most important question:</p><blockquote><strong><em>Why is it slow?</em></strong></blockquote><p>Suppose the real problem is a database query.</p><p>Adding more API Pods might temporarily reduce some queueing.</p><p>But it could also increase the number of database connections and make PostgreSQL even more overloaded.</p><p>Suppose the real problem is an external payment provider.</p><p>Adding CPU to your application won’t make the payment provider respond faster.</p><p>Suppose the real problem is an N+1 query pattern.</p><p>Adding more memory doesn’t remove the unnecessary network requests.</p><p>The better approach is to treat performance debugging as an investigation.</p><p>A useful mental model is:</p><pre>Symptom<br>   ↓<br>Measure<br>   ↓<br>Locate<br>   ↓<br>Form a hypothesis<br>   ↓<br>Collect evidence<br>   ↓<br>Run an experiment<br>   ↓<br>Identify root cause<br>   ↓<br>Apply the fix<br>   ↓<br>Measure again</pre><p>Notice that <strong>the fix comes near the end</strong>, not the beginning.</p><h3>Case Study: The Order API That Sometimes Takes Eight Seconds</h3><p>Let’s look at a realistic example.</p><p>Imagine our Order Service needs to return an order together with information about the products inside that order.</p><p>The implementation looks something like this:</p><pre>def get_order(order_id):<br>    order = Order.objects.get(id=order_id)</pre><pre>    items = OrderItem.objects.filter(order=order)</pre><pre>    products = []</pre><pre>    for item in items:<br>        response = requests.get(<br>            f&quot;https://product-service/products/{item.product_id}&quot;<br>        )</pre><pre>        products.append(response.json())</pre><pre>    return {<br>        &quot;order&quot;: order,<br>        &quot;items&quot;: products,<br>    }</pre><p>At first glance, this seems reasonable.</p><p>We retrieve the order, retrieve its items, and then retrieve the corresponding products.</p><p>But let’s think about what the program is actually doing.</p><p>Suppose an order contains five products.</p><p>The application makes approximately:</p><pre>Order Service<br>    │<br>    ├── Product Service<br>    ├── Product Service<br>    ├── Product Service<br>    ├── Product Service<br>    └── Product Service</pre><p>Five network requests.</p><p>Now suppose a customer has an order containing 50 items.</p><p>The application makes:</p><pre>1 request → Order<br>1 query   → Order Items<br>50 requests → Product Service</pre><p>That’s a very different workload.</p><p>If each Product Service request takes 150 milliseconds and they happen sequentially:</p><pre>50 × 150ms<br>= 7,500ms<br>= 7.5 seconds</pre><p>We’ve just explained the mysterious eight-second response.</p><p>And notice something important.</p><p>Nothing necessarily looks broken.</p><p>The containers can be healthy.</p><p>The Kubernetes Pods can be healthy.</p><p>CPU can be low.</p><p>Memory can be normal.</p><p>The network can be working correctly.</p><p>Every individual request is technically successful.</p><p>The architecture itself is causing the latency.</p><h3>Why Is the API Only Slow Sometimes?</h3><p>This is where the original symptom becomes useful.</p><p>The API wasn’t always slow.</p><p>It was <strong>sometimes</strong> slow.</p><p>That tells us something.</p><p>Maybe small orders look like this:</p><pre>5 products<br>×<br>150ms<br>≈<br>750ms</pre><p>while large orders look like:</p><pre>50 products<br>×<br>150ms<br>≈<br>7.5 seconds</pre><p>Now the behavior isn’t random anymore.</p><p>Latency is correlated with the number of products in the order.</p><p>That gives us a hypothesis:</p><blockquote><strong><em>The number of downstream requests increases with the size of the order.</em></strong></blockquote><p>That’s much more useful than:</p><blockquote><em>“The API is randomly slow.”</em></blockquote><h3>Fixing the N+1 Problem</h3><p>One possible solution is to change the Product Service API so it can retrieve multiple products at once.</p><p>Instead of:</p><pre>GET /products/1<br>GET /products/2<br>GET /products/3<br>GET /products/4<br>...</pre><p>we could provide something like:</p><pre>POST /products/batch</pre><p>with:</p><pre>{<br>  &quot;ids&quot;: [1, 2, 3, 4, 5]<br>}</pre><p>The architecture becomes:</p><pre>Order Service<br>      │<br>      │ one request<br>      ▼<br>Product Service<br>      │<br>      ▼<br>Multiple products</pre><p>We have changed the problem from:</p><pre>N network requests</pre><p>to:</p><pre>1 network request</pre><p>The exact implementation depends on the system. Sometimes batching is appropriate. Sometimes caching is better. Sometimes asynchronous processing makes more sense.</p><p>The important point is not the specific optimization.</p><p>The important point is how we discovered it:</p><pre>Slow request<br>    ↓<br>Trace request<br>    ↓<br>Find many downstream calls<br>    ↓<br>Notice relationship with order size<br>    ↓<br>Identify N+1 pattern<br>    ↓<br>Change architecture<br>    ↓<br>Measure again</pre><p>That’s performance debugging.</p><h3>What If the Database Is the Problem?</h3><p>Let’s say we’ve investigated the application and its service calls.</p><p>The next obvious place to look is PostgreSQL.</p><p>Suppose our Order Service executes:</p><pre>SELECT *<br>FROM orders<br>WHERE customer_id = 12345;</pre><p>Our database contains millions of orders.</p><p>We shouldn’t immediately create an index just because indexes are usually good.</p><p>First, ask PostgreSQL how it executes the query:</p><pre>EXPLAIN ANALYZE<br>SELECT *<br>FROM orders<br>WHERE customer_id = 12345;</pre><p>Imagine we discover:</p><pre>Seq Scan on orders<br>Rows Removed by Filter: 9,999,000<br>Execution Time: 4200 ms</pre><p>Now we have evidence.</p><p>PostgreSQL is scanning a huge amount of data to find the rows we need.</p><p>If customer_id is frequently used for filtering, an appropriate index may dramatically reduce the amount of work:</p><pre>CREATE INDEX idx_orders_customer_id<br>ON orders(customer_id);</pre><p>Afterward, we run the query again.</p><p>Perhaps the result becomes:</p><pre>Before:<br>4,200ms</pre><pre>After:<br>15ms</pre><p>Now imagine the original incident report:</p><blockquote><em>“The Kubernetes API is slow.”</em></blockquote><p>But Kubernetes wasn’t the problem.</p><p>The root cause was a database query.</p><p>This is why performance debugging needs to cross application boundaries.</p><h3>Low CPU Doesn’t Mean Your Application Is Healthy</h3><p>One of the most misleading signals during an incident is CPU.</p><p>Imagine you look at your Kubernetes dashboard and see:</p><pre>CPU:     20%<br>Memory:  40%<br>Pods:    Running</pre><p>Everything looks healthy.</p><p>But customers are waiting eight seconds for a response.</p><p>How?</p><p>Because an application doesn’t spend all of its time calculating.</p><p>A request might spend most of its lifetime waiting for something else:</p><pre>API<br> │<br> ├── waiting for PostgreSQL<br> │<br> ├── waiting for Redis<br> │<br> ├── waiting for another service<br> │<br> └── waiting for an external API</pre><p>While the process is waiting, CPU usage may remain low.</p><p>This is why:</p><blockquote><strong><em>CPU utilization is a useful signal, but it is not a complete definition of application health.</em></strong></blockquote><p>The same principle applies to memory.</p><p>A service can have plenty of free memory and still be slow because it is blocked on a database lock, waiting for a connection, waiting on network I/O, or throttled by another resource.</p><h3>Connection Pool Exhaustion</h3><p>Here’s another problem that can produce surprisingly high latency without obvious CPU pressure.</p><p>Suppose our application has a PostgreSQL connection pool of 20 connections.</p><p>Then 100 requests arrive concurrently.</p><p>The first 20 requests may acquire connections:</p><pre>Request 1   → DB connection<br>Request 2   → DB connection<br>Request 3   → DB connection<br>...<br>Request 20  → DB connection</pre><p>The remaining requests have to wait:</p><pre>Request 21  → waiting<br>Request 22  → waiting<br>Request 23  → waiting<br>...</pre><p>From the outside, the application may simply look slow.</p><p>You might see:</p><pre>CPU       → normal<br>Memory    → normal<br>Pod       → Running<br>PostgreSQL → healthy</pre><p>But the application is spending time waiting for a database connection.</p><p>This is an important distinction:</p><pre>Slow query</pre><p>and:</p><pre>Waiting for a connection before the query can even start</pre><p>are different problems.</p><p>The solution is therefore different too.</p><p>You need to investigate things such as:</p><ul><li>connection pool configuration</li><li>request concurrency</li><li>query duration</li><li>long-running transactions</li><li>database connection limits</li><li>application instance count</li></ul><p>Again, the goal isn’t to guess the configuration.</p><p>It’s to understand where the waiting is happening.</p><h3>External Dependencies Are Part of Your Latency Budget</h3><p>Microservices introduce another interesting problem.</p><p>Your service may be perfectly healthy while one of its dependencies is having a bad day.</p><p>Consider a checkout flow:</p><pre>Customer<br>   │<br>   ▼<br>Order Service<br>   │<br>   ▼<br>Payment Service<br>   │<br>   ▼<br>External Payment Provider</pre><p>Normally, the external provider might respond in:</p><pre>200ms</pre><p>But during an incident, it might take:</p><pre>6 seconds</pre><p>If your application waits synchronously for that response, your API inherits that latency.</p><p>Your Kubernetes metrics might still look perfectly normal:</p><pre>CPU       → 25%<br>Memory    → 45%<br>Pods      → Healthy</pre><p>The application isn’t doing anything wrong.</p><p>It’s waiting.</p><p>This is one reason production systems often need:</p><ul><li>timeouts</li><li>retries with care</li><li>circuit breakers</li><li>asynchronous processing</li><li>graceful degradation</li><li>dependency monitoring</li></ul><p>A five-second external API call should not necessarily be allowed to block your application indefinitely.</p><h3>Now Kubernetes Enters the Investigation</h3><p>So far, we’ve looked mostly at application and dependency problems.</p><p>But sometimes Kubernetes really is involved.</p><p>Consider a container with:</p><pre>resources:<br>  requests:<br>    cpu: &quot;100m&quot;<br>  limits:<br>    cpu: &quot;200m&quot;</pre><p>The CPU request tells Kubernetes roughly how much CPU capacity the workload needs for scheduling purposes.</p><p>The CPU limit places an upper bound on how much CPU the container can consume.</p><p>If the application regularly needs substantially more CPU than its configured limit allows, it can experience CPU throttling and increased latency.</p><p>But here’s the important part:</p><p><strong>Don’t see a CPU limit and immediately increase it.</strong></p><p>First investigate.</p><p>Ask:</p><pre>Is CPU actually saturated?<br>Is the container being throttled?<br>Is the workload CPU-bound?<br>Is the node under pressure?<br>Is the application doing unnecessary work?<br>Would increasing CPU simply move the bottleneck somewhere else?</pre><p>You want evidence before making the change.</p><h3>Why Adding More Pods Can Make Things Worse</h3><p>Scaling horizontally is powerful.</p><p>Suppose one API Pod can handle approximately 100 requests per second.</p><p>With three Pods:</p><pre>3 × 100<br>=<br>300 requests/second</pre><p>If traffic grows to 500 requests per second, increasing the number of Pods may be the correct solution.</p><p>But what if PostgreSQL is already the bottleneck?</p><p>You scale:</p><pre>3 Pods<br>   ↓<br>20 Pods</pre><p>Now you potentially have many more application instances competing for database resources.</p><p>The result could look like:</p><pre>More Pods<br>    ↓<br>More concurrent requests<br>    ↓<br>More DB connections<br>    ↓<br>Database saturation<br>    ↓<br>Longer query times<br>    ↓<br>Higher API latency</pre><p>You scaled the API and made the system slower.</p><p>This is why distributed systems need <strong>bottleneck-aware scaling</strong>.</p><p>Scaling one component doesn’t necessarily increase the capacity of the whole system.</p><h3>How Do We Actually Find the Bottleneck?</h3><p>This is where observability becomes extremely valuable.</p><p>Observability is often described using three major signals:</p><pre>Observability<br>                     │<br>          ┌──────────┼──────────┐<br>          │          │          │<br>          ▼          ▼          ▼<br>        Logs      Metrics     Traces</pre><p>They answer different questions.</p><h3>Logs</h3><p>Logs help answer:</p><blockquote><strong><em>What happened?</em></strong></blockquote><p>For example:</p><pre>GET /api/orders/12345<br>status=200<br>duration=8120ms</pre><p>That’s useful.</p><p>But it still doesn’t tell us exactly where the eight seconds went.</p><h3>Metrics</h3><p>Metrics help answer questions such as:</p><blockquote><em>How much?</em></blockquote><blockquote><em>How often?</em></blockquote><blockquote><em>Is it getting worse?</em></blockquote><p>We might see:</p><pre>request_count       = 10,000<br>p99_latency         = 7.8s<br>cpu_usage           = 35%<br>memory_usage        = 60%<br>db_connections      = 95%<br>error_rate          = 2%</pre><p>Now we can start looking for relationships.</p><p>For example:</p><pre>Traffic increases<br>       ↓<br>DB connections increase<br>       ↓<br>Latency increases</pre><p>That correlation gives us something to investigate.</p><h3>Traces</h3><p>Distributed traces answer one of the most important questions:</p><blockquote><strong><em>Where did this particular request spend its time?</em></strong></blockquote><p>For our order request, a trace might look like:</p><pre>GET /api/orders/12345<br>│<br>├── API Gateway       20ms<br>│<br>├── Order Service     30ms<br>│<br>├── Redis             10ms<br>│<br>├── Product Service  200ms<br>│<br>└── PostgreSQL      6,900ms</pre><p>Now the problem becomes much easier to reason about.</p><p>Instead of saying:</p><blockquote><em>“The API takes eight seconds.”</em></blockquote><p>we can say:</p><blockquote><em>“This request takes eight seconds, and approximately 6.9 seconds are spent waiting on PostgreSQL.”</em></blockquote><p>That’s a dramatically better debugging position.</p><h3>A Complete Production Investigation</h3><p>Let’s put the entire process together.</p><p>A customer reports:</p><blockquote><em>“The order API is sometimes extremely slow.”</em></blockquote><p>We begin by looking at latency.</p><pre>p50 = 120ms<br>p95 = 300ms<br>p99 = 7.8s</pre><p>The problem appears concentrated in the slowest requests.</p><p>We inspect traces from those requests.</p><p>We discover:</p><pre>Gateway             20ms<br>Order Service       30ms<br>Redis               10ms<br>Product Service    200ms<br>PostgreSQL       6,900ms</pre><p>Now we know where to investigate.</p><p>We inspect the database query with:</p><pre>EXPLAIN ANALYZE</pre><p>The database shows a sequential scan over a large table.</p><p>We investigate the query and discover that a frequently used filter doesn’t have an appropriate index.</p><p>We add the index.</p><p>Then we measure again.</p><p>Before:</p><pre>p99 = 7.8s</pre><p>After:</p><pre>p99 = 350ms</pre><p>The investigation is complete.</p><p>Notice how different this is from:</p><pre>API slow<br>   ↓<br>Increase CPU<br>   ↓<br>Restart Pods</pre><p>The second approach changes the system without understanding it.</p><p>The first approach builds a chain of evidence.</p><h3>A Practical Debugging Framework</h3><p>When you receive a vague report such as:</p><blockquote><em>“The API is slow.”</em></blockquote><p>start by making the statement more precise.</p><p>Ask:</p><h3>Is every request slow?</h3><p>If not, look for characteristics shared by the slow requests.</p><p>Maybe they’re:</p><ul><li>large orders</li><li>specific customers</li><li>particular endpoints</li><li>requests with many database records</li><li>requests involving an external dependency</li></ul><h3>What does the latency distribution look like?</h3><p>Check:</p><pre>p50<br>p95<br>p99</pre><p>A high p99 with a normal p50 tells you a very different story from a high p50.</p><h3>Where is the time being spent?</h3><p>Use application metrics and distributed tracing to break the request into components.</p><h3>Is the application computing or waiting?</h3><p>Look at:</p><pre>CPU<br>Database<br>Network<br>External APIs<br>Connection pools<br>Locks<br>I/O</pre><h3>Is Kubernetes actually involved?</h3><p>Only after you have evidence should you investigate things such as:</p><pre>CPU throttling<br>Memory pressure<br>OOMKilled<br>Node pressure<br>Scheduling<br>NetworkPolicy<br>Service routing<br>Ingress</pre><p>This ordering matters.</p><p>Kubernetes is part of the system, but it isn’t automatically the cause of every performance problem.</p><h3>The Difference Between a Workaround and a Root-Cause Fix</h3><p>Suppose your API is slow because a PostgreSQL query is inefficient.</p><p>You add more API replicas.</p><p>Latency improves from eight seconds to five seconds.</p><p>Did you fix the problem?</p><p>Not necessarily.</p><p>You may have changed the workload enough to temporarily improve the symptoms.</p><p>The database query is still inefficient.</p><p>A proper fix might involve:</p><pre>Query optimization<br>+<br>Appropriate indexing<br>+<br>Connection management<br>+<br>Caching where appropriate<br>+<br>Better application behavior</pre><p>And then you verify the result using measurements.</p><p>This distinction matters in production because a workaround can become permanent infrastructure.</p><p>Six months later, nobody remembers why the system has 20 replicas.</p><p>The original problem may still be sitting underneath it.</p><h3>Performance Debugging Is About Evidence</h3><p>The deeper lesson here isn’t about PostgreSQL.</p><p>It isn’t about Kubernetes.</p><p>It isn’t even about observability.</p><p>It’s about how you think when a production system behaves unexpectedly.</p><p>A useful investigation looks like this:</p><pre>Symptom<br>                       │<br>                       ▼<br>                  Measurement<br>                       │<br>                       ▼<br>                 Localization<br>                       │<br>                       ▼<br>                  Hypothesis<br>                       │<br>                       ▼<br>                    Evidence<br>                       │<br>                       ▼<br>                   Experiment<br>                       │<br>                       ▼<br>                  Root Cause<br>                       │<br>                       ▼<br>                     Fix<br>                       │<br>                       ▼<br>                 Verification</pre><p>Each step reduces uncertainty.</p><p>You don’t need to know the answer immediately.</p><p>You need to know <strong>what question to ask next</strong>.</p><p>That is one of the most valuable skills you can develop as a backend or platform engineer.</p><h3>The Next Time Someone Says “The API Is Slow”</h3><p>Don’t start by restarting the Pod.</p><p>Don’t immediately increase CPU.</p><p>Don’t blindly add replicas.</p><p>Start with:</p><blockquote><strong><em>“Which requests are slow?”</em></strong></blockquote><p>Then:</p><blockquote><strong><em>“How slow are they?”</em></strong></blockquote><p>Then:</p><blockquote><strong><em>“Where is the time being spent?”</em></strong></blockquote><p>Then:</p><blockquote><strong><em>“What evidence tells us why?”</em></strong></blockquote><p>And finally:</p><blockquote><strong><em>“How do we know our fix actually worked?”</em></strong></blockquote><p>The goal of performance engineering isn’t to make a system faster by changing random variables until the graphs look better.</p><p>It’s to understand the system well enough that you can explain <strong>why it was slow, what changed, and why the change fixed it</strong>.</p><p>That mindset becomes increasingly important as your architecture grows.</p><p>A monolith can hide many of these problems inside one process.</p><p>A microservice architecture spreads them across services.</p><p>Containers add another layer.</p><p>Kubernetes adds another.</p><p>Cloud infrastructure adds another.</p><p>And suddenly a request that looks like:</p><pre>GET /api/orders/12345</pre><p>is actually a journey through dozens of components.</p><p>When something goes wrong, the engineer who understands that journey has a significant advantage.</p><p>So the next time you see:</p><pre>🚨 API latency: 8 seconds</pre><p>don’t ask:</p><blockquote><em>“What should I restart?”</em></blockquote><p>Ask:</p><blockquote><strong><em>“Where did those eight seconds go?”</em></strong></blockquote><p>That’s where the real investigation begins.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e42cf2b00372" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agile Methodology Explained: How Software Teams Actually Work]]></title>
            <link>https://medium.com/@bunbunrong993/agile-methodology-explained-how-software-teams-actually-work-ede4c88bae65?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/ede4c88bae65</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[sdcl]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[scrum]]></category>
            <category><![CDATA[lifecycle]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Sun, 30 Aug 2026 07:11:17 GMT</pubDate>
            <atom:updated>2026-08-30T07:11:17.120Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*cgVbwlpSamVLP-lP.png" /></figure><h3>Introduction: The Six-Month Project That Failed</h3><p>Imagine you’re a software developer.</p><p>Your company wants to build a new e-commerce platform.</p><p>The business team has an idea.</p><p>They spend several weeks collecting requirements. Product managers write specifications. Designers create screens. Architects design the system. Developers estimate the work.</p><p>Eventually, the team has a detailed six-month plan.</p><p>Everyone feels confident.</p><p>Development begins.</p><p>For the next six months, developers build exactly what was requested.</p><p>Backend developers build APIs.</p><p>Frontend developers build screens.</p><p>Database engineers design tables.</p><p>QA prepares test cases.</p><p>The project appears to be progressing perfectly.</p><p>Then comes launch day.</p><p>The application goes live.</p><p>The customer opens it.</p><p>After using the system for a few minutes, they say:</p><blockquote><em>“This isn’t how we expected customers to use it.”</em></blockquote><p>The team is confused.</p><p>The requirements were followed.</p><p>The designs were implemented.</p><p>The tests passed.</p><p>The project was delivered according to plan.</p><p>So what went wrong?</p><p>The problem wasn’t necessarily the developers.</p><p>The problem was the <strong>assumption that the team could know everything six months before users actually used the software</strong>.</p><p>This is one of the fundamental problems Agile tries to address.</p><p>Software development contains uncertainty.</p><p>Requirements change.</p><p>Customers discover new needs.</p><p>Business priorities change.</p><p>Competitors release new products.</p><p>Technical limitations appear during implementation.</p><p>Sometimes a feature that looked extremely important turns out to be almost useless once users actually interact with it.</p><p>A traditional process can make these discoveries very expensive because feedback arrives late.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R1zvxha9MAblqLrD.png" /></figure><p>The team may spend months building something before discovering that the original assumption was wrong.</p><p>Agile approaches the problem differently.</p><p>Instead of assuming that the original plan is perfect, Agile creates <strong>short feedback loops</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W79K4kvAM55snefQ.png" /></figure><p>The goal isn’t to predict the future perfectly.</p><p>The goal is to <strong>learn quickly when reality differs from the plan</strong>.</p><p>That idea is the foundation of Agile software development.</p><h3>What Is Agile Methodology?</h3><p>Agile is often described as a software development methodology.</p><p>That description isn’t completely wrong, but it can create confusion.</p><p>Agile is better understood as a <strong>set of values and principles for developing products in environments where requirements and circumstances can change</strong>.</p><p>The Agile movement became formally associated with the <strong>Agile Manifesto</strong>, published in 2001 by a group of software practitioners who wanted to improve how software was developed.</p><p>The manifesto introduced four important values.</p><h3>1. Individuals and Interactions Over Processes and Tools</h3><p>Software teams use many tools:</p><ul><li>Jira</li><li>GitHub</li><li>GitLab</li><li>Slack</li><li>Microsoft Teams</li><li>CI/CD pipelines</li><li>Project management systems</li></ul><p>These tools are useful.</p><p>But tools don’t build software by themselves.</p><p>People do.</p><p>Imagine a team with excellent tools but terrible communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F7OvHIW4jWh_Qh89.png" /></figure><p>Now imagine a team with relatively simple tools but strong communication.</p><p>Agile doesn’t say:</p><blockquote><em>“Processes and tools are useless.”</em></blockquote><p>It says that <strong>people and communication are more important than blindly following a process</strong>.</p><p>For developers, this can mean discussing a requirement with a product manager before writing code instead of immediately implementing a ticket that isn’t clear.</p><h3>2. Working Software Over Comprehensive Documentation</h3><p>Documentation is important.</p><p>Good software teams need:</p><ul><li>Architecture documentation</li><li>API documentation</li><li>Database documentation</li><li>Deployment documentation</li><li>Technical decisions</li><li>Operational runbooks</li></ul><p>Agile doesn’t mean:</p><blockquote><em>“Don’t write documentation.”</em></blockquote><p>It means that documentation shouldn’t become a substitute for delivering working software.</p><p>Consider two situations.</p><h3>Situation A</h3><p>A team spends three months creating a detailed specification.</p><pre>300-page specification<br>        ↓<br>Architecture document<br>        ↓<br>Technical document<br>        ↓<br>Still no working product</pre><h3>Situation B</h3><p>The team creates a smaller requirement, implements it, and validates it with users.</p><p>The second approach gives the team something much more valuable:</p><p><strong>information from reality.</strong></p><p>A document describes what people <em>think</em> will happen.</p><p>Working software shows what <em>actually</em> happens.</p><h3>3. Customer Collaboration Over Contract Negotiation</h3><p>Imagine a customer gives a software team a requirement document.</p><p>The contract says the team will deliver exactly those requirements.</p><p>Six months later, the team delivers the application.</p><p>But during development, the customer’s understanding of the product has changed.</p><p>The business may have discovered new information.</p><p>Customers may have changed their behavior.</p><p>The market may have changed.</p><p>Agile encourages continuous collaboration rather than treating the initial requirements as permanently frozen.</p><p>The customer becomes part of the feedback loop.</p><p>This reduces the chance of discovering major misunderstandings at the end of the project.</p><h3>4. Responding to Change Over Following a Plan</h3><p>This is probably the most misunderstood Agile principle.</p><p>Some people interpret it as:</p><blockquote><em>“Agile teams don’t make plans.”</em></blockquote><p>That’s completely wrong.</p><p>Agile teams plan constantly.</p><p>They create:</p><ul><li>Product roadmaps</li><li>Backlogs</li><li>Sprint plans</li><li>Release plans</li><li>Technical designs</li><li>Estimates</li></ul><p>The difference is that Agile teams recognize that <strong>plans are based on current knowledge</strong>.</p><p>And current knowledge can change.</p><p>Think about using Google Maps while driving.</p><p>You have a destination.</p><p>You have a route.</p><p>But suddenly:</p><p>Do you continue driving toward the blocked road because:</p><blockquote><em>“That’s what the original plan said”?</em></blockquote><p>Of course not.</p><p>You choose another route.</p><p>Software development is similar.</p><p>Agile isn’t anti-planning.</p><p>Agile is <strong>anti-blindly-following-a-plan when reality has changed</strong>.</p><h3>Agile Does Not Mean “No Planning”</h3><p>This deserves its own section because it’s one of the most common misconceptions.</p><p>Imagine someone says:</p><blockquote><em>“We’re Agile, so we don’t need detailed requirements.”</em></blockquote><p>That’s not Agile.</p><p>Another person says:</p><blockquote><em>“We’re Agile, so developers can just build whatever they want.”</em></blockquote><p>That’s not Agile either.</p><p>Another says:</p><blockquote><em>“We’re Agile, so deadlines don’t matter.”</em></blockquote><p>Again, that’s not Agile.</p><p>Agile still requires discipline.</p><p>The difference is that planning happens continuously.</p><p>A useful mental model is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-7g8HzUTrCbVvWo3.png" /></figure><p>Instead of creating one giant plan and treating it as permanent, the team continuously updates its understanding.</p><h3>Why Traditional Software Development Can Become Expensive</h3><p>To understand Agile properly, we need to understand the problem it tries to solve.</p><p>Consider a simplified Waterfall process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4NdxOrLNDCSLXx2e.png" /></figure><p>There is nothing inherently wrong with sequential development.</p><p>For some types of projects, it can be appropriate.</p><p>The problem appears when requirements are uncertain but the process assumes they are stable.</p><p>Imagine a requirement changes during development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2B_OuwVBiA3GXZFB.png" /></figure><p>One requirement change can affect:</p><ul><li>Database design</li><li>API contracts</li><li>Frontend screens</li><li>Tests</li><li>Documentation</li><li>Deployment</li><li>Other dependent features</li></ul><p>The later the change happens, the more expensive it can become.</p><p>Agile tries to reduce this risk by shortening the distance between <strong>building something and receiving feedback about it</strong>.</p><h3>Agile Is Really About Feedback Loops</h3><p>This is perhaps the most useful way for a developer to understand Agile.</p><p>Suppose your product team believes users need a complicated reporting dashboard.</p><p>The assumption is:</p><blockquote><em>“Customers need 20 different reports.”</em></blockquote><p>The team could spend three months building all of them.</p><p>But there’s another approach.</p><p>Build a smaller version first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z1qsRWuydgeqQo5E.png" /></figure><p>Maybe users only need three reports.</p><p>The team just saved months of development.</p><p>This is why short feedback loops are powerful.</p><p>Agile doesn’t eliminate uncertainty.</p><p>It helps the team <strong>reduce uncertainty continuously</strong>.</p><h3>The Agile Build-Measure-Learn Cycle</h3><p>A software team can think of every feature as an experiment.</p><p>You start with an assumption.</p><p>You build something.</p><p>Users interact with it.</p><p>You measure the result.</p><p>Then you decide what to do next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BDhAZ6x6DNLtIoiS.png" /></figure><p>This is especially important for developers because it changes how we think about “finished.”</p><p>A feature isn’t necessarily successful because:</p><pre>Code compiled<br>+<br>Tests passed<br>+<br>PR merged</pre><p>A feature creates value when it solves the intended problem.</p><p>That’s a much higher standard.</p><h3>What Does an Agile Software Team Actually Look Like?</h3><p>Now let’s move from theory into a real software team.</p><p>Imagine you’re joining a team building an e-commerce platform.</p><p>The team might include:</p><ul><li>Product Owner</li><li>Product Manager</li><li>Developers</li><li>QA Engineers</li><li>UX/UI Designer</li><li>DevOps Engineer</li><li>Technical Lead</li></ul><p>The exact structure varies between organizations.</p><p>The important idea is that these people collaborate around a shared product goal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HYb1i0JGRFl7_2Vu.png" /></figure><p>The team isn’t simply completing isolated tasks.</p><p>They’re trying to create a product that provides value.</p><h3>Agile vs Scrum: They Are Not the Same Thing</h3><p>This distinction is extremely important.</p><p>You might hear someone say:</p><blockquote><em>“Our company uses Agile.”</em></blockquote><p>Then they describe:</p><ul><li>Two-week sprints</li><li>Daily standups</li><li>Sprint planning</li><li>Sprint reviews</li><li>Retrospectives</li></ul><p>They’re probably describing <strong>Scrum</strong>.</p><p>Agile and Scrum are not synonyms.</p><p>A useful way to think about the relationship is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qsxh-BvzyxEQgPd7.png" /></figure><p>Agile provides a set of values and principles.</p><p>Scrum provides a framework for organizing product development.</p><p>Kanban provides a flow-based approach to managing work.</p><p>Extreme Programming, often called XP, focuses heavily on engineering practices such as pair programming, test-driven development, continuous integration, and frequent releases.</p><p>This distinction matters because many companies accidentally turn Agile into a collection of ceremonies.</p><p>They have:</p><pre>- Daily Standup ✓<br>- Sprint Planning ✓<br>- Sprint Review ✓<br>- Retrospective ✓<br>- Jira Board ✓<br>- Story Points ✓</pre><p>But they still have:</p><pre>- Poor communication<br>- Late feedback<br>- Large batches of work<br>- Constant rework<br>- Unclear priorities</pre><p>They have adopted the <strong>mechanics</strong> of Agile without adopting the underlying mindset.</p><h3>The Sprint: Turning a Large Problem Into a Small Cycle</h3><p>Let’s look at Scrum more closely.</p><p>A Sprint is a fixed period during which a team works toward a specific goal and produces a usable increment of the product.</p><p>A common Sprint duration is two weeks.</p><p>Imagine your product backlog contains:</p><pre>- Authentication<br>- Payment<br>- Order Management<br>- Inventory<br>- Reports<br>- Notifications<br>- Customer Management</pre><p>Trying to build everything simultaneously would create enormous uncertainty.</p><p>Instead, the team selects a smaller set of work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d2yNPcmWNK_S8l-2.png" /></figure><p>The team isn’t trying to finish the entire product in two weeks.</p><p>They’re trying to create a <strong>valuable, usable increment</strong>.</p><h3>Why Short Iterations Matter</h3><p>Suppose a team works for six months before showing the customer anything.</p><p>If they misunderstand the requirements, the mistake could affect thousands of development hours.</p><p>Now imagine the team demonstrates working software every two weeks.</p><p>The customer says:</p><blockquote><em>“The workflow isn’t correct.”</em></blockquote><p>That’s not necessarily bad news.</p><p>It’s valuable information.</p><p>The team has discovered the problem after two weeks instead of six months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9Mm2fKUWC7iYRwPw.png" /></figure><p>Compare that with short iterations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IU00Fvn5wEW-KP1z.png" /></figure><p>This leads to one of the most powerful ideas in Agile:</p><blockquote><strong><em>Failing early is often cheaper than succeeding at the wrong thing.</em></strong></blockquote><h3>The Developer’s Role in an Agile Team</h3><p>Agile also changes how developers participate in product development.</p><p>A developer shouldn’t be treated as a machine that converts Jira tickets into code.</p><p>Consider this ticket:</p><blockquote><strong><em>“Add customer search.”</em></strong></blockquote><p>A purely implementation-focused developer might immediately start coding.</p><pre>Ticket<br>  ↓<br>API<br>  ↓<br>Database Query<br>  ↓<br>Frontend<br>  ↓<br>Pull Request</pre><p>An Agile-oriented developer might first ask:</p><ul><li>What problem are customers trying to solve?</li><li>Which fields should be searchable?</li><li>How many customers will exist?</li><li>Should partial matching be supported?</li><li>Should archived customers appear?</li><li>Do we need pagination?</li><li>How fast should the search respond?</li><li>Does search need typo tolerance?</li><li>What happens when two customers have the same name?</li></ul><p>These questions aren’t bureaucracy.</p><p>They’re engineering.</p><p>They reduce ambiguity before code is written.</p><p>A more collaborative workflow looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nh_ARalg-mCn4Lx6.png" /></figure><p>The developer becomes part of the problem-solving process.</p><p>That’s an important shift.</p><h3>Agile Doesn’t Mean Moving Faster</h3><p>Another common misunderstanding is:</p><blockquote><em>“Agile means developers need to work faster.”</em></blockquote><p>Not exactly.</p><p>Agile is less about typing code faster and more about <strong>reducing the time between action and learning</strong>.</p><p>Consider two teams.</p><h3>Team A</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EZ-DlBJIaWUARCE_.png" /></figure><p>Feedback arrives very late.</p><h3>Team B</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cgVbwlpSamVLP-lP.png" /></figure><p>Team B might actually write <strong>less code</strong>.</p><p>But the code they write is more likely to solve the correct problem.</p><p>That’s the real advantage.</p><h3>The Agile Mindset</h3><p>If you remember only one concept from this article, remember this:</p><blockquote><strong><em>Agile is not a process for predicting the future perfectly. It is a way of learning quickly when your prediction is wrong.</em></strong></blockquote><p>A requirement will change.</p><p>A customer will provide unexpected feedback.</p><p>A developer will discover that an architecture decision doesn’t scale.</p><p>A product manager will realize a feature isn’t as valuable as expected.</p><p>A production incident will expose an assumption nobody noticed.</p><p>An Agile team doesn’t simply treat these events as failures.</p><p>It uses them as information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mQg85a4UVJ8ri36x.png" /></figure><p>Once you understand this loop, many Agile concepts start making more sense.</p><p><strong>Product Backlog</strong> helps manage potential work.</p><p><strong>User Stories</strong> help describe user needs.</p><p><strong>Sprint Planning</strong> helps decide what to focus on next.</p><p><strong>Daily coordination</strong> helps the team identify problems early.</p><p><strong>Sprint Reviews</strong> create feedback from stakeholders.</p><p><strong>Retrospectives</strong> help the team improve how it works.</p><p><strong>Continuous Integration and Delivery</strong> shorten the feedback loop between code changes and working software.</p><p>These aren’t supposed to be random corporate rituals.</p><p>They’re mechanisms that support the feedback loop.</p><h3>What Comes Next?</h3><p>We’ve established the foundation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BJ1gO-kmkMQG_-kd.png" /></figure><p>But understanding Agile principles is only the beginning.</p><p>The more interesting question for a developer is:</p><blockquote><strong><em>What actually happens on Monday morning when an Agile team starts working?</em></strong></blockquote><p>How does a business requirement become a user story?</p><p>How does a user story become a ticket?</p><p>Who decides its priority?</p><p>How does Sprint Planning work?</p><p>What should a developer actually say during a Daily Scrum?</p><p>What happens when a story isn’t finished?</p><p>What happens during Code Review?</p><p>Where does QA fit?</p><p>How does a Pull Request become a production deployment?</p><p>And perhaps most importantly:</p><blockquote><strong><em>How does the team know whether it is actually delivering value?</em></strong></blockquote><p>In the next part, we’ll follow a <strong>real software feature from idea to production</strong> and walk through the complete Agile workflow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AZjJqgX7fgdPzERi.png" /></figure><p>That’s where Agile stops being a collection of definitions and starts looking like the <strong>real workflow developers experience every day</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ede4c88bae65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agile Methodology Explained: How Software Teams Actually Work]]></title>
            <link>https://medium.com/@bunbunrong993/agile-methodology-explained-how-software-teams-actually-work-633bd0b356d7?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/633bd0b356d7</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[agile-vs-scrum]]></category>
            <category><![CDATA[sdlc-methodologies]]></category>
            <category><![CDATA[agile-methodology]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Sat, 15 Aug 2026 07:06:46 GMT</pubDate>
            <atom:updated>2026-08-15T07:06:46.513Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Agile isn’t a meeting, a Jira board, or a two-week sprint. It’s a way of changing how a software team thinks, builds, learns, and responds when reality doesn’t match the original plan.</em></blockquote><h3>Introduction: The Six-Month Project That Failed</h3><p>Imagine you’re a software developer.</p><p>Your company has an idea for a new e-commerce platform.</p><p>The product manager spends several weeks collecting requirements.</p><p>The business team writes a specification.</p><p>The architects design the entire system.</p><p>The designers create every screen.</p><p>The developers receive a large document containing hundreds of requirements.</p><p>Then development begins.</p><p>For the next six months, the team works according to the original plan.</p><p>Developers build the database.</p><p>They implement the APIs.</p><p>Frontend developers build the interface.</p><p>QA prepares test cases.</p><p>Everyone is busy.</p><p>Everyone is working.</p><p>And everyone believes the project is moving forward.</p><p>Six months later, the team finally releases the first version.</p><p>The product manager opens the application.</p><p>The customer looks at it.</p><p>Then someone says:</p><blockquote><em>“This isn’t what we actually needed.”</em></blockquote><p>Suddenly, the team discovers something painful.</p><p>The problem wasn’t that the developers were bad.</p><p>The problem wasn’t that the team didn’t work hard.</p><p>The problem was that <strong>the team spent six months optimizing a plan based on assumptions that turned out to be wrong.</strong></p><p>This is one of the problems Agile software development tries to solve.</p><p>Agile doesn’t promise that your original plan will always be correct.</p><p>Instead, Agile accepts a reality that software engineers eventually learn:</p><blockquote><strong><em>You don’t know everything at the beginning of a software project.</em></strong></blockquote><p>Requirements change.</p><p>Customers change their minds.</p><p>Business priorities change.</p><p>Technology changes.</p><p>Competitors release new features.</p><p>Developers discover technical limitations.</p><p>And sometimes, after users actually interact with the product, everyone discovers that the original idea was simply wrong.</p><p>Agile is designed around this reality.</p><p>Instead of asking:</p><blockquote><em>“How can we follow the original plan perfectly?”</em></blockquote><p>Agile asks:</p><blockquote><strong><em>“How can we continuously learn and adapt while building the product?”</em></strong></blockquote><p>That difference sounds small.</p><p>It isn’t.</p><p>It changes how software teams plan, communicate, develop, test, release, and improve software.</p><h3>What Is Agile Methodology?</h3><p>Agile is often described as a software development methodology.</p><p>That description is useful, but incomplete.</p><p>Agile is better understood as a <strong>set of principles and values for managing software development in environments where requirements and circumstances change</strong>.</p><p>The Agile movement became formally associated with the <strong>Agile Manifesto</strong>, published in 2001 by a group of software practitioners who wanted to find better ways of developing software.</p><p>The manifesto contains four famous values.</p><h3>Individuals and interactions over processes and tools</h3><p>Processes and tools are useful.</p><p>But software is ultimately built by people.</p><p>A team with perfect tools but poor communication can still fail.</p><p>A team with simple tools but excellent communication can often accomplish remarkable things.</p><p>Agile therefore emphasizes collaboration between people.</p><h3>Working software over comprehensive documentation</h3><p>Documentation has value.</p><p>Architecture documents have value.</p><p>Technical specifications have value.</p><p>But documentation isn’t the final product.</p><p>Working software is.</p><p>A 200-page document describing a payment system is not the same as a payment system that successfully processes a transaction.</p><p>Agile encourages teams to prioritize usable software while still creating the documentation they genuinely need.</p><h3>Customer collaboration over contract negotiation</h3><p>Traditional projects often create a boundary between the development team and the customer.</p><p>The requirements are agreed upon.</p><p>The contract is signed.</p><p>The developers build.</p><p>The customer receives the result.</p><p>Agile encourages much more continuous collaboration.</p><p>The customer or product representative provides feedback throughout development.</p><p>This allows the team to discover mistakes earlier.</p><h3>Responding to change over following a plan</h3><p>This is perhaps the most important Agile idea.</p><p>Planning is important.</p><p>But plans are predictions about the future.</p><p>And predictions can be wrong.</p><p>Agile doesn’t say:</p><blockquote><em>“Don’t plan.”</em></blockquote><p>It says:</p><blockquote><strong><em>“Plan, learn, and adapt.”</em></strong></blockquote><h3>Agile Doesn’t Mean “No Planning”</h3><p>This is one of the biggest misunderstandings about Agile.</p><p>Some developers hear:</p><blockquote><em>“Agile responds to change.”</em></blockquote><p>And interpret it as:</p><blockquote><em>“We don’t need requirements.”</em></blockquote><p>That’s incorrect.</p><p>Agile teams still plan.</p><p>They still estimate.</p><p>They still define requirements.</p><p>They still create roadmaps.</p><p>They still track progress.</p><p>The difference is that they recognize the plan will probably change.</p><p>Think about planning a road trip.</p><p>You know:</p><ul><li>Where you’re starting.</li><li>Where you’re going.</li><li>Roughly how long it might take.</li><li>Which roads you expect to use.</li></ul><p>But if a road is closed, you don’t continue driving toward the blocked road because:</p><blockquote><em>“That was the original plan.”</em></blockquote><p>You find another route.</p><p>Software development works the same way.</p><pre>                PRODUCT GOAL<br>                      │<br>                      ▼<br>                   PLAN<br>                      │<br>                      ▼<br>                  BUILD<br>                      │<br>                      ▼<br>                  RELEASE<br>                      │<br>                      ▼<br>                  FEEDBACK<br>                      │<br>                      ▼<br>                   LEARN<br>                      │<br>                      ▼<br>                ADJUST PLAN<br>                      │<br>                      └───────────────┐<br>                                      │<br>                                      ▼<br>                                    BUILD</pre><p>This cycle is at the heart of Agile.</p><h3>Why Traditional Software Development Struggled</h3><p>To understand Agile, it’s useful to understand what came before it.</p><p>One traditional approach is commonly known as the <strong>Waterfall model</strong>.</p><p>The basic idea is sequential development.</p><pre>Requirements<br>     │<br>     ▼<br>Design<br>     │<br>     ▼<br>Development<br>     │<br>     ▼<br>Testing<br>     │<br>     ▼<br>Deployment</pre><p>The assumption is that each phase can be largely completed before moving to the next.</p><p>For certain types of projects, this can work well.</p><p>But software has a unique characteristic:</p><p><strong>Software requirements are difficult to know perfectly before the product exists.</strong></p><p>Imagine telling a customer:</p><blockquote><em>“Please describe exactly what your application should look like.”</em></blockquote><p>The customer may provide a specification.</p><p>But until they actually use the software, they may not realize what works and what doesn’t.</p><p>This creates a dangerous feedback loop.</p><pre>Assumption<br>    │<br>    ▼<br>Requirement<br>    │<br>    ▼<br>Development<br>    │<br>    ▼<br>Software<br>    │<br>    ▼<br>Customer sees it<br>    │<br>    ▼<br>&quot;That&#39;s not what I expected.&quot;</pre><p>The later you discover the mistake, the more expensive it becomes to fix.</p><p>Agile attempts to move feedback closer to development.</p><p>Instead of waiting six months:</p><pre>Build ───────────────────────────────► Feedback<br>             6 months</pre><p>The team creates shorter feedback cycles:</p><pre>Build → Feedback → Improve<br>  ↑                    │<br>  └────────────────────┘</pre><p>This doesn’t eliminate uncertainty.</p><p>It makes uncertainty <strong>manageable</strong>.</p><h3>Agile Is About Feedback Loops</h3><p>This is one of the most useful mental models for understanding Agile.</p><p>Think about a developer building a feature.</p><p>You have an assumption:</p><blockquote><em>“Users need a complicated reporting dashboard.”</em></blockquote><p>You could spend three months building it.</p><p>Or you could build a small version first.</p><pre>Assumption<br>    │<br>    ▼<br>Small Feature<br>    │<br>    ▼<br>Users<br>    │<br>    ▼<br>Feedback<br>    │<br>    ▼<br>New Understanding<br>    │<br>    ▼<br>Improved Feature</pre><p>Maybe users don’t need the complicated dashboard.</p><p>Maybe they only need three numbers:</p><pre>Orders<br>Revenue<br>Customers</pre><p>You just avoided three months of unnecessary development.</p><p>That’s the power of short feedback loops.</p><h3>What Does an Agile Team Actually Look Like?</h3><p>Now let’s move away from theory.</p><p>Imagine you’re joining an Agile software team.</p><p>You might find people with different responsibilities:</p><pre>                    Product Goal<br>                         │<br>                         ▼<br>                 Product Owner<br>                         │<br>                         ▼<br>                   Product Backlog<br>                         │<br>             ┌───────────┴───────────┐<br>             │                       │<br>             ▼                       ▼<br>        Development Team          Designer<br>             │<br>       ┌─────┼─────┐<br>       │     │     │<br>       ▼     ▼     ▼<br>    Backend Frontend QA</pre><p>The exact structure varies from company to company.</p><p>But the important idea is that Agile encourages <strong>cross-functional collaboration</strong>.</p><p>Instead of throwing requirements over a wall:</p><pre>Business<br>   │<br>   ▼<br>Product Manager<br>   │<br>   ▼<br>Designer<br>   │<br>   ▼<br>Developer<br>   │<br>   ▼<br>QA</pre><p>the team works together continuously.</p><pre>            Product Goal<br>                  │<br>        ┌─────────┼─────────┐<br>        ▼         ▼         ▼<br>     Product   Designer   Developers<br>       Owner                 │<br>        │                    ▼<br>        └──────────────►   QA<br>                              │<br>                              ▼<br>                           Users<br>                              │<br>                              ▼<br>                           Feedback</pre><p>The objective isn’t simply to complete assigned tasks.</p><p>The objective is to <strong>deliver useful product value</strong>.</p><h3>Agile vs Scrum: They Are Not the Same Thing</h3><p>This distinction is extremely important.</p><p>You will often hear developers say:</p><blockquote><em>“Our company uses Agile.”</em></blockquote><p>Then they explain:</p><blockquote><em>“We have two-week sprints, daily standups, and sprint planning.”</em></blockquote><p>What they’re actually describing is probably <strong>Scrum</strong>.</p><p>Agile is the broader philosophy.</p><p>Scrum is one framework for implementing Agile principles.</p><p>Think of it this way:</p><pre>                 AGILE<br>                   │<br>        ┌──────────┼──────────┐<br>        │          │          │<br>        ▼          ▼          ▼<br>      Scrum      Kanban      XP</pre><p>Agile tells you <strong>what values and principles matter</strong>.</p><p>Frameworks such as Scrum and Kanban provide different ways of organizing work around those principles.</p><p>This distinction becomes important because many organizations accidentally replace Agile thinking with Agile rituals.</p><p>They have:</p><ul><li>Daily standups</li><li>Sprint planning</li><li>Sprint reviews</li><li>Retrospectives</li><li>Story points</li><li>Jira boards</li></ul><p>But they still have the same problems they had before.</p><p>Why?</p><p>Because Agile isn’t the meetings.</p><p>Agile is the <strong>way the team responds to uncertainty and delivers value</strong>.</p><h3>The Sprint: Turning a Large Problem Into a Small Cycle</h3><p>One of the most recognizable Scrum concepts is the <strong>Sprint</strong>.</p><p>A Sprint is a fixed period during which a team works toward a specific goal and produces a usable increment of the product.</p><p>A common Sprint length is two weeks.</p><p>Imagine your product backlog contains:</p><pre>Authentication<br>Payment<br>Order Management<br>Inventory<br>Reports<br>Notifications<br>Customer Management</pre><p>Trying to build everything at once would create a huge amount of uncertainty.</p><p>Instead, the team selects a smaller amount of work.</p><pre>PRODUCT BACKLOG<br>Authentication<br>Payment<br>Order Management<br>Inventory<br>Reports<br>Notifications<br>Customer Management</pre><pre>                     │<br>                     ▼</pre><pre>                 SPRINT BACKLOG</pre><pre>Authentication<br>Login<br>Logout<br>Password Reset</pre><pre>                     │<br>                     ▼</pre><pre>                    SPRINT</pre><pre>              Week 1 → Week 2</pre><pre>                     │<br>                     ▼</pre><pre>              Working Software</pre><p>The team isn’t trying to finish the entire product.</p><p>They’re trying to create a <strong>valuable increment</strong>.</p><h3>Why Short Iterations Matter</h3><p>Suppose a team works for six months before showing the customer anything.</p><p>If they misunderstand the requirements, the mistake may affect hundreds of development hours.</p><p>Now imagine the team demonstrates something every two weeks.</p><p>The customer says:</p><blockquote><em>“The workflow isn’t correct.”</em></blockquote><p>That’s frustrating.</p><p>But it’s useful.</p><p>The team has discovered the problem after two weeks instead of six months.</p><p>This is one of Agile’s greatest strengths:</p><blockquote><strong><em>Failing early is often cheaper than succeeding at the wrong thing.</em></strong></blockquote><h3>The Developer’s Role in Agile</h3><p>Agile isn’t only a management framework.</p><p>It changes how developers approach their work.</p><p>A developer in an Agile environment isn’t simply someone who receives a ticket and writes code.</p><p>They are expected to participate in understanding the problem.</p><p>For example, imagine you receive this ticket:</p><blockquote><em>“Add customer search.”</em></blockquote><p>A traditional interpretation might be:</p><pre>Ticket<br>  │<br>  ▼<br>Write API<br>  │<br>  ▼<br>Write UI<br>  │<br>  ▼<br>Submit PR</pre><p>An Agile developer may ask:</p><ul><li>What problem are customers trying to solve?</li><li>What fields should be searchable?</li><li>How many customers might exist?</li><li>Does the search need partial matching?</li><li>Should it support pagination?</li><li>What happens with duplicate names?</li><li>How fast does the search need to be?</li><li>Should archived customers appear?</li></ul><p>Those questions can prevent expensive rework.</p><p>The developer becomes part of the problem-solving process rather than simply an implementation machine.</p><h3>Agile Is Not About Moving Faster</h3><p>This is another important misconception.</p><p>Agile does not necessarily mean:</p><blockquote><em>“Write code faster.”</em></blockquote><p>It means:</p><blockquote><strong><em>Reduce the amount of time between doing something and learning whether it was the right thing to do.</em></strong></blockquote><p>Consider these two teams.</p><h3>Team A</h3><pre>Plan<br>   ↓<br>Build<br>   ↓<br>Build<br>   ↓<br>Build<br>   ↓<br>Build<br>   ↓<br>Release<br>   ↓<br>Feedback</pre><p>Feedback arrives very late.</p><h3>Team B</h3><pre>Plan<br> ↓<br>Build<br> ↓<br>Feedback<br> ↓<br>Improve<br> ↓<br>Build<br> ↓<br>Feedback<br> ↓<br>Improve</pre><p>Team B may write less code.</p><p>But the code they write is more likely to solve the actual problem.</p><p>That’s a major difference.</p><h3>The Agile Mindset</h3><p>If you remember only one idea from this article, remember this:</p><blockquote><strong><em>Agile is not a process for predicting the future perfectly. It is a system for learning quickly when your prediction is wrong.</em></strong></blockquote><p>Requirements will change.</p><p>Production incidents will happen.</p><p>Customers will provide unexpected feedback.</p><p>A developer will discover that an architecture decision doesn’t scale.</p><p>A feature that looked important will turn out to be useless.</p><p>An Agile team doesn’t treat these events as failures of the process.</p><p>It uses them as information.</p><pre>ASSUMPTION<br>            │<br>            ▼<br>          BUILD<br>            │<br>            ▼<br>          RELEASE<br>            │<br>            ▼<br>         OBSERVE<br>            │<br>            ▼<br>          LEARN<br>            │<br>            ▼<br>         ADAPT<br>            │<br>            └───────────────► BUILD</pre><p>That’s the real Agile loop.</p><p>And once you understand this loop, concepts like <strong>Product Backlog, User Stories, Sprint Planning, Daily Standups, Sprint Reviews, Retrospectives, Story Points, Kanban, Scrum, and Continuous Delivery</strong> stop looking like random corporate rituals.</p><p>They become tools designed to support the feedback loop.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=633bd0b356d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Caching with Redis and Celery — Part 4]]></title>
            <link>https://medium.com/@bunbunrong993/system-caching-with-redis-and-celery-part-4-e30c7950054f?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/e30c7950054f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[celery-django]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[django-celery-beat]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 07:05:37 GMT</pubDate>
            <atom:updated>2026-08-08T07:15:38.382Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>We’ve now seen how Redis can remove expensive reads from the request path and how Celery can refresh cached data asynchronously. But a caching system isn’t production-ready just because it is fast. What happens when Redis runs out of memory? What happens when a Celery worker fails? How do you know whether your cache is actually helping? And what happens when cached data becomes inconsistent with your database?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*VYmXX7ZqOwUe_n2DL4x4BQ@2x.jpeg" /></figure><h3>A Fast Cache Can Still Be a Bad Cache</h3><p>Imagine your team deploys Redis and immediately sees impressive numbers.</p><p>Before Redis:</p><pre>Average API response: 850 ms<br>Database CPU:         82%<br>Requests/sec:         500</pre><p>After Redis:</p><pre>Average API response: 70 ms<br>Database CPU:         25%<br>Requests/sec:         500</pre><p>Everyone celebrates.</p><p>A few weeks later, however, Redis starts consuming all available memory.</p><p>Then Celery workers begin failing.</p><p>Some users see stale data.</p><p>Other requests suddenly become slow again.</p><p>The team discovers that the cache was never designed for production behavior.</p><p>This illustrates an important principle:</p><blockquote><strong><em>Caching is not simply a performance feature. It is a distributed system that needs its own reliability strategy.</em></strong></blockquote><p>You need to think about:</p><ul><li>Memory</li><li>Expiration</li><li>Eviction</li><li>Failures</li><li>Monitoring</li><li>Consistency</li><li>Worker reliability</li><li>Serialization</li><li>Cache hit rate</li></ul><p>Let’s examine each one.</p><h3>Redis Memory Is Not Infinite</h3><p>Redis stores data in memory.</p><p>That is the reason it’s fast.</p><p>But it is also one of its biggest constraints.</p><p>Imagine your server has:</p><pre>RAM = 16 GB</pre><p>Your application uses:</p><pre>Django          2 GB<br>PostgreSQL      4 GB<br>Operating System 2 GB<br>Celery          2 GB<br>Redis           6 GB</pre><p>You don’t have unlimited room.</p><p>If Redis continues accumulating cache entries, eventually it reaches its configured memory limit.</p><p>What happens next depends on your Redis eviction policy.</p><h3>Redis Eviction Policies</h3><p>Redis provides several strategies for deciding which keys should be removed when memory becomes full.</p><p>Common policies include:</p><ul><li>noeviction</li><li>allkeys-lru</li><li>allkeys-lfu</li><li>volatile-lru</li><li>volatile-lfu</li><li>volatile-ttl</li></ul><p>Understanding these policies is important because your choice affects application behavior.</p><h3>LRU — Least Recently Used</h3><p>LRU removes data that hasn’t been accessed recently.</p><p>Imagine your cache contains:</p><pre>Product A → accessed 2 seconds ago<br>Product B → accessed 10 seconds ago<br>Product C → accessed 3 hours ago<br>Product D → accessed 2 days ago</pre><p>If Redis needs space, Product D is a strong candidate for eviction.</p><p>The reasoning is simple:</p><blockquote><em>If nobody has requested it recently, it is probably less valuable.</em></blockquote><p>This is useful for workloads where recent access is a strong predictor of future access.</p><h3>LFU — Least Frequently Used</h3><p>LFU looks at how often data is accessed.</p><p>Suppose:</p><pre>Product A → 10,000 accesses<br>Product B → 2 accesses<br>Product C → 800 accesses<br>Product D → 1 access</pre><p>Product D is rarely used, so it becomes a good candidate for removal.</p><p>LFU can be particularly useful when a small number of objects are extremely popular.</p><p>For example:</p><pre>iPhone 17 Pro<br>MacBook Pro<br>AirPods Pro</pre><p>These products may receive thousands of requests while thousands of other products are barely accessed.</p><h3>TTL — Time To Live</h3><p>Another critical concept is <strong>TTL</strong>.</p><p>TTL defines how long a cache entry should remain valid.</p><p>For example:</p><pre>cache.set(<br>    &quot;products:featured&quot;,<br>    data,<br>    timeout=300,<br>)</pre><p>The value remains available for approximately five minutes.</p><p>After that, it expires.</p><p>TTL is important because not every piece of data should remain cached forever.</p><p>For example:</p><p>DataExample TTLProduct categories1 hourFeatured products5 minutesUser profile10 minutesExchange rates1 minuteDashboard statistics30 seconds</p><p>The correct TTL depends on how frequently the underlying data changes and how much stale data your application can tolerate.</p><h3>The Most Important Question: How Stale Can Your Data Be?</h3><p>There is no universal “correct” cache duration.</p><p>Instead, ask:</p><blockquote><strong><em>How much inconsistency can this business operation tolerate?</em></strong></blockquote><p>Consider two examples.</p><h3>Product Categories</h3><p>Suppose a new category appears five minutes late.</p><p>Probably acceptable.</p><pre>Database<br>   │<br>   ├── New category<br>   │<br>   └── Redis<br>       └── Old data for 5 minutes</pre><h3>Bank Account Balance</h3><p>A stale balance could be unacceptable.</p><pre>Database<br>   │<br>   └── $1,000<br><br>Redis<br>  │<br>  └── $2,000</pre><p>You should not casually cache sensitive transactional state without carefully designing its consistency model.</p><p>This leads to a critical engineering principle:</p><blockquote><strong><em>Cache data based on business tolerance, not simply technical convenience.</em></strong></blockquote><h3>Cache Hit Rate</h3><p>One of the most useful metrics in a caching system is the <strong>cache hit rate</strong>.</p><p>Suppose your API receives:</p><pre>100,000 requests</pre><p>Redis successfully serves:</p><pre>92,000 requests</pre><p>The remaining:</p><pre>8,000 requests</pre><p>go to PostgreSQL.</p><p>Your cache hit rate is:</p><pre>92,000 / 100,000 × 100 = 92%</pre><p>That’s generally a good sign.</p><p>The higher the hit rate, the more requests your cache is handling without involving the database.</p><p>A simplified flow is:</p><pre>100,000 Requests<br>                       │<br>             ┌─────────┴─────────┐<br>             │                   │<br>          92,000               8,000<br>          Cache Hit            Cache Miss<br>             │                   │<br>             ▼                   ▼<br>           Redis             PostgreSQL</pre><p>But don’t blindly chase a 100% hit rate.</p><p>A 100% hit rate may mean you’re caching everything, including data that shouldn’t be cached.</p><p>The goal is not:</p><blockquote><em>“Cache as much as possible.”</em></blockquote><p>The goal is:</p><blockquote><strong><em>“Cache the right things.”</em></strong></blockquote><h3>Cache Misses Are Not Always Bad</h3><p>A cache miss simply means the requested data wasn’t available in Redis.</p><p>For example:</p><pre>GET product:123<br>Redis<br>  │<br>  └── MISS<br>PostgreSQL<br>  │<br>  └── Product 123<br>Redis<br>  │<br>  └── Store product:123</pre><p>The next request becomes a cache hit.</p><p>This is normal.</p><p>The problem is a <strong>high and persistent cache miss rate</strong>.</p><p>For example:</p><pre>Cache Hit Rate<br>Week 1 → 92%<br>Week 2 → 91%<br>Week 3 → 63%</pre><p>Something changed.</p><p>Perhaps:</p><ul><li>TTLs became too short.</li><li>Keys are being invalidated too aggressively.</li><li>Cache memory is too small.</li><li>Cache keys are inconsistent.</li><li>The application generates unnecessary variants.</li></ul><p>Monitoring helps you find these problems.</p><h3>Monitoring Redis</h3><p>A production Redis deployment should be observable.</p><p>At minimum, monitor:</p><ul><li>Memory usage</li><li>Hit rate</li><li>Miss rate</li><li>Evictions</li><li>Connected clients</li><li>Commands per second</li><li>Latency</li><li>Key expiration</li><li>Network traffic</li></ul><p>A useful conceptual dashboard might look like:</p><pre>Redis Production Dashboard<br>Memory Usage        71%<br>Cache Hit Rate      94%<br>Cache Miss Rate      6%<br>Evictions           1,204/min<br>Commands            45,000/sec<br>Average Latency      0.8ms</pre><p>These numbers tell you much more than simply knowing that Redis is “running.”</p><h3>Monitoring Celery</h3><p>Redis can be healthy while Celery is failing.</p><p>Remember the architecture:</p><pre>Django<br>   │<br>   ▼<br>Redis Broker<br>   │<br>   ▼<br>Celery Worker<br>   │<br>   ▼<br>Refresh Cache</pre><p>If workers stop processing tasks, your cache may become stale even though Redis itself is perfectly healthy.</p><p>Therefore, monitor:</p><ul><li>Queue length</li><li>Task execution time</li><li>Failed tasks</li><li>Retry count</li><li>Worker availability</li><li>Task throughput</li><li>Task latency</li></ul><p>For example:</p><pre>Celery Queue<br><br>Pending Tasks:  18,500<br>Workers:        4<br>Active Tasks:   40<br>Failed Tasks:   230</pre><p>A rapidly growing queue is a warning sign.</p><p>It means tasks are arriving faster than workers can process them.</p><h3>What Happens When a Celery Worker Dies?</h3><p>Imagine Celery is refreshing your product cache.</p><pre>Celery Worker<br>      │<br>Refresh Products<br>      │<br>Query PostgreSQL<br>      │<br>Worker Crashes</pre><p>The task might not complete.</p><p>Now your Redis cache may remain stale.</p><p>This is why production Celery systems need proper retry strategies.</p><p>A simplified example:</p><pre>from celery import shared_task<br>@shared_task(<br>    autoretry_for=(Exception,),<br>    retry_backoff=True,<br>    max_retries=3,<br>)<br>def refresh_product_cache():<br>    ...</pre><p>The important idea isn’t the exact configuration.</p><p>The important idea is:</p><blockquote><strong><em>Background jobs should assume failure is possible.</em></strong></blockquote><p>Networks fail.</p><p>Databases restart.</p><p>Workers crash.</p><p>Redis becomes temporarily unavailable.</p><p>Production code must be designed around those realities.</p><h3>Don’t Put Critical Business Data Only in Redis</h3><p>This is one of the most important rules.</p><p>Suppose you have:</p><pre>PostgreSQL<br>   │<br>   └── Source of Truth</pre><p>and:</p><pre>Redis<br>   │<br>   └── Cached Copy</pre><p>If Redis disappears, PostgreSQL should still contain the data.</p><p>You should be able to rebuild the cache.</p><pre>Redis Lost<br>    │<br>    ▼<br>Query PostgreSQL<br>    │<br>    ▼<br>Rebuild Redis<br>    │<br>    ▼<br>Application Recovers</pre><p>This is called treating the cache as <strong>disposable state</strong>.</p><p>For most application caching scenarios, this is exactly what you want.</p><h3>A Dangerous Architecture</h3><p>Avoid designing your system like this:</p><pre>Application<br>      │<br>      ▼<br>Redis<br>      │<br>      └── Only Copy of Data</pre><p>If Redis fails, your business data disappears.</p><p>Instead:</p><pre>PostgreSQL<br>          Source of Truth<br>                │<br>                │<br>                ▼<br>              Redis<br>           Cached Copy</pre><p>The database owns the data.</p><p>Redis accelerates access to it.</p><h3>Cache Consistency Is a Business Decision</h3><p>Let’s return to our product example.</p><p>Suppose:</p><pre>PostgreSQL<br><br>Product Price = $899</pre><p>Redis contains:</p><pre>Product Price = $999</pre><p>There is technically an inconsistency.</p><p>But whether that inconsistency is acceptable depends on the business.</p><p>For a product listing page:</p><pre>$999 → $899</pre><p>A few seconds of delay may be acceptable.</p><p>For checkout:</p><pre>Customer pays $999</pre><p>while the actual price is:</p><pre>$899</pre><p>That’s a serious problem.</p><p>Therefore:</p><blockquote><strong><em>Never rely on a stale cache for critical transactional decisions.</em></strong></blockquote><p>Use the authoritative data source when correctness matters more than speed.</p><h3>Cache the Read Path, Protect the Write Path</h3><p>A useful architecture principle is:</p><pre>---------------<br>     READ<br>---------------<br><br>Client<br>  │<br>  ▼<br>Redis<br>  │<br>  ├── HIT ──► Response<br>  │<br>  └── MISS<br>        │<br>        ▼<br>    PostgreSQL<br>        │<br>        ▼<br>      Redis<br><br>----------------<br>     WRITE<br>----------------<br><br>Client<br>  │<br>  ▼<br>Django<br>  │<br>  ▼<br>PostgreSQL<br>  │<br>  ▼<br>Invalidate / Refresh Cache<br>  │<br>  ▼<br>Celery</pre><p>Reads are optimized aggressively.</p><p>Writes remain authoritative.</p><p>This separation makes the system easier to reason about.</p><h3>Avoid Caching Everything</h3><p>Caching has a cost.</p><p>Every cached object consumes memory.</p><p>Every invalidation creates complexity.</p><p>Every cached response introduces consistency concerns.</p><p>Therefore, don’t cache data simply because Redis is available.</p><p>Good candidates usually have one or more of these characteristics:</p><ul><li>Read frequently.</li><li>Change infrequently.</li><li>Require expensive database queries.</li><li>Are expensive to calculate.</li><li>Can tolerate short periods of staleness.</li></ul><p>Examples:</p><pre>Product Categories<br>Dashboard Statistics<br>Popular Products<br>Configuration<br>Public Content<br>Search Results</pre><p>Poor candidates often include:</p><pre>Highly transactional balances<br>One-time operations<br>Frequently changing records<br>Security-sensitive state<br>Data requiring strict consistency</pre><h3>Putting Everything Together</h3><p>We can now construct a complete architecture.</p><pre>                        CLIENT<br>                           │<br>                           ▼<br>                     Load Balancer<br>                           │<br>                           ▼<br>                     Django API<br>                           │<br>              ┌────────────┴────────────┐<br>              │                         │<br>              ▼                         ▼<br>         Redis Cache                PostgreSQL<br>              │                         │<br>              │                         │<br>              └────────────┬────────────┘<br>                           │<br>                           ▼<br>                     Celery Broker<br>                         Redis<br>                           │<br>                           ▼<br>                    Celery Workers<br>                           │<br>            ┌──────────────┼──────────────┐<br>            ▼              ▼              ▼<br>      Cache Refresh   Scheduled Jobs   Async Tasks<br>            │<br>            ▼<br>       Redis Cache</pre><p>Now consider a typical product request.</p><pre>GET /api/products/123</pre><p>The sequence becomes:</p><pre>Client<br>  │<br>  │ GET /products/123<br>  ▼<br>Django<br>  │<br>  │ GET product:123<br>  ▼<br>Redis<br>  │<br>  ├── HIT ───────────────► Django ─────► Client<br>  │<br>  └── MISS<br>       │<br>       ▼<br>   PostgreSQL<br>       │<br>       ▼<br>   Django<br>       │<br>       ├── Store result in Redis<br>       │<br>       ▼<br>     Client</pre><p>Now consider a product update.</p><pre>Admin<br>  │<br>  │ Update Product<br>  ▼<br>Django<br>  │<br>  ▼<br>PostgreSQL<br>  │<br>  ▼<br>Queue Celery Task<br>  │<br>  ▼<br>Redis Broker<br>  │<br>  ▼<br>Celery Worker<br>  │<br>  ├── Query latest data<br>  │<br>  ├── Serialize<br>  │<br>  └── Update Redis</pre><p>This gives us a powerful division of responsibilities:</p><p><strong>PostgreSQL</strong></p><blockquote><em>Owns the data.</em></blockquote><p><strong>Redis</strong></p><blockquote><em>Makes frequently accessed data fast.</em></blockquote><p><strong>Celery</strong></p><blockquote><em>Performs expensive work outside the request lifecycle.</em></blockquote><p><strong>Django</strong></p><blockquote><em>Coordinates the business operation.</em></blockquote><p>This separation is the foundation of a maintainable caching architecture.</p><h3>The Most Important Lessons</h3><p>After working through the architecture, several principles should stand out.</p><h3>1. Redis is not your database</h3><p>Use Redis to accelerate access to data owned elsewhere.</p><h3>2. Caching introduces consistency problems</h3><p>Every cached value is potentially an older version of the source data.</p><h3>3. TTL is a business decision</h3><p>Don’t choose expiration times randomly.</p><p>Ask how much stale data your application can tolerate.</p><h3>4. Celery moves expensive work away from users</h3><p>Don’t make users wait for work that can safely happen asynchronously.</p><h3>5. Cache invalidation requires a strategy</h3><p>Deleting a key is easy.</p><p>Keeping thousands or millions of cached objects correct is much harder.</p><h3>6. Monitor the cache</h3><p>A cache that is fast but constantly evicting data may not actually be helping.</p><h3>7. Design for failure</h3><p>Redis can disappear.</p><p>Workers can crash.</p><p>Tasks can fail.</p><p>Your application should still be able to recover from the source of truth.</p><h3>Final Perspective</h3><p>At the beginning of this article, we started with a simple problem:</p><blockquote><strong><em>Why is my API slow when the same data is requested repeatedly?</em></strong></blockquote><p>The obvious answer might be:</p><blockquote><em>“Use Redis.”</em></blockquote><p>But that’s only the beginning.</p><p>A production caching system requires much more thought.</p><p>You need to decide:</p><ul><li>What should be cached?</li><li>How long should it live?</li><li>When should it be invalidated?</li><li>Who should refresh it?</li><li>What happens when Redis fails?</li><li>What happens when Celery fails?</li><li>How do you prevent cache stampedes?</li><li>How do you monitor cache effectiveness?</li><li>Which data can tolerate inconsistency?</li></ul><p>Once you understand these questions, Redis stops being just another technology in your stack.</p><p>You begin to understand <strong>why caching is an architectural decision</strong>.</p><p>A well-designed system doesn’t put Redis between your application and database simply because Redis is fast.</p><p>It uses Redis because certain workloads benefit from avoiding expensive work repeatedly.</p><p>And it uses Celery because not every operation needs to happen while a user is waiting for an HTTP response.</p><p>The resulting architecture is simple in principle:</p><pre>              DATABASE<br>           Source of Truth<br>                 │<br>                 ▼<br>              REDIS<br>          Fast Cached Data<br>                 │<br>                 ▲<br>                 │<br>              CELERY<br>        Background Processing<br>                 │<br>                 ▲<br>                 │<br>              DJANGO<br>          Business Logic<br>                 │<br>                 ▲<br>                 │<br>              CLIENT</pre><p>The goal isn’t to eliminate database queries.</p><p>The goal isn’t to cache everything.</p><p>The goal is to make the system <strong>do less unnecessary work while preserving correctness</strong>.</p><p>That’s the real value of Redis caching with Celery.</p><h3>Practical Checklist</h3><p>Before deploying Redis + Celery caching to production, ask yourself:</p><h3>Cache Design</h3><ul><li>Do I know which data actually needs caching?</li><li>Does every cache key have a clear naming convention?</li><li>Does every cache entry have an appropriate TTL?</li><li>Can stale data cause a business problem?</li></ul><h3>Invalidation</h3><ul><li>When is the cache invalidated?</li><li>Is the cache rebuilt automatically?</li><li>Can multiple requests trigger the same expensive rebuild?</li><li>Do I need a distributed lock?</li></ul><h3>Redis</h3><ul><li>Is Redis memory usage monitored?</li><li>Is an appropriate eviction policy configured?</li><li>Are cache hit and miss rates tracked?</li><li>Can the application recover if Redis becomes unavailable?</li></ul><h3>Celery</h3><ul><li>Are failed tasks retried?</li><li>Are workers monitored?</li><li>Is the queue length monitored?</li><li>Are long-running tasks separated from short tasks?</li><li>Are scheduled jobs handled by Celery Beat where appropriate?</li></ul><h3>Data Integrity</h3><ul><li>Is PostgreSQL still the source of truth?</li><li>Are critical transactions reading authoritative data?</li><li>Can the entire cache be rebuilt?</li><li>Do you have a strategy for stale data?</li></ul><p>If you can answer these questions confidently, you’re no longer simply “using Redis.”</p><p>You’re designing a caching system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e30c7950054f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Caching with Redis and Celery (Part 3)]]></title>
            <link>https://medium.com/@bunbunrong993/system-caching-with-redis-and-celery-part-3-f95b17624173?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/f95b17624173</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[celery-django]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[celery-and-redis]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 06:16:19 GMT</pubDate>
            <atom:updated>2026-08-08T07:13:12.158Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In the previous sections, we learned why caching exists, how Redis dramatically reduces database load, and how Celery keeps cached data synchronized without slowing down user requests. Now it’s time to explore how experienced backend engineers design caching systems that remain fast, scalable, and reliable in production.</blockquote><h3>From a Small Application to a Production System</h3><p>Let’s imagine your e-commerce application has grown significantly.Instead of serving a few hundred users each day, it now handles:</p><ul><li>50,000 daily active users</li><li>3 million API requests per day</li><li>120,000 products</li><li>Multiple warehouses</li><li>Mobile applications</li><li>Web applications</li><li>Third-party integrations</li></ul><p>Your architecture now looks like this:</p><pre>                    Internet<br>                        │<br>                        ▼<br>                 Load Balancer<br>                        │<br>        ┌───────────────┴───────────────┐<br>        ▼                               ▼<br>   Django API #1                  Django API #2<br>        │                               │<br>        └───────────────┬───────────────┘<br>                        │<br>          ┌─────────────┴─────────────┐<br>          ▼                           ▼<br>      Redis Cache                Redis Broker<br>          │                           │<br>          ▼                           ▼<br>    PostgreSQL                  Celery Workers<br>                                    │<br>                    ┌───────────────┼───────────────┐<br>                    ▼               ▼               ▼<br>             Cache Refresh     Email Jobs     Report Jobs</pre><p>Notice something different.</p><p>Redis is no longer just “a cache.”</p><p>It has become a central component of the architecture.</p><p>Different services communicate through Redis, while Celery workers continuously process background tasks.</p><h3>Understanding Cache Patterns</h3><p>One mistake many developers make is assuming there’s only one way to cache data.</p><p>In reality, several caching strategies exist, each solving a different problem.</p><p>Understanding these patterns is more important than memorizing Redis commands because architecture decisions have a greater impact on performance than individual lines of code.</p><h3>Pattern 1 — Cache-Aside (Lazy Loading)</h3><p>This is the most common caching strategy.</p><p>It works like this:</p><ol><li>Client requests data.</li><li>Application checks Redis.</li><li>If data exists, return it.</li><li>Otherwise, query PostgreSQL.</li><li>Store the result in Redis.</li><li>Return the response.</li></ol><pre>Client<br>   │<br>   ▼</pre><pre>Redis</pre><pre>   │</pre><pre>Cache Hit?</pre><pre> ┌──────┴──────┐<br> │             │<br>Yes           No<br> │             │<br> ▼             ▼</pre><pre>Return     PostgreSQL<br>               │<br>               ▼<br>        Save to Redis<br>               │<br>               ▼<br>        Return Response</pre><h3>Advantages</h3><ul><li>Easy to implement.</li><li>Reduces unnecessary database queries.</li><li>Works well for most REST APIs.</li></ul><h3>Disadvantages</h3><ul><li>First request is always slower.</li><li>Cache can become stale.</li><li>Cache stampedes are possible.</li></ul><h3>Pattern 2 — Write-Through Cache</h3><p>Instead of waiting for the next request to rebuild the cache, the application updates Redis immediately after updating PostgreSQL.</p><pre>Update Product <br>     │<br>     ▼</pre><pre>Update PostgreSQL</pre><pre>      │<br>      ▼</pre><pre>Update Redis</pre><pre>      │</pre><pre>      ▼</pre><pre>Return Success</pre><p>Advantages:</p><ul><li>Cache is always fresh.</li><li>Users never see outdated information.</li></ul><p>Disadvantages:</p><ul><li>Every write becomes slightly slower.</li><li>Extra Redis operations during updates.</li></ul><h3>Pattern 3 — Write-Behind (Write-Back)</h3><p>This strategy is almost the opposite.</p><p>The application writes to Redis first.</p><p>Later, Celery synchronizes Redis back to PostgreSQL.</p><pre>   Apliction</pre><pre>      │</pre><pre>   Write Redis</pre><pre>      │</pre><pre>   Return Success</pre><pre>      │<br>      ▼</pre><pre>   Celery</pre><pre>      │</pre><pre>Persist to PostgreSQL</pre><p>This approach is extremely fast.</p><p>However, it introduces risk.</p><p>If Redis crashes before Celery persists the data, information may be lost.</p><p>Because of this, Write-Behind is usually reserved for specialized workloads such as analytics, logging, or temporary metrics rather than financial transactions.</p><h3>Which Pattern Should You Choose?</h3><p>There isn’t a universal answer.</p><p>Each pattern exists because it solves a different problem.</p><p>PatternBest ForComplexityCache-AsideREST APIsLowWrite-ThroughFrequently Updated DataMediumWrite-BehindHigh-Speed Data CollectionHigh</p><p>For most Django applications, <strong>Cache-Aside combined with Celery cache warming</strong> provides an excellent balance between simplicity and performance.</p><h3>Preventing Cache Stampede</h3><p>Earlier, we saw how deleting a cache can cause thousands of requests to hit the database simultaneously.</p><p>Let’s visualize it.</p><pre>     Cache Expired<br>       │<br>       ▼</pre><pre>   10,000 Users</pre><pre>       │<br>       ▼</pre><pre>10,000 Database Queries</pre><pre>       │<br>       ▼</pre><pre>Database Overloaded</pre><p>This problem is known as a <strong>Cache Stampede</strong>.</p><p>The more successful your application becomes, the more likely you’ll encounter it.</p><h3>Solution 1 — Background Cache Warming</h3><p>Instead of waiting for the first user to rebuild the cache, let Celery do it proactively.</p><pre>Celery Beat<br>      <br>      │</pre><pre>Every Hour</pre><pre>      │</pre><pre>Refresh Cache</pre><pre>      │</pre><pre>Update Redis</pre><pre>      │</pre><pre>Users Receive Fresh Data</pre><p>The users never experience a cache miss because the cache is refreshed before it expires.</p><h3>Solution 2 — Distributed Locking</h3><p>Suppose the cache expires.</p><p>The first request should rebuild it.</p><p>But the remaining 9,999 requests should wait.</p><p>Redis provides distributed locks to solve this.</p><pre>  Request 1<br>      <br>      │</pre><pre>Acquire Lock</pre><pre>      │</pre><pre>Rebuild Cache</pre><pre>      │</pre><pre>Release Lock</pre><pre>──────────────</pre><pre>Request 2</pre><pre>Wait</pre><pre>──────────────</pre><pre>Request 3</pre><pre>Wait</pre><pre>──────────────</pre><pre>Request 4</pre><pre>Read New Cache</pre><p>Only one request performs the expensive work.</p><p>Everyone else benefits.</p><h3>Solution 3 — Random Expiration</h3><p>Imagine every cache key expires exactly at midnight.</p><pre>Products<br>12:00 AM</pre><pre>Categories<br>12:00 AM</pre><pre>Homepage<br>12:00 AM</pre><pre>Inventory<br>12:00 AM</pre><p>At midnight…</p><p>Everything disappears.</p><p>The database suddenly receives thousands of cache misses.</p><p>A better strategy is adding random expiration times.</p><pre><br>import random<br>timeout = 3600 + random.randint(0, 300)</pre><pre>cache.set(key, data, timeout=timeout)</pre><p>Now different cache keys expire at slightly different times.</p><p>The database load becomes much smoother.</p><h3>Designing Better Cache Keys</h3><p>Another common mistake is using poor cache names.</p><p>Bad example:</p><pre>products</pre><p>Good examples:</p><pre>products:featured<br>products:latest<br>product:1052<br>category:electronics<br>dashboard:homepage<br>inventory:warehouse:2</pre><p>Good cache keys are:</p><ul><li>Descriptive</li><li>Predictable</li><li>Hierarchical</li><li>Easy to invalidate</li></ul><p>A well-designed naming convention makes debugging and maintenance much easier.</p><h3>Versioning Cache Keys</h3><p>Imagine you change your API response.</p><p>Old cache:</p><pre>{<br>    &quot;name&quot;: &quot;MacBook&quot;<br>}</pre><p>New response:</p><pre>{<br>    &quot;name&quot;: &quot;MacBook&quot;,<br>    &quot;brand&quot;: &quot;Apple&quot;<br>}</pre><p>If Redis still stores the old object, clients may receive outdated data structures.</p><p>A simple solution is versioning.</p><pre>v1:products:featured</pre><pre>v2:products:featured</pre><p>Instead of deleting millions of cache entries, simply switch to the new version.</p><p>Old entries naturally expire.</p><h3>Celery Beat — Automating Cache Refresh</h3><p>So far, we’ve rebuilt caches after updates.</p><p>But what about data that changes on a schedule?</p><p>For example:</p><ul><li>Daily sales reports</li><li>Dashboard statistics</li><li>Trending products</li><li>Currency exchange rates</li></ul><p>Instead of waiting for users to trigger updates, Celery Beat schedules periodic tasks.</p><pre>Every 5 Minutes      </pre><pre>      │</pre><pre>Celery Beat</pre><pre>      │</pre><pre>Refresh Dashboard Cache</pre><pre>      │</pre><pre>Store in Redis</pre><pre>      ▼</pre><pre>Users Receive Fresh Statistics</pre><p>This approach is often called <strong>cache warming</strong>, and it’s commonly used for dashboards where users expect data to load instantly.</p><h3>Separating Business Logic from Cache Logic</h3><p>One principle experienced engineers follow is keeping caching separate from business rules.</p><p>Instead of embedding Redis calls throughout your views, create a dedicated cache service.</p><pre>  class ProductCachService:<br>    @staticmethod<br>    def get_featured_products():<br>        ...</pre><pre>    @staticmethod<br>    def refresh_featured_products():<br>        ...</pre><p>Now:</p><ul><li>Views remain clean.</li><li>Celery reuses the same methods.</li><li>Unit testing becomes easier.</li><li>Cache behavior stays consistent.</li></ul><p>This follows the <strong>Single Responsibility Principle</strong> and keeps your application maintainable as it grows.</p><h3>A Production Mindset</h3><p>Caching isn’t about making one API endpoint faster.</p><p>It’s about designing a system that remains responsive as traffic grows from hundreds to millions of requests.</p><p>Redis reduces unnecessary work.</p><p>Celery automates expensive background operations.</p><p>Together, they allow your application to spend more time serving users and less time repeating identical computations.</p><p>As you build larger systems, you’ll discover that successful architectures aren’t those with the fastest databases — they’re the ones that avoid unnecessary database work in the first place.</p><p>In the final part of this guide, we’ll explore monitoring, cache observability, Redis memory management, eviction policies, common production mistakes, performance metrics, and best practices used by large-scale engineering teams to keep caching reliable under heavy load.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*VYmXX7ZqOwUe_n2DL4x4BQ@2x.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f95b17624173" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Caching with Redis and Celery (Part 2)]]></title>
            <link>https://medium.com/@bunbunrong993/system-caching-with-redis-and-celery-part-2-ec2372f57666?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec2372f57666</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[celery]]></category>
            <category><![CDATA[django-api]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 09:56:01 GMT</pubDate>
            <atom:updated>2026-08-08T06:27:17.951Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In Part 1, we learned why caching exists, how Redis improves application performance, and why the Cache-Aside pattern is the foundation of most modern backend systems. However, caching introduces a new challenge: keeping cached data synchronized with the database. In this part, we’ll explore why Redis alone isn’t enough and how Celery solves one of the biggest problems in production systems.</blockquote><h3>The Hardest Part of Caching Isn’t Speed</h3><p>When developers first learn Redis, they’re often amazed by the performance improvements.</p><p>Imagine your homepage originally takes <strong>850 milliseconds</strong> to load because it queries multiple database tables.</p><p>After adding Redis, the response time drops to <strong>25 milliseconds</strong>.</p><p>Everything looks perfect.</p><p>Until someone updates the data.</p><p>Let’s revisit our e-commerce application.</p><p>The homepage displays:</p><ul><li>Featured products</li><li>Categories</li><li>Best-selling products</li><li>Flash sale items</li><li>Recommended products</li></ul><p>These results are stored in Redis.</p><p>Now suppose an administrator updates the price of an iPhone.</p><pre># Old Price<br>iPhone 17 Pro<br>$999</pre><p>After the update:</p><pre># New Price<br>iPhone 17 Pro<br>$899</pre><p>The database is updated immediately.</p><p>But Redis still contains:</p><pre>iPhone 17 Pro<br>$999</pre><p>Now two versions of the truth exist.</p><pre>       iPhone = $899 [PostgeSQL]</pre><pre>              ▲</pre><pre>              │</pre><pre>              │</pre><pre>Application</pre><pre>              │</pre><pre>              ▼</pre><pre>        iPhone = $999 [Redis]</pre><p>Which one will your users see?</p><p>Unfortunately…</p><p>The old one.</p><p>Your application continues serving stale data until the cache expires.</p><p>This is called <strong>stale cache</strong>, and it’s one of the most common bugs in systems that use Redis.</p><h3>Why Not Just Delete the Cache?</h3><p>Many beginners think the solution is simple.</p><p>Whenever the database changes:</p><ol><li>Update PostgreSQL</li><li>Delete Redis</li><li>Done</li></ol><p>For a small application, this works well.</p><pre> [User Update Product]</pre><pre>        │</pre><pre>        ▼</pre><pre>[Update PostgreSQL]</pre><pre>        │</pre><pre>        ▼</pre><pre>[Delete Redis Cache]</pre><pre>        │</pre><pre>        ▼</pre><pre>Next Request Rebuilds Cache</pre><p>This strategy is called <strong>Cache Invalidation</strong>.</p><p>It is simple.</p><p>It is effective.</p><p>But only for small systems.</p><h3>The Hidden Problem</h3><p>Imagine your application has one million users.</p><p>The cache stores:</p><ul><li>Homepage</li><li>Categories</li><li>Products</li><li>Inventory</li><li>Promotions</li><li>Search results</li></ul><p>Every minute, hundreds of products change.</p><p>If every update immediately deletes multiple cache keys, Redis becomes busy rebuilding them.</p><p>This creates a phenomenon called a <strong>Cache Stampede</strong>.</p><p>Imagine this sequence.</p><pre>Cache Exists</pre><pre>        │</pre><pre>Admin Updates Product</pre><pre>        │</pre><pre>Delete Cache</pre><pre>        │</pre><pre>10,000 Users Visit Homepage</pre><pre>        │</pre><pre>All Requests Miss Cache</pre><pre>        │</pre><pre>10,000 Database Queries</pre><pre>        │</pre><pre>Database CPU = 100%</pre><p>Instead of one database query rebuilding the cache…</p><p>Thousands of users simultaneously rebuild the same cache.</p><p>The database experiences a sudden spike in traffic.</p><p>Ironically, caching can overload the database if implemented incorrectly.</p><h3>Introducing Celery</h3><p>So far, our application performs everything synchronously.</p><p>A request arrives.</p><p>The application queries PostgreSQL.</p><p>The application updates Redis.</p><p>The application returns a response.</p><p>Everything happens in one request.</p><pre>Client<br> │</pre><pre> ▼</pre><pre>Django</pre><pre> │</pre><pre> ├── PostgreSQL</pre><pre> ├── Redis</pre><pre> └── Response</pre><p>But not every task needs to happen immediately.</p><p>Some tasks can happen later.</p><p>Examples include:</p><ul><li>Sending emails</li><li>Resizing images</li><li>Generating reports</li><li>Creating PDFs</li><li>Processing payments</li><li>Exporting Excel files</li><li>Refreshing Redis caches</li></ul><p>This is where <strong>Celery</strong> becomes valuable.</p><p>Celery is a distributed task queue.</p><p>Instead of making the user wait while extra work completes, Celery moves long-running tasks into the background.</p><p>Think of it like ordering coffee.</p><p>Without Celery:</p><pre>   Customer</pre><pre>      │</pre><pre>      ▼</pre><pre>Barista</pre><pre>      │</pre><pre>Makes Coffee</pre><pre>      │</pre><pre>Packages Beans</pre><pre>      │</pre><pre>Cleans Machine</pre><pre>      │</pre><pre>Prints Receipt</pre><pre>      │</pre><pre>Customer Waits</pre><p>The customer waits until every task is finished.</p><p>With Celery:</p><pre>   Customer<br>      │</pre><pre>      ▼</pre><pre>   Barista</pre><pre>      │</pre><pre>Makes Coffee</pre><pre>      │</pre><pre>Serve Customer</pre><pre>      ▼</pre><pre>Background Staff</pre><pre>Packages Beans</pre><pre>Clean Machine</pre><pre>Update Inventory</pre><p>The customer receives the coffee immediately.</p><p>Everything else happens behind the scenes.</p><p>That is exactly what Celery does for web applications.</p><h3>How Redis and Celery Work Together</h3><p>One of the most common misconceptions is that Redis and Celery are competitors.</p><p>They’re not.</p><p>They solve different problems.</p><p>Redis stores data.</p><p>Celery executes background jobs.</p><p>Interestingly, Redis can also act as the <strong>message broker</strong> that Celery uses to communicate.</p><p>A typical production architecture looks like this:</p><pre>Client<br>   │<br>   ▼<br>Django REST API<br>   │<br>   ├──────────────► PostgreSQL<br>   │<br>   ├──────────────► Redis Cache<br>   │<br>   │<br>   └──── Publish Task ─────────────┐<br>                                   │<br>                                   ▼<br>                           Redis Broker<br>                                   │<br>                                   ▼<br>                            Celery Worker<br>                                   │<br>              ┌────────────────────┼────────────────────┐<br>              │                    │                    │<br>              ▼                    ▼                    ▼<br>      Refresh Cache         Send Email         Generate Report</pre><p>Notice something important.</p><p>The API request finishes before the background task begins.</p><p>This keeps response times low.</p><h3>Redis Has Two Different Responsibilities</h3><p>Many developers assume Redis is only a cache.</p><p>In reality, Redis often plays multiple roles inside the same system.</p><pre>      ┌───────────────────┐</pre><pre>      │ Cache Storage     │</pre><pre>      │ Product Data      │</pre><pre>      │ User Sessions     │</pre><pre>      │ API Responses     │</pre><pre>      └───────────────────┘<br></pre><pre>      ┌───────────────────┐</pre><pre>      │ Message Broker    │</pre><pre>      │ Celery Queue      │</pre><pre>      │ Pending Tasks     │</pre><pre>      └───────────────────┘</pre><p>Although both use Redis, they store completely different kinds of data.</p><p>One stores cached information.</p><p>The other stores messages waiting for workers.</p><h3>A Real Django Example</h3><p>Suppose your homepage displays featured products.</p><p>Your API endpoint might look like this:</p><pre>def get_featured_products():<br>    cache_key = &quot;featured_products&quot;<br>    data = cache.get(cache_key)<br>    if data:<br>        return data<br>    products = Product.objects.filter(is_featured=True)<br>    serialized = ProductSerializer(products, many=True).data<br>    cache.set(cache_key, serialized, timeout=3600)<br>    return serialized</pre><p>The first request queries PostgreSQL.</p><p>Every later request reads from Redis.</p><p>Simple.</p><p>Now imagine an administrator updates a product.</p><p>Instead of rebuilding the cache immediately, we enqueue a background task.</p><pre>def update_product(product_id, payload):<br>    product = Product.objects.get(id=product_id)<br>    product.price = payload[&quot;price&quot;]<br>    product.save()<br>    refresh_featured_products.delay()</pre><p>Notice this line:</p><pre>refresh_featured_products.delay()</pre><p>Nothing happens immediately.</p><p>The task is simply placed into Celery’s queue.</p><p>The API responds instantly.</p><p>Meanwhile…</p><p>Celery handles the expensive work.</p><h3>What Happens Behind the Scenes?</h3><p>Let’s follow the request.</p><pre>Administrator</pre><pre>      │</pre><pre>Update Product</pre><pre>      ▼</pre><pre>Django API</pre><pre>      │</pre><pre>Save PostgreSQL</pre><pre>      │</pre><pre>Queue Celery Task</pre><pre>      ▼</pre><pre>HTTP 200 OK</pre><pre>────────────────────────────────────</pre><pre>Celery Worker</pre><pre>      │</pre><pre>Receive Task</pre><pre>      │</pre><pre>Query PostgreSQL</pre><pre>      │</pre><pre>Generate Cache</pre><pre>      │</pre><pre>Update Redis</pre><pre>      ▼</pre><pre>Task Complete</pre><p>Notice something subtle.</p><p>The user doesn’t wait.</p><p>Cache rebuilding happens independently.</p><p>This dramatically improves user experience.</p><h3>Why Background Cache Refresh Is Better</h3><p>Imagine rebuilding a homepage cache takes three seconds.</p><p>Without Celery:</p><pre>User Saves Product<br>↓</pre><pre>Wait 3 Seconds</pre><pre>↓</pre><pre>Response</pre><p>With Celery:</p><pre>User Saves Product<br>↓</pre><pre>Response Immediately</pre><pre>↓</pre><pre>Celery Refreshes Cache</pre><pre>↓</pre><pre>Future Visitors Receive Updated Data</pre><p>Users perceive the application as much faster because expensive work happens asynchronously.</p><h3>Cache Invalidation vs Cache Warming</h3><p>These two concepts are often confused.</p><h3>Cache Invalidation</h3><p>Simply removes outdated cache.</p><pre>Update Database<br>↓</pre><pre>Delete Cache</pre><p>The next visitor rebuilds it.</p><h3>Cache Warming</h3><p>Rebuilds the cache immediately after invalidation.</p><pre>Update Database<br>↓</pre><pre>Delete Cache</pre><pre>↓</pre><pre>Celery Rebuilds Cache</pre><pre>↓</pre><pre>Users Receive Fresh Data</pre><p>Cache warming prevents the first visitor from experiencing a slow request.</p><p>Large applications almost always prefer this approach.</p><h3>Real-World Example</h3><p>Imagine you’re browsing an online store during a major sales event.</p><p>Thousands of customers visit the homepage every second.</p><p>Without cache warming:</p><ul><li>First visitor waits 5 seconds.</li><li>Homepage cache is rebuilt.</li><li>Everyone else receives a fast response.</li></ul><p>With cache warming:</p><p>The administrator publishes a new promotion.</p><p>Immediately after saving:</p><ul><li>Celery regenerates the homepage cache.</li><li>Redis stores the new homepage.</li><li>Customers never experience the expensive rebuild.</li></ul><p>This is why many enterprise systems combine <strong>Redis + Celery</strong>.</p><p>Redis makes requests fast.</p><p>Celery keeps Redis synchronized with the database without slowing down users.</p><h3>What’s Next?</h3><p>So far we’ve answered:</p><ul><li>Why caching exists.</li><li>Why stale cache happens.</li><li>Why deleting cache isn’t enough.</li><li>How Celery works.</li><li>How Redis and Celery complement each other.</li><li>Why asynchronous cache rebuilding improves performance.</li></ul><p>In the next part, we’ll build a <strong>production-ready caching architecture</strong> using Django, Redis, and Celery. You’ll learn advanced caching patterns such as <strong>Write-Through</strong>, <strong>Write-Behind</strong>, <strong>Read-Through</strong>, distributed cache synchronization, cache versioning, cache stampede prevention, Redis clustering, monitoring, and best practices used in high-traffic production systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec2372f57666" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Caching with Redis and Celery: The Complete Guide Every Backend Developer Should Understand]]></title>
            <link>https://medium.com/@bunbunrong993/system-caching-with-redis-and-celery-the-complete-guide-every-backend-developer-should-understand-02e133e9866c?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/02e133e9866c</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[celery]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 02:14:11 GMT</pubDate>
            <atom:updated>2026-08-05T02:14:11.748Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>Learn how Redis caching and Celery work together to build high-performance web applications. Instead of only learning how to configure Redis, you’ll understand why caching exists, how cache architecture works internally, how background jobs keep your cache fresh, and how production systems like Netflix, Amazon, and GitHub use similar concepts to serve millions of users.</em></strong></blockquote><h3>Introduction</h3><p>Imagine you’ve just deployed your Django application to production.</p><p>The launch is a success.</p><p>Your dashboard shows hundreds of active users.</p><p>API requests are flowing normally.</p><p>Everything feels stable.</p><p>Then your application gets featured on a popular tech blog.</p><p>Within minutes, traffic increases from <strong>200 users</strong> to <strong>20,000 users</strong>.</p><p>At first, you’re excited.</p><p>More users mean your product is growing.</p><p>But then your monitoring dashboard begins telling a different story.</p><pre>CPU Usage        98%</pre><pre>Database CPU     100%</pre><pre>Average Response Time</pre><pre>120ms  →  3.8s</pre><pre>Error Rate</pre><pre>0.1%   →   18%</pre><p>Your PostgreSQL server is overloaded.</p><p>Every request is executing the same expensive SQL queries.</p><p>Thousands of users are asking for identical information.</p><p>For example:</p><pre>GET /api/products</pre><pre>GET /api/products</pre><pre>GET /api/products</pre><pre>GET /api/products</pre><pre>GET /api/products</pre><p>Every request performs exactly the same work.</p><pre>Application</pre><pre>↓</pre><pre>Query PostgreSQL</pre><pre>↓</pre><pre>Join 8 tables</pre><pre>↓</pre><pre>Aggregate inventory</pre><pre>↓</pre><pre>Calculate pricing</pre><pre>↓</pre><pre>Serialize JSON</pre><pre>↓</pre><pre>Return Response</pre><p>The database repeats this expensive process thousands of times every minute.</p><p>Nothing is wrong with your SQL.</p><p>Nothing is wrong with Django.</p><p>Nothing is wrong with PostgreSQL.</p><p>The real problem is much simpler.</p><blockquote><strong><em>You’re repeatedly calculating information that rarely changes.</em></strong></blockquote><p>Imagine asking someone:</p><blockquote><em>“What is today’s date?”</em></blockquote><p>One thousand times.</p><p>Instead of remembering yesterday’s answer, they walk to a calendar every single time before replying.</p><p>That would be absurd.</p><p>Yet this is exactly what many web applications do.</p><p>Every request starts from scratch.</p><p>Every request asks the database again.</p><p>Every request performs identical calculations.</p><p>Eventually, the database becomes the bottleneck.</p><h3>The Real Problem Isn’t a Slow Database</h3><p>One of the biggest misconceptions among new backend developers is:</p><blockquote><em>“My database is slow.”</em></blockquote><p>In reality, modern databases are incredibly fast.</p><p>PostgreSQL, MySQL, SQL Server, and Oracle can process millions of rows efficiently when used correctly.</p><p>The issue is usually <strong>how applications use the database</strong>, not the database itself.</p><p>Consider an e-commerce homepage.</p><p>Each visitor loads:</p><ul><li>Featured products</li><li>Categories</li><li>Best sellers</li><li>Flash sales</li><li>Store banners</li></ul><p>Now imagine 10,000 users opening the homepage at the same moment.</p><p>Without caching:</p><pre>10,000 Users</pre><pre>        │</pre><pre>        ▼</pre><pre>Django Application</pre><pre>        │</pre><pre>10,000 SQL Queries</pre><pre>        │</pre><pre>        ▼</pre><pre>PostgreSQL</pre><p>Every visitor requests the same information.</p><p>The server performs the same work repeatedly.</p><p>The database becomes overwhelmed — not because it’s slow, but because it’s being asked the same question thousands of times.</p><h3>The Birth of Caching</h3><p>Long before Redis existed, engineers faced the same challenge.</p><p>Computers have always struggled with one unavoidable fact:</p><p><strong>Reading data from storage is slower than reading data already in memory.</strong></p><p>Early computer scientists realized something important.</p><p>People naturally remember information they use frequently.</p><p>Imagine a chef preparing hundreds of meals every day.</p><p>The ingredients used most often — salt, sugar, pepper, cooking oil — are kept within arm’s reach.</p><p>Rarely used ingredients remain in storage.</p><p>The chef doesn’t walk to the storeroom every time someone asks for salt.</p><p>Software follows exactly the same principle.</p><p>Frequently requested information should stay close to the application.</p><p>Rarely requested information can remain in the database.</p><p>This simple observation became one of the most important optimization techniques in computer science:</p><blockquote><strong><em>Don’t compute the same result twice if nothing has changed.</em></strong></blockquote><p>That idea is the foundation of caching.</p><h3>What Is a Cache?</h3><p>Many tutorials define a cache like this:</p><blockquote><em>“A cache stores temporary data.”</em></blockquote><p>Technically, that’s correct.</p><p>But it doesn’t explain <strong>why</strong> caches exist.</p><p>A better definition is:</p><blockquote><strong><em>A cache is a high-speed memory layer that stores frequently accessed data so future requests can be served without repeating expensive work.</em></strong></blockquote><p>Notice something important.</p><p>A cache does <strong>not</strong> replace your database.</p><p>It complements it.</p><p>Think of your database as a massive library.</p><p>Every book ever written is stored there.</p><p>Finding the right book may take a little time.</p><p>Now imagine placing today’s most popular books on a small table near the entrance.</p><p>Visitors can immediately pick them up.</p><p>The library still contains every book.</p><p>But the most frequently requested books are now much faster to access.</p><p>That’s exactly how Redis works.</p><h3>Introducing Redis</h3><p>Redis stands for <strong>Remote Dictionary Server</strong>.</p><p>Unlike PostgreSQL, which stores data permanently on disk, Redis stores data primarily in <strong>memory (RAM)</strong>.</p><p>Because RAM is dramatically faster than disk storage, Redis can respond to requests in microseconds instead of milliseconds.</p><p>A simplified comparison looks like this:</p><p>StorageAverage Access SpeedHard Disk (HDD)~10 millisecondsSSD~0.1 millisecondsPostgreSQL QueryDepends on query complexityRedis Memory LookupOften less than 1 millisecond</p><p>The exact numbers vary depending on hardware and workload, but the principle remains the same:</p><p><strong>Memory access is dramatically faster than repeatedly executing complex database queries.</strong></p><p>This speed is what makes Redis one of the most widely adopted caching technologies in modern backend systems.</p><h3>A Simple Example</h3><p>Suppose your API returns the list of product categories.</p><pre>GET /api/categories</pre><p>The categories change only once or twice each month.</p><p>Without caching, every request performs the same database query.</p><pre>Client</pre><pre>     │</pre><pre>     ▼</pre><pre>Django</pre><pre>     │</pre><pre>SELECT * FROM category;</pre><pre>     ▼</pre><pre>PostgreSQL</pre><pre>     │</pre><pre>     ▼</pre><pre>Response</pre><p>Now imagine 5,000 users visiting your homepage every hour.</p><p>The database executes the same query 5,000 times.</p><p>Yet the answer is always identical.</p><p>Caching changes the entire request flow.</p><pre>First Request</pre><pre>Client<br>   │<br>   ▼<br>Django<br>   │<br>   ▼<br>Redis Cache</pre><pre>   │</pre><pre>Cache Miss</pre><pre>   ▼</pre><pre>PostgreSQL</pre><pre>   │</pre><pre>Store Result in Redis</pre><pre>   ▼</pre><pre>Response</pre><pre>Later Requests</pre><pre>Client<br>   │<br>   ▼<br>Django<br>   │<br>   ▼<br>Redis Cache</pre><pre>   │</pre><pre>Cache Hit</pre><pre>   ▼</pre><pre>Response</pre><p>Notice what happened.</p><p>The database only performed the expensive work <strong>once</strong>.</p><p>Every later request was served directly from memory.</p><p>The users receive a faster response, and the database is free to handle other work.</p><p>This simple pattern is called <strong>Cache-Aside</strong>, and it is the foundation of most Redis caching strategies.</p><h3>But There’s a New Problem…</h3><p>Caching solves one problem while introducing another.</p><p>Imagine your application caches the product categories for 24 hours.</p><p>At 10:00 AM, the cache contains:</p><pre>Electronics<br>Laptops<br>Phones<br>Accessories</pre><p>At 10:05 AM, an administrator adds a new category:</p><pre>Gaming Consoles</pre><p>The database now contains the new category.</p><p>But Redis still holds the old list.</p><p>Your users continue seeing outdated information.</p><p>This raises one of the most important questions in backend engineering:</p><blockquote><strong><em>How do we keep cached data synchronized with the database without making every request slow again?</em></strong></blockquote><p>This challenge — known as <strong>cache invalidation</strong> — is often called one of the hardest problems in software engineering.</p><p>And this is exactly where <strong>Celery</strong> enters the architecture.</p><p>In the next section, we’ll explore why Redis alone isn’t enough, how background workers solve cache synchronization, and how Redis and Celery work together to keep applications both <strong>fast</strong> and <strong>accurate</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02e133e9866c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API Key vs Access Token: What’s the Difference? A Complete Guide for Developers]]></title>
            <link>https://medium.com/@bunbunrong993/api-key-vs-access-token-whats-the-difference-a-complete-guide-for-developers-41fbff112bcd?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/41fbff112bcd</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[api-key]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[access-token]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 06:00:35 GMT</pubDate>
            <atom:updated>2026-08-08T07:24:28.498Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>Learn the difference between API Keys and Access Tokens, when to use each, how they work, and why choosing the right authentication method is critical for building secure and scalable APIs.</em></strong></blockquote><h3>Introduction</h3><p>Imagine you’ve just finished building your first REST API.</p><p>Now comes an important question:</p><p><strong>How should clients authenticate?</strong></p><p>Should they send an API Key?</p><p>Should they use an Access Token?</p><p>Or should they use both?</p><p>Many developers — even experienced ones — use the terms <strong>API Key</strong> and <strong>Access Token</strong> interchangeably. At first glance, they seem similar because both are strings sent with API requests. However, they serve very different purposes.</p><p>Using the wrong authentication method can introduce security vulnerabilities, make your APIs difficult to scale, and complicate future integrations. On the other hand, understanding when and why to use each one allows you to build APIs that are secure, maintainable, and ready for production.</p><p>In this guide, you’ll learn what API Keys and Access Tokens are, how they work, their advantages and disadvantages, when to use them, and why many modern systems use both together.</p><h3>What Is an API Key?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*0n3aHjVzbuBATDdbYVdzOA@2x.jpeg" /></figure><p>An <strong>API Key</strong> is a unique identifier that allows an application to access an API. Think of it as an identification badge for software.</p><p>Unlike user authentication, an API Key identifies <strong>the application making the request</strong>, not the person using the application.</p><p>For example, when your weather application requests data from a weather service, the service needs to know which application is making the request. It doesn’t necessarily need to know who the end user is.</p><p>A typical request looks like this:</p><pre>GET /api/weather</pre><pre>Headers:<br>x-api-key: sk_live_9f2d7xxxxxxxxxxxxx</pre><p>When the server receives the request, it verifies that the API Key is valid before allowing access.</p><h3>How API Keys Work</h3><p>The authentication process is straightforward:</p><pre>Application<br>      │<br>      │  API Key<br>      ▼<br>API Gateway<br>      │<br>Validate API Key<br>      ▼<br>Backend API</pre><p>The server checks whether the key exists, whether it is active, and whether it has permission to access the requested API.</p><p>If everything is valid, the request continues.</p><p>Otherwise, the server returns an authentication error.</p><h3>Why API Keys Exist</h3><p>API Keys were introduced to solve a simple problem.</p><p>Imagine you build a public API that thousands of developers use.</p><p>Without API Keys, anyone could send unlimited requests to your server.</p><p>You wouldn’t know:</p><ul><li>Which application is using your API</li><li>How many requests each application makes</li><li>Whether one application is abusing your service</li><li>Which developer should receive usage statistics</li></ul><p>API Keys solve these problems by identifying the calling application.</p><p>Because of this, they’re commonly used for:</p><ul><li>Public APIs</li><li>Third-party integrations</li><li>Rate limiting</li><li>Usage tracking</li><li>Billing</li><li>Machine-to-machine communication</li></ul><h3>Advantages of API Keys</h3><p>API Keys offer several benefits:</p><ul><li>Easy to generate and manage.</li><li>Simple to integrate into any application.</li><li>Excellent for identifying client applications.</li><li>Useful for monitoring API usage.</li><li>Ideal for server-to-server communication.</li></ul><p>Because of their simplicity, API Keys remain popular today.</p><p><strong>Limitations of API Keys</strong></p><p>Despite their advantages, API Keys have important limitations.</p><p>Most API Keys:</p><ul><li>Do not identify individual users.</li><li>Often never expire.</li><li>Can be copied if exposed.</li><li>Usually provide limited permission control.</li><li>Cannot easily represent user roles or permissions.</li></ul><p>If someone steals an API Key, they can often use it until the owner manually revokes it.</p><p>This is why API Keys should never be treated as user authentication.</p><h3>What Is an Access Token?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*RcWxwJJr71nkFkksiBi1Mw@2x.jpeg" /></figure><p>An <strong>Access Token</strong> is a temporary credential that represents an authenticated user or service.</p><p>Instead of identifying an application, it identifies <strong>who is making the request</strong> and <strong>what they are allowed to do</strong>.</p><p>Modern Access Tokens are commonly implemented as <strong>JSON Web Tokens (JWTs)</strong> or OAuth 2.0 bearer tokens.</p><p>A typical request looks like this:</p><pre>GET /api/profile</pre><pre>Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR...</pre><p>Unlike an API Key, the Access Token is generated <strong>after a successful login</strong>.</p><h3>How Access Tokens Work</h3><p>A typical authentication flow looks like this:</p><pre>User<br> │<br> ▼<br>Login<br> │<br> ▼<br>Authentication Server<br> │<br>Generate Access Token<br> │<br> ▼<br>Client Application<br> │<br>Authorization: Bearer Token<br> ▼<br>Backend API</pre><p>Every request includes the Access Token.</p><p>The backend verifies that:</p><ul><li>The token is valid.</li><li>The token has not expired.</li><li>The token was issued by a trusted authority.</li><li>The user has permission to perform the requested action.</li></ul><p>Only then is access granted.</p><h3>Why Access Tokens Exist</h3><p>As web applications became more complex, developers needed more than simple application identification.</p><p>Modern systems need to answer questions like:</p><ul><li>Who is this user?</li><li>Is this user logged in?</li><li>What role does this user have?</li><li>Can this user access this resource?</li><li>Has the session expired?</li></ul><p>API Keys cannot answer these questions.</p><p>Access Tokens were designed specifically for user authentication and authorization.</p><h3>API Key vs Access Token</h3><p>Although they may appear similar, they solve different problems.</p><p>FeatureAPI KeyAccess TokenIdentifiesApplicationUser or ServicePurposeApplication AuthenticationUser AuthenticationExpiresUsually NoYesPermissionsLimitedFine-GrainedUser IdentityNoYesOAuth CompatibleNoYesSecurityMediumHighBest Use CasePublic APIsLogged-in Applications</p><p>A simple way to remember the difference is:</p><blockquote><strong><em>API Keys identify applications. Access Tokens identify authenticated users.</em></strong></blockquote><h3>Real-World Examples</h3><p>Let’s look at where each method is commonly used.</p><h3>Google Maps API</h3><p>When embedding Google Maps into a website, Google needs to know which application is making requests.</p><p>An API Key is sufficient because Google doesn’t need to know who is viewing the map.</p><pre>Website</pre><pre>↓</pre><pre>Google Maps API</pre><pre>↓</pre><pre>API Key</pre><h3>Stripe</h3><p>Stripe’s backend APIs use Secret API Keys.</p><p>When your server creates a payment intent, Stripe identifies your application — not your customer.</p><pre>Backend Server</pre><pre>↓</pre><pre>Stripe Secret Key</pre><pre>↓</pre><pre>Stripe API</pre><h3>GitHub</h3><p>GitHub needs to know exactly which developer is making an API request.</p><p>For example:</p><ul><li>Creating repositories</li><li>Reading private repositories</li><li>Managing pull requests</li></ul><p>These actions require user identity.</p><p>GitHub therefore uses Access Tokens.</p><pre>Developer Login<br>↓<br>Access Token<br>↓<br>GitHub API</pre><h3>Banking Applications</h3><p>When transferring money, the system must know:</p><ul><li>Who the customer is</li><li>Whether they’re authenticated</li><li>What permissions they have</li></ul><p>This requires an Access Token.</p><p>Using only an API Key would be a serious security risk.</p><h3>Can You Use Both Together?</h3><p>Absolutely.</p><p>In fact, many enterprise systems do exactly that.</p><p>Consider a mobile banking application.</p><pre>Mobile Application<br>        │<br>        ├── API Key<br>        │      │<br>        │      └── Identifies the application<br>        │<br>        └── Access Token<br>               │<br>               └── Identifies the logged-in customer</pre><p>The API Gateway first verifies that the request comes from an approved application.</p><p>The backend then verifies that the authenticated user has permission to perform the requested action.</p><p>This layered approach provides stronger security than using either method alone.</p><h3>Common Mistakes Developers Make</h3><p>Many authentication issues come from misunderstanding these technologies.</p><p>Some common mistakes include:</p><h3>1. Using an API Key for User Authentication</h3><p>An API Key cannot identify individual users.</p><p>Always use Access Tokens for authenticated users.</p><h3>2. Hardcoding API Keys</h3><p>Never store API Keys directly in source code.</p><p>Instead, use:</p><ul><li>Environment variables</li><li>Secret management services</li><li>Secure configuration systems</li></ul><h3>3. Creating Tokens That Never Expire</h3><p>Access Tokens should be short-lived.</p><p>Long-lived tokens increase the risk if they are stolen.</p><h3>4. Sending Tokens Over HTTP</h3><p>Always use HTTPS.</p><p>Otherwise, credentials can be intercepted during transmission.</p><h3>5. Giving Excessive Permissions</h3><p>Follow the Principle of Least Privilege.</p><p>Applications and users should only receive the permissions they actually need.</p><h3>Best Practices</h3><p>Whether you choose API Keys or Access Tokens, follow these security recommendations:</p><ul><li>Always use HTTPS.</li><li>Rotate API Keys regularly.</li><li>Store secrets securely.</li><li>Keep Access Tokens short-lived.</li><li>Use Refresh Tokens for long sessions.</li><li>Implement rate limiting.</li><li>Monitor authentication logs.</li><li>Revoke compromised credentials immediately.</li><li>Never expose secrets in frontend applications or public repositories.</li></ul><p>These practices significantly reduce the risk of unauthorized access.</p><h3>When Should You Use Each?</h3><p>A simple decision process looks like this:</p><pre>Need to identify who is calling your API?</pre><pre>        │<br>        ▼</pre><pre>Is it an application?</pre><pre>        │<br>   Yes ─────► API Key</pre><pre>        │<br>        No</pre><pre>        ▼</pre><pre>Is it an authenticated user?</pre><pre>        │<br>   Yes ─────► Access Token</pre><p>In many enterprise applications, the answer is both.</p><p>Use an API Key to identify the client application and an Access Token to identify the authenticated user.</p><h3>Conclusion</h3><p>API Keys and Access Tokens are not competitors — they solve different problems.</p><p>An <strong>API Key</strong> answers the question:</p><blockquote><strong><em>“Which application is making this request?”</em></strong></blockquote><p>An <strong>Access Token</strong> answers the question:</p><blockquote><strong><em>“Which authenticated user or service is making this request, and what are they allowed to do?”</em></strong></blockquote><p>Understanding this distinction is one of the most important concepts in API security.</p><p>If you’re building a public API, integrating with third-party services, or designing a modern microservices architecture, choosing the right authentication mechanism will improve both security and scalability.</p><p>Many of today’s most successful platforms — including Google Cloud, GitHub, Stripe, AWS, Microsoft Azure, and countless SaaS products — use a combination of API Keys and Access Tokens to protect their services while providing a seamless developer experience.</p><p>As you design your next API, don’t ask <strong>“Which one should I use?”</strong> Instead, ask <strong>“What problem am I trying to solve?”</strong></p><p>Once you understand that difference, selecting the right authentication strategy becomes much easier — and your APIs will be more secure, more maintainable, and better prepared for production.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41fbff112bcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Outbound Events for Software Engineers: The Complete Guide to Building High-Performing Engineering…]]></title>
            <link>https://medium.com/@bunbunrong993/outbound-events-for-software-engineers-the-complete-guide-to-building-high-performing-engineering-d1d8f1e21c9e?source=rss-8c7c8f5d9108------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1d8f1e21c9e</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[skill-improvement]]></category>
            <category><![CDATA[outbound-events-se]]></category>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Bunbunrong]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 03:49:20 GMT</pubDate>
            <atom:updated>2026-08-03T03:49:20.350Z</atom:updated>
            <content:encoded><![CDATA[<h3>Outbound Events for Software Engineers: The Complete Guide to Building High-Performing Engineering Teams</h3><blockquote><strong><em>Learn how to design, organize, and run outbound events that strengthen communication, leadership, collaboration, and problem-solving in software engineering teams.</em></strong></blockquote><h3>Introduction</h3><p>Most software engineers believe becoming a better developer means learning another programming language, mastering a new framework, or studying system design.</p><p>Those skills are important — but they’re only part of the equation.</p><p>Think about the last project that missed its deadline.</p><p>Was it because the developers didn’t know how to code?</p><p>Probably not.</p><p>More often, software projects struggle because of:</p><ul><li>Miscommunication between teams</li><li>Unclear requirements</li><li>Poor collaboration</li><li>Weak leadership</li><li>Lack of trust</li><li>Different assumptions across departments</li></ul><p>In other words, <strong>people problems become software problems</strong>.</p><p>This is why many successful engineering organizations invest in <strong>Outbound Events</strong>. These events are not simply company trips or recreational activities — they are structured learning experiences designed to improve how engineering teams communicate, collaborate, solve problems, and lead under pressure.</p><p>This guide explains what outbound events are, why they matter in software engineering, how to organize one successfully, and how to transform the lessons learned into better engineering practices.</p><h3>What Is an Outbound Event?</h3><p>An outbound event is a structured learning program conducted outside the normal workplace. Participants engage in collaborative challenges, simulations, workshops, and team-based activities that recreate the kinds of situations engineering teams face every day.</p><p>Unlike a casual company outing, every activity has a clear learning objective.</p><p>Typical goals include:</p><ul><li>Improving communication</li><li>Building trust</li><li>Strengthening teamwork</li><li>Developing leadership</li><li>Encouraging creative thinking</li><li>Practicing decision-making under pressure</li><li>Enhancing problem-solving skills</li></ul><p>The objective is not simply to complete the activities — it is to understand <em>how</em> the team works together and <em>how</em> those behaviors influence real software projects.</p><h3>Why Software Engineering Teams Need Outbound Events</h3><p>Software engineering is no longer an individual profession.</p><p>Modern products are built by cross-functional teams that include backend developers, frontend developers, QA engineers, DevOps engineers, designers, product managers, business analysts, and engineering managers.</p><p>Even if every individual is technically excellent, projects can still fail when collaboration breaks down.</p><p>Consider these common engineering challenges:</p><ul><li>Developers interpret requirements differently.</li><li>Teams work in isolation.</li><li>Knowledge is concentrated in a few people.</li><li>Engineers hesitate to ask questions.</li><li>Production incidents reveal communication gaps.</li><li>Sprint planning lacks alignment.</li></ul><p>Outbound events help address these issues by creating situations where success depends on communication, trust, and collaboration rather than technical expertise alone.</p><h3>The Outbound Event Lifecycle</h3><p>Every successful outbound event follows a structured process.</p><pre>                    ┌──────────────────────┐<br>                    │ Identify Team Issues │<br>                    │ Communication, Trust │<br>                    └──────────┬───────────┘<br>                               │<br>                               ▼<br>                    ┌──────────────────────┐<br>                    │ Define Objectives    │<br>                    │ Leadership, Teamwork │<br>                    └──────────┬───────────┘<br>                               │<br>                               ▼<br>                    ┌──────────────────────┐<br>                    │ Design Activities    │<br>                    │ Simulations &amp; Games  │<br>                    └──────────┬───────────┘<br>                               │<br>                               ▼<br>                    ┌──────────────────────┐<br>                    │ Execute Event        │<br>                    │ Team Challenges      │<br>                    └──────────┬───────────┘<br>                               │<br>                               ▼<br>                    ┌──────────────────────┐<br>                    │ Reflection Session   │<br>                    │ Discuss Lessons      │<br>                    └──────────┬───────────┘<br>                               │<br>                               ▼<br>                    ┌──────────────────────┐<br>                    │ Apply at Work        │<br>                    │ Better Engineering   │<br>                    └──────────────────────┘</pre><p>The final step is the most important. Without applying lessons back in the workplace, the event becomes entertainment rather than professional development.</p><h3>The Story: Why Outbound Events Work</h3><p>Imagine your engineering team is building an e-commerce checkout platform.</p><p>The project team consists of:</p><pre>Frontend Developers<br>Backend Developers<br>QA Engineers<br>DevOps Engineers<br>UI/UX Designers<br>Business Analysts</pre><p>Sprint planning goes well.</p><p>Development finishes on time.</p><p>Testing passes.</p><p>Deployment day arrives.</p><p>Then problems appear.</p><pre>❌ Frontend uses an outdated API endpoint.</pre><pre>❌ Backend renamed a response field.</pre><pre>❌ QA tested yesterday&#39;s build.</pre><pre>❌ DevOps deployed the wrong container image.</pre><pre>Result:</pre><pre>🚨 Production Incident</pre><p>Was the problem technical?</p><p>No.</p><p>Every team had the necessary technical skills.</p><p>The failure happened because communication and coordination broke down.</p><p>Now imagine an outbound activity where each participant receives only part of a puzzle. No one can complete the task individually. Success depends on sharing information, listening carefully, and coordinating decisions.</p><p>This mirrors software engineering perfectly.</p><p>The activity becomes a safe environment where teams experience the consequences of poor communication — and discover better ways to work together.</p><h3>Mapping Outbound Activities to Software Engineering</h3><p>One of the biggest misconceptions is that outbound activities are “just games.”</p><p>In reality, each activity develops a skill directly applicable to engineering work.</p><p>Outbound ActivitySoftware Engineering EquivalentSkill DevelopedEscape RoomProduction Incident ResponseCollaboration under pressureTreasure HuntDebugging Complex SystemsAnalytical thinkingBlindfold NavigationRequirement GatheringActive listeningTower BuildingSoftware ArchitecturePlanning and designRope CrossingCI/CD PipelineProcess disciplineStrategy GameSprint PlanningDecision-makingRelay ChallengeAgile DevelopmentHandover and coordination</p><p>When participants understand this connection, every activity becomes a learning opportunity rather than simple entertainment.</p><h3>How to Organize an Outbound Event</h3><h3>Step 1: Identify Team Challenges</h3><p>Before planning activities, identify the engineering problems you want to solve.</p><p>Examples include:</p><ul><li>Weak communication between frontend and backend teams</li><li>Low confidence among junior developers</li><li>Poor collaboration during deployments</li><li>Limited leadership opportunities</li><li>Ineffective sprint retrospectives</li></ul><p>The event should address real challenges, not hypothetical ones.</p><h3>Step 2: Define Learning Objectives</h3><p>Every activity should support a measurable outcome.</p><p>Examples:</p><ul><li>Improve communication across engineering teams.</li><li>Build trust between departments.</li><li>Develop leadership in senior engineers.</li><li>Strengthen collaborative problem-solving.</li></ul><h3>Step 3: Design Purposeful Activities</h3><p>Select activities that reinforce the desired behaviors.</p><p>For example:</p><ul><li>Communication simulations</li><li>Team strategy challenges</li><li>Leadership rotation exercises</li><li>Resource management games</li><li>Cross-functional problem-solving scenarios</li></ul><p>Avoid activities that are fun but unrelated to the learning objectives.</p><h3>Step 4: Run the Event</h3><p>Encourage participants to:</p><ul><li>Share ideas openly.</li><li>Rotate leadership roles.</li><li>Make collective decisions.</li><li>Learn from mistakes.</li><li>Support teammates.</li></ul><p>The facilitator should observe team behavior rather than simply manage the schedule.</p><h3>Step 5: Reflect and Apply</h3><p>The reflection session transforms experiences into workplace improvements.</p><p>Ask questions such as:</p><ul><li>What worked well?</li><li>What slowed the team down?</li><li>How did communication affect the outcome?</li><li>Did leadership emerge naturally?</li><li>How does this relate to our current engineering process?</li><li>What changes should we implement next week?</li></ul><p>Reflection is where meaningful learning takes place.</p><h3>Sample One-Day Schedule</h3><pre>08:00  Registration</pre><pre>08:30  Icebreaker Activities</pre><pre>09:00  Communication Challenge</pre><pre>10:30  Leadership Rotation</pre><pre>12:00  Lunch</pre><pre>13:00  Engineering Simulation</pre><pre>15:00  Team Mission</pre><pre>16:30  Reflection Workshop</pre><pre>17:00  Action Plan &amp; Closing</pre><h3>From Outbound Lessons to Better Software</h3><p>The learning process does not end when the event finishes.</p><pre>Problems in Engineering Team<br>            │<br>            ▼<br>   Outbound Activities<br>            │<br>            ▼<br> Reflection &amp; Discussion<br>            │<br>            ▼<br>  New Team Practices<br>            │<br>            ▼<br> Higher Quality Projects<br>            │<br>            ▼<br> Continuous Improvement</pre><p>This mirrors Agile development: inspect, adapt, and improve.</p><h3>Common Mistakes to Avoid</h3><ul><li>Treating the event as entertainment instead of learning.</li><li>Choosing activities without clear objectives.</li><li>Skipping the reflection session.</li><li>Rewarding competition over collaboration.</li><li>Failing to implement lessons after the event.</li><li>Ignoring feedback from participants.</li></ul><h3>Key Takeaways</h3><p>An effective outbound event is not measured by how much fun participants had — it is measured by how much the team improves afterward.</p><p>When planned thoughtfully, outbound events help software engineering teams:</p><ul><li>Communicate more effectively.</li><li>Collaborate across disciplines.</li><li>Build trust.</li><li>Strengthen leadership.</li><li>Solve problems more efficiently.</li><li>Improve sprint execution.</li><li>Reduce misunderstandings.</li><li>Deliver higher-quality software.</li></ul><h3>Conclusion</h3><p>Building exceptional software requires more than writing excellent code. It requires teams that trust one another, communicate clearly, adapt to change, and solve problems together.</p><p>Outbound events provide a practical environment where these skills can be developed through experience rather than theory. By recreating the challenges of software engineering in collaborative, hands-on activities, teams learn behaviors that directly improve planning, development, testing, deployment, and continuous improvement.</p><p>Whether you’re a junior developer seeking to grow, a senior engineer preparing for leadership, or an engineering manager building a stronger team, organizing an outbound event is an investment in long-term engineering excellence.</p><p>The strongest engineering teams are not defined by the smartest individual — they are defined by how effectively they work together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1d8f1e21c9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>