<?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 Anthony Ricardo Thiotanry on Medium]]></title>
        <description><![CDATA[Stories by Anthony Ricardo Thiotanry on Medium]]></description>
        <link>https://medium.com/@artkx?source=rss-b9d19ed7cb7b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5ObypwbOrNXPDZWXi-Oqtg.jpeg</url>
            <title>Stories by Anthony Ricardo Thiotanry on Medium</title>
            <link>https://medium.com/@artkx?source=rss-b9d19ed7cb7b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:48:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@artkx/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[Goroutine: Concurrency Without Parallelism]]></title>
            <link>https://medium.com/@artkx/goroutine-concurrency-without-parallelism-72191346b64b?source=rss-b9d19ed7cb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/72191346b64b</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[concurrency]]></category>
            <dc:creator><![CDATA[Anthony Ricardo Thiotanry]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 12:37:10 GMT</pubDate>
            <atom:updated>2025-11-16T12:37:10.049Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Same-same, but different.</blockquote><p>Concurrency and parallelism are two ideas that get mixed up all the time in system design. They’re often treated as synonyms, but they’re really not. <strong>Concurrency</strong> is how you structure work so that many things can be <em>in flight</em>. <strong>Parallelism</strong> is how many things can <em>actually run at the same instant</em>.</p><p>This confusion is seductive because we mistake <strong>activity</strong> for <strong>progress</strong>. Thousands of tasks “running” sounds like high throughput, but in reality only as many can execute <em>right now</em> as your machine’s parallelism allows.</p><p>That misunderstanding is how you get a system that behaves beautifully in a controlled development environment and then falls apart in production.</p><p>So what am I saying, really? Let’s start from the basics…</p><h3>What’s Goroutine?</h3><p>A goroutine is a tiny, managed unit of work in Go. You start one with go f(). The Go runtime decides <em>when</em> and <em>where</em> it runs.</p><p>Think of it as saying: “<em>Do this without blocking me.</em>” Goroutines are cheap enough that having thousands live at the same time is completely normal.</p><p>Under the hood, goroutine works simply:</p><ul><li>You hand tasks to Go.</li><li>Go spreads them across a handful of worker threads.</li><li>The OS puts those threads on real cores.</li></ul><p>Let’s simulate three slow I/O calls (think: HTTP, DB, queue). First without goroutines, then with them.</p><p>For both simulations, I will use this function to fake network/disk wait.</p><pre>func slowIO(i int) {<br> time.Sleep(50 * time.Millisecond)<br> fmt.Println(&quot;task&quot;, i, &quot;done&quot;)<br>}</pre><h4><strong>Without goroutines (sequential)</strong></h4><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;time&quot;<br>)<br><br>func main() {<br> start := time.Now()<br><br> for i := 1; i &lt;= 3; i++ {<br>  slowIO(i)<br> }<br><br> fmt.Println(&quot;sequential took:&quot;, time.Since(start))<br>}</pre><h4><strong>With goroutines (concurrent)</strong></h4><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;sync&quot;<br> &quot;time&quot;<br>)<br><br>func main() {<br> start := time.Now()<br><br> var wg sync.WaitGroup<br> wg.Add(3)<br><br> for i := 1; i &lt;= 3; i++ {<br>  i := i<br>  go func() {<br>   defer wg.Done()<br>   slowIO(i)<br>  }()<br> }<br><br> wg.Wait()<br> fmt.Println(&quot;concurrent took:&quot;, time.Since(start))<br>}</pre><h4>Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*xrbN1F8kC_Ge6zVMuu_ELQ.png" /><figcaption>Sequential execution result</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*xMblZZP9crZRMMY--fIRnA.png" /><figcaption>Concurrent execution result</figcaption></figure><p>Now, briefly: <strong>why is the concurrent one faster?</strong></p><p><strong>Sequential</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*od4roqBJlTdBVAIoP_i_9Q.png" /><figcaption>Sequential tasks visualization</figcaption></figure><p>On the sequential side, each task politely queues behind the previous one on the same timeline. Task 1 finishes, <em>then</em> Task 2 is allowed to start, <em>then</em> Task 3. If each takes ~50 ms, you pay for all of them end-to-end: about 150 ms of wall-clock time, because there is no overlap at all.</p><p><strong>Concurrent</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*u78ciyuwH1Y32KGkN8d7ww.png" /><figcaption>Concurrent tasks visualization</figcaption></figure><p>Meanwhile, on the concurrent side, the tasks are staggered along the same timeline. Task 1 starts, hits a time.Sleep (or I/O), and the goroutine parks, the thread immediately moves on to run Task 2, then Task 3. Their <em>waiting time</em> overlaps, so total wall-clock time is closer to the longest single task (~50 ms) plus a bit of scheduling overhead, instead of the sum of all three.</p><p>Now, let’s move on to the core topic of this article: <strong>concurrency vs. parallelism</strong>.</p><h3>Concurrency vs. parallelism</h3><p>So far, we’ve seen goroutines make the concurrent version faster than the sequential one. But that doesn’t mean your CPU suddenly learned to do magic.</p><p>Let’s untangle two words that often get mashed together.</p><h4>What is concurrency?</h4><p><strong>Concurrency</strong> is about <em>dealing with many things at once</em>.</p><p>In code, it means structuring your program as multiple independent units of work that can make progress without waiting on each other more than necessary.</p><ul><li>You break work into tasks: goroutines, actors, processes, whatever.</li><li>You define how they communicate: channels, queues, message buses, shared memory.</li><li>The runtime juggles them so that when one is waiting (I/O, lock, timer), another can run.</li></ul><blockquote><em>Concurrency is a design choice: “I want these things </em>in flight at the same time<em>.”</em></blockquote><h4>What is parallelism?</h4><p><strong>Parallelism</strong> is about <em>doing many things at the same instant</em>.</p><p>At the hardware level:</p><ul><li>Multiple CPU cores execute instructions simultaneously.</li><li>Or a GPU crunching thousands of operations at once.</li><li>Or a vector instruction doing math on multiple data points in a single cycle.</li></ul><p>In Go, you get parallelism when:</p><ul><li>Your machine actually has multiple cores, <strong>and</strong></li><li>GOMAXPROCS allows multiple OS threads to run Go code at once, <strong>and</strong></li><li>Your workload has enough independent CPU work to occupy those cores.</li></ul><blockquote><em>Parallelism is a resource question: “Can my hardware run these things </em>at the same time<em>?”</em></blockquote><h3>Concurrency without paralleism</h3><p>First, let’s look at a case where goroutines help <strong>even when you only have one logical CPU</strong>.</p><p>Imagine you have a bunch of “slow” steps in your pipeline: maybe scheduled notifications, delayed retries, or “don’t process this before X ms” logic. Most of the time, the program is just <strong>waiting</strong>.</p><p>We’ll simulate that with time.Sleep, which is basically “pure waiting” from the program’s point of view.</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;runtime&quot;<br> &quot;sync&quot;<br> &quot;time&quot;<br>)<br><br>const (<br> numTasks = 20<br> delay    = 100 * time.Millisecond<br>)<br><br>func main() {<br> runtime.GOMAXPROCS(1)<br><br> start := time.Now()<br><br> var wg sync.WaitGroup<br> wg.Add(numTasks)<br><br> for i := 0; i &lt; numTasks; i++ {<br>  go func() {<br>   defer wg.Done()<br>   time.Sleep(delay)<br>  }()<br> }<br><br> wg.Wait()<br> fmt.Println(&quot;concurrent pure-wait took:&quot;, time.Since(start))<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*0kI3bNqbJxqS6wPXFygr9w.png" /><figcaption>The result</figcaption></figure><p>You can see that the program finishes in 100ms instead of 20 x 100ms = 2 second(s) . Why?</p><p>Even though everything is running on <strong>one core</strong>:</p><ul><li>At the start, all 20 goroutines are created almost back-to-back.</li><li>Each one immediately calls time.Sleep(100 * time.Millisecond).</li><li>time.Sleep tells the runtime: <em>“Wake me up at </em><em>now + 100ms.”</em> The goroutine is <strong>parked</strong> and stops running.</li><li>Once parked, that goroutine doesn’t use the CPU at all. The single OS thread has nothing meaningful to do except wait for timers to expire.</li><li>Around the 100ms mark, all those timers fire, the goroutines wake up, do a tiny bit of work, and exit.</li></ul><p>Now you might say: “<strong><em>Wow! That looks great. Why not just add more CPUs to make it even faster?</em></strong>”</p><p>Well… In this scenario. Not really.</p><p>Let’s run the same code, but compare GOMAXPROCS=1 and GOMAXPROCS=4 :</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;runtime&quot;<br> &quot;sync&quot;<br> &quot;time&quot;<br>)<br><br>const (<br> numTasks = 20<br> delay    = 100 * time.Millisecond<br>)<br><br>func main() {<br> for _, procs := range []int{1, 4} {<br>  runtime.GOMAXPROCS(procs)<br><br>  start := time.Now()<br>  runConcurrentSleep()<br>  fmt.Printf(&quot;GOMAXPROCS=%d → %v\n&quot;, procs, time.Since(start))<br> }<br>}<br><br>func runConcurrentSleep() {<br> var wg sync.WaitGroup<br> wg.Add(numTasks)<br><br> for i := 0; i &lt; numTasks; i++ {<br>  go func() {<br>   defer wg.Done()<br>   time.Sleep(delay)<br>  }()<br> }<br><br> wg.Wait()<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/1*h_GaI8-DyKqzwlpXQ8SP8Q.png" /><figcaption>GOMAXPROCS comparison result</figcaption></figure><p><strong>Why doesn’t 4 CPUs make things dramatically faster here?</strong></p><p>Because:</p><ul><li>The work is <strong>dominated by waiting</strong> (the timers).</li><li>time.Sleep tells the runtime: “park this goroutine until time T”.</li><li>While all goroutines are sleeping, <em>there is nothing to do.</em></li><li>When the timers fire, each goroutine wakes, does almost no CPU work, then finishes.</li></ul><p>Even with 4 cores available, there’s no meaningful CPU bottleneck to remove. You can’t “parallelize waiting on the clock” in a way that beats “everyone starts sleeping at the same time.”</p><p>So in this case, extra logical CPUs don’t buy you much</p><h4>Concurrency with parallelism</h4><p>Now flip to a very different workload.</p><p>Think of a nightly batch that re-scores a bunch of customers with an expensive risk model. Almost no I/O, just math and loops.</p><p>We’ll simulate that with a tight CPU loop:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;runtime&quot;<br> &quot;sync&quot;<br> &quot;time&quot;<br>)<br><br>func burnCPU(ms int) {<br> end := time.Now().Add(time.Duration(ms) * time.Millisecond)<br> for time.Now().Before(end) {<br>  // busy loop: pretend this is complex risk scoring logic<br> }<br>}<br><br>func runBatch(procs int) time.Duration {<br> runtime.GOMAXPROCS(procs)<br><br> start := time.Now()<br> var wg sync.WaitGroup<br> wg.Add(100)<br><br> for i := 0; i &lt; 100; i++ {<br>  go func() {<br>   defer wg.Done()<br>   burnCPU(20)<br>  }()<br> }<br><br> wg.Wait()<br> return time.Since(start)<br>}<br><br>func main() {<br> for _, p := range []int{1, 2, 4, 8} {<br>  fmt.Printf(&quot;GOMAXPROCS=%d → %v\n&quot;, p, runBatch(p))<br> }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*aPoZsCYw7cZpTOqhoLg2pg.png" /><figcaption>GOMAXPROCS comparison result with parallelism</figcaption></figure><p>As you can see in the result above, the total time withGOMAXPROCS=1 is roughly what you’d expect for <strong>“100 goroutines x ~20ms each” on a single core</strong>.</p><p>As GOMAXPROCS increases to 2 and 4, the total runtime drops roughly in half each time. Work that used to be done serially on one core is now spread across multiple cores. Several goroutines are literally executing <em>at the same instant</em>.</p><p>Why does this look so different from the <strong>concurrency without parallelism </strong>example?</p><p>Because this workload is <strong>purely CPU-bound</strong>:</p><ul><li>Each goroutine runs a busy loop that does nothing but crunch cycles for ~20ms.</li><li>There is almost <strong>no waiting</strong> on I/O or timers to overlap.</li><li>Concurrency (100 goroutines) by itself doesn’t make it faster; with GOMAXPROCS=1, they’re just taking turns on a single core.</li><li>Only when we let Go use multiple cores does parallelism kick in and reduce wall-clock time.</li></ul><p>Now concurrency and parallelism are aligned: lots of goroutines <em>and</em> multiple cores working at once.</p><p>With that all being said…</p><h3>Before you “just add more goroutines”</h3><p>Let’s circle back to where we started: that quiet misunderstanding that gives you a system that feels fine in a controlled dev box and then falls over in production.</p><p>A goroutine <em>looks</em> like parallel work. It <strong>is</strong> concurrent work. It’s how Go lets you add concurrency cheaply. But whether it <em>helps</em> depends on what’s really going on under the hood.</p><p>Adding more concurrency does <strong>not</strong> automatically give you more parallelism, and it definitely does <strong>not</strong> automatically give you more throughput.</p><p>Here’s the mental checklist I try to run before I reach for more goroutines.</p><p><strong>1. What’s the actual bottleneck?</strong></p><ul><li><strong>Mostly waiting?</strong><br>Network calls, disk, message queues, timers? You’re probably <strong>I/O-bound.</strong> Concurrency will help you overlap waits.</li><li><strong>Mostly computing?</strong><br>Crypto, compression, scoring models, data crunching? You’re <strong>CPU-bound</strong>. You need <strong>parallelism </strong>to go faster.</li><li><strong>Mostly external limits?</strong><br>DB connection caps, API rate limits, queue throughput? You’re <strong>resource-bound</strong>. More goroutines just mean more things waiting in line.</li></ul><p><strong>2. Are you adding concurrency or just adding contention?</strong></p><p>Goroutines are great at:</p><ul><li>Overlapping waits (HTTP, DB, queues)</li><li>Fanning out work and fanning in results</li><li>Keeping services responsive under moderate load</li></ul><p>They’re terrible at:</p><ul><li>Magically speeding up a single hot loop that can’t be split</li><li>Hiding a saturated database or a slow third-party API</li><li>Fixing bad algorithms or N² queries</li></ul><p>If every goroutine hits the same DB shard or the same external API at once, you just build a coordinated stampede.</p><p><strong>3. Do you have the right amount of parallelism?</strong></p><p>Two quick rules of thumb:</p><ul><li>For <strong>I/O-bound</strong> code: <br>- Focus on <em>enough</em> goroutines to keep your in-flight I/O busy. <br>- Parallelism (GOMAXPROCS) doesn’t matter much until CPU usage starts to climb.</li><li>For <strong>CPU-bound</strong> code:<br>- Start with “number of cores” as an upper bound for “how many things should crunch CPU at once.”<br>- Benchmark different GOMAXPROCS values. Stop when the curve flattens.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72191346b64b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Best JIRA Tickets Are Incomplete]]></title>
            <link>https://medium.com/@artkx/the-best-jira-tickets-are-incomplete-e0f151868cb8?source=rss-b9d19ed7cb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0f151868cb8</guid>
            <category><![CDATA[jira]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Anthony Ricardo Thiotanry]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 12:30:34 GMT</pubDate>
            <atom:updated>2025-07-31T12:30:34.709Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Yes, the perfect JIRA ticket exists. No, it’s not a 500-line checklist.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_0GOALytzf0YCGqU" /></figure><blockquote><em>Throughout this article, I’ll refer to “JIRA tickets” as shorthand for any structured unit of work, whether your team calls them tasks, issues, or cards.</em></blockquote><p>If you’re reading this, chances are you’ve encountered JIRA tickets that felt like riddles scribbled down by drunk product managers. Or maybe you’ve faced a monstrous wall of text so dense you considered abandoning engineering to herd sheep in New Zealand. And if we’re being honest, you’ve probably inflicted similar pain on someone else.</p><p>We all crave that elusive “perfect” JIRA ticket. But what is perfect, exactly?</p><h3>Misconceptions of Perfection</h3><p>I’ve worked with JIRA tickets in just about every flavor: the cryptic one-liner, the thousand-line saga, the ticket-within-a-ticket nesting doll. In a few short years in software, I’ve been both the engineer begging for a card so complete I’d never have to ask a single question, and the manager hoping for specs, estimates, and acceptance criteria so crisp they’d drop clean into a Gantt chart.</p><p>Both of those instincts are wrong.</p><p>The assumption that perfection equals completeness is the first problem. That if we stuff the ticket with enough words, enough bullet points, enough screenshots and test cases, it will become self-evident and foolproof. But exhaustive detail doesn’t guarantee clarity. Not because we’re bad at writing them, but because work is rarely static. People interpret differently, business needs shift, and technical constraints evolve. Last week’s certainties became obsolete overnight because someone next door deployed something unexpected.</p><h3>Card-Taker vs Problem Solver</h3><p>Once, as a lead of five engineers, I assigned a meticulously crafted ticket to an engineer fresh into the team. I had outlined everything — requirements, acceptance criteria, even implementation suggestions — down to the smallest detail. My intention was to help him succeed. I knew he wouldn’t have the same institutional knowledge or architectural familiarity as a seasoned engineer, so I tried to bridge the gap with clarity and structure.</p><p>But I went too far.</p><p>In trying to make it foolproof, I made it thought-proof.</p><p>He followed the ticket exactly. He didn’t question a thing because I had implicitly told him not to. My over-specification signaled: <em>“This is the right way. Just do it.”</em> So he did.</p><p>And then a bug slipped through. A recently added feature, unaccounted for in my design, clashed with the implementation. He didn’t flag it because, in his mind, I had already done the thinking. My ticket was “perfect.”</p><p>That’s when I realized, I had built him a cage instead of a task.</p><p>Such scenarios feed a toxic cycle, transforming brilliant problem solvers into passive ticket-takers. Engineers conditioned this way become hesitant to challenge assumptions, probe deeper, or suggest improvements. Worse, it encourages managers to believe they can predict every technical hurdle.</p><p>I would know, I’ve been on both sides of the aisle.</p><h3><strong>It Is Perfectly Normal To Be Imperfect</strong></h3><p>Product Managers aren’t omniscient. Their role is to articulate business needs clearly, not prescribe how to implement solutions. When a role, distant from the codebase, starts dictating database schema or caching strategy, it stops being product thinking and starts becoming architectural hubris.</p><p>Likewise, engineers aren’t just keyboard operators. A capable engineer creates clarity instead of waiting for it to fall on their lap. Ask uncomfortable questions, poke holes in assumptions, and see places where a beautifully imagined product flow will crumble under real-world edge cases or performance constraints.</p><p>Even when both roles are played well, the first iteration rarely lands perfectly. Most tickets don’t survive contact with the codebase without a follow-up. And that is fine, that is not a failure, that is collaboration.</p><h3>So What Is A Perfect Ticket?</h3><p>No, it’s not a skeletal ticket with a cryptic one-liner forgotten a week later. Nor is it a mini-wiki page drowning in theoretical designs.</p><p>A genuinely perfect JIRA ticket is strategically incomplete. It’s clear about goals but leaves methods open-ended. It points you in the right direction without dictating the exact path.</p><p>It must demand engagement. It must spark dialogue, invite collaboration, and drive exploration.</p><p>Here, ambiguity, when done right, becomes your ally. Great tickets prompt questions: asking why, not merely what; probing limitations; discovering hidden risks before they escalate.</p><p>Then the magic happens in the questions prompted. The perfect ticket doesn’t say “Do this exactly,” but rather “Here’s the problem, let’s solve it.”</p><h3>How to Write a Perfectly Imperfect JIRA Ticket</h3><ul><li><strong>Start with Why:</strong> Clearly articulate the business goal or problem you’re solving. This aligns everyone’s understanding from the start.</li><li><strong>Give Just Enough Context:</strong> Provide relevant background, existing constraints, and historical context without overwhelming detail.</li><li><strong>Explicitly Call Out Unknowns:</strong> Clearly state what’s uncertain or needs further investigation, so engineers know exactly what gaps to explore.</li><li><strong>Invite Dialogue:</strong> Pose open-ended questions or explicitly encourage feedback to make collaboration inevitable.</li><li><strong>Avoid Implementation Dictates:</strong> Guide without prescribing exact solutions, allowing engineers space to innovate and own their approach.</li></ul><p>Embrace imperfection strategically. Perfectly imperfect tickets are intentionally incomplete, designed to foster deeper understanding and genuine problem-solving.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0f151868cb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Real Cost of Skipping Observability: Why Moving Fast Without Visibility Breaks Engineering…]]></title>
            <link>https://medium.com/@artkx/youre-not-moving-fast-you-re-skipping-steps-942162f88888?source=rss-b9d19ed7cb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/942162f88888</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Anthony Ricardo Thiotanry]]></dc:creator>
            <pubDate>Fri, 23 May 2025 14:40:29 GMT</pubDate>
            <atom:updated>2025-05-28T03:15:07.841Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Real Cost of Skipping Observability: Why Moving Fast Without Visibility Breaks Engineering Teams</h3><blockquote>When speed outruns visibility, disaster follows quietly.</blockquote><p>A town dreamed of a magnificent bridge. A marvel of modern engineering that would fuel growth, commerce, and prosperity. So they set ambitious deadlines and secured abundant funding.</p><p>The engineers got to work. Foundations poured, steel laid, features quickly followed. Stylish road signs went up. Automated toll booths were installed. Bright lights dazzled nighttime travelers.</p><p>But structural sensors and load monitors weren’t exciting, so they were pushed aside. Those could come later, everyone thought.</p><p>Initially, things looked perfect. Traffic flowed smoothly. Investors applauded each milestone.</p><p>Then one day, without warning, the bridge strained under stress it was never built to handle. No alerts sounded. No sensors warned the engineers. The problem went unnoticed until concrete cracked and steel buckled. Suddenly, panic ensued. Long nights of frantic investigation and patching followed.</p><h3>The Allure of Speed</h3><p>There is an irresistible thrill in fast releases.</p><p>New features roll out, demos impress stakeholders, and the sense of momentum feels great. Your team ships four feature updates in two days. Everyone cheers and celebrates progress.</p><p>But there’s another side to this story. A quiet, often invisible part where telemetry is sparse, logs go unread, and no one notices (or pretends not to) the absence of meaningful signals until something breaks. The system runs smoothly, right up until it does not.</p><p>It’s a pattern that many fall into. The faster you seem to move, the easier it is to overlook what is essential.</p><p>Modern development principles often get twisted. “Fail fast, learn fast” does not mean skipping critical steps. It means building a system that quickly reveals their weaknesses safely and clearly. Agile, Lean, and DevOps methodologies all stress the importance of continuous feedback and early problem detection.</p><p>Yet, somewhere along the way, feedback became shorthand for toggling features, and experimentation turned into cutting corners. Teams forgot that fast learning requires visibility. You can’t learn what you can’t see.</p><h3>The Hero We Should Not Need</h3><p>Let’s get one thing straight: moving fast is not the same as skipping steps.</p><p>There is a pervasive illusion in product and engineering culture that visible progress equals meaningful progress. Features make noise. Monitoring does not. Nobody claps for a well-tuned alert.</p><p>When systems explode and the root cause is something preventable, we often fail to ask the harder question: Why wasn’t this caught sooner? Instead, we default to firefighting, and the cycle repeats.</p><p>Worse still, teams often try to catch up <em>after </em>the fire. They retroactively bolt on dashboards. They write postmortems. They pledge to do better. But then the next feature sprint begins, and guess what gets pushed back? Again.</p><p>In many engineering teams, there is an unspoken hero culture. A tendency to celebrate those who leap into action during outages, apply hotfixes, and bring systems back from the brink.</p><p>These individuals deserve recognition. Responsiveness under pressure is a valuable trait.</p><p>But this becomes toxic when those heroic acts are only necessary because the system lacked observability to begin with. When those conditions are left unexamined —or worse, become normalized — we begin to reward failure recovery and ignore failure prevention.</p><p>Firefighting becomes the norm. Overtime hotfixes are seen as noble, while proactive stability work is seen as overhead. We glorify recovery instead of resilience. Instrumentation, telemetry, and traceability fade into the background because the spotlight remains fixed on those who <em>fix</em>, not those who <em>fortify</em>.</p><p>In the end, we nurture a reactive team that is rewarded for urgency instead of foresight. Hero culture, in this context, doesn’t just emerge from the absence of stability practices. It actively reinforces their neglect. The more we glorify reactive heroics, the more we normalize a lack of foresight.</p><p>We end up building systems that wait to fail before they get attention. Instead of cultivating a culture of prevention, we celebrate survival.</p><h3>The Real Cost of Skipping Steps</h3><p>Without observability, you don’t know something’s broken until users scream. Precious time is wasted figuring out what broke, where, and why. Without logs, there’s no audit trail. Without metrics, performance regressions go unnoticed. Without traces, inter-service delays remain hidden.</p><p>Lack of observability doesn’t just degrade operational response. It weakens anomaly detection, masks security incidents (like logins from suspicious IPs or stealthy data exfiltration), and leaves engineering teams navigating blind.</p><p>We’ve seen the cost paid in practice. Consider <a href="https://slack.engineering/slacks-outage-on-january-4th-2021/"><strong>Slack’s January 2021 outage</strong></a><strong>.</strong> Granted, they had observability in place, but in this instance, the signals failed to surface the degradation early. Engineers were left investigating blind, forced to uncover root causes manually under pressure. It’s a clear example of how even a well-instrumented system can falter without precise, actionable visibility.</p><p>Or look at Knight Capital in 2012. A simple deployment oversight triggered errant trades totaling $440 million in losses (within 45 minutes). According to a <a href="https://www.henricodolfing.com/2019/06/project-failure-case-study-knight-capital.html"><strong>case study</strong></a>: The firm lacked automation and real-time monitoring to detect the problem fast enough.</p><p>Without insight into system performance, teams either overprovision to be safe or underprovision and crash under load. Neither is sustainable.</p><p>The human cost follows quickly. Increased on-call load, slower feature delivery, and rising attrition from burnout. Engineers become stuck in reactive mode, constantly solving problems they didn’t see coming.</p><h3>Going Slow to Go Fast</h3><p>All of this leads to one simple truth: <strong>sustainable speed comes from deliberate systems.</strong></p><p>True velocity requires clarity. That means building in visibility, investing in instrumentation, and treating observability as a first-class citizen of your architecture rather than an afterthought.</p><p>What looks like slowness is actually <em>intentionality</em>. You document not because it’s exciting, but because it saves hours later. You instrument not because things are broken, but to catch them before they are. You test not for today, but to protect tomorrow.</p><p>Moving fast isn’t the issue. Moving blindly is. If you can’t see your system, you can’t trust your speed.</p><p>If you’re an engineer, ask: Do you truly understand how your system behaves in production? If you’re a manager or stakeholder, ask yourself: Are you creating space for teams to build observability into the process or just rewarding delivery at all costs?</p><p>We cannot demand reliability while refusing to invest in visibility. Observability is both a backend detail and a leadership decision. One that signals whether your team is building for speed or building to last.</p><p>Lay down your tracks before the train arrives. Watch your bridges before the traffic crosses. And if you feel like you’re moving a bit slowly, you’re probably doing exactly the right thing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=942162f88888" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leverage Caching To Cushion Our Database]]></title>
            <link>https://medium.com/julotech/leverage-caching-to-cushion-our-database-985d28d2bf45?source=rss-b9d19ed7cb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/985d28d2bf45</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[caching]]></category>
            <dc:creator><![CDATA[Anthony Ricardo Thiotanry]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 05:50:28 GMT</pubDate>
            <atom:updated>2022-11-03T05:50:28.068Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How proper caching implementation can alleviate the strain on database. Co-authored with </em><a href="https://medium.com/u/834340d146f5"><em>Fathur Rohman</em></a><em>.</em></p><p>Fetching and serving information around the web demands resources in the form of processing power and processing time. The bigger the data, the more expensive it costs, and the number increases the more users flock to your services. As the services attract more users, we must scale the system all the while maintaining its normal operation. For many startups, the expanding user base often means logical operations and queries that used to look passable will have to undergo changes to be more optimal. But there’s only so much you can do on code before teams find themselves worrying over micro-optimization and start a race of premature optimization, plus it takes a gigantic amount of effort to even evaluate where we should begin optimization out of the many services already released.</p><p>Facing similar problems, our engineers at <a href="https://www.julo.co.id/"><strong>JULO</strong></a> concluded that a caching strategy would allow us to alleviate strain in our database while simultaneously serving data faster. In this post, we detail our journey on initiating data caching to increase our capacity while reducing strain on the database.</p><p>What is caching? Assume that there’s a book that you want to read in the library, rather than going to the library every time you want to read it you’d probably borrow the book and keep it on your shelf instead. Now you won’t have to waste transportation fees and commuting time revisiting the library. In this analogy, the library would be the database and the shelf is the cache. Simply put, caching stores frequently requested items closer to people who want them, thus increasing access speed and reducing expended resources.</p><h3>Motivation</h3><p>A brief overview of our tech stack to get you on board. JULO’s API layer consists of Python, <a href="https://www.djangoproject.com/">Django</a>, and <a href="https://www.django-rest-framework.org/">Django Rest Framework</a>, along with that and our database layer relies on Django ORM and <a href="https://www.postgresql.org/">PostgreSQL</a>. For this initiative, we rely on two monitoring tools: <a href="https://www.datadoghq.com/">Datadog</a> and <a href="https://grafana.com/">Grafana</a>.</p><p>In JULO, we develop services that are actively used by millions of users including our internal team such as customer service and collection team. As our application grew, we began experiencing spiking latency and throttled database pools to the point where even our team felt the slowness. Using Datadog as our monitoring tool, we can see roughly over 3 trillion requests are served every month. One of the tables has consistently hit around 266 million fetch requests, accounting for almost 9% of the whole SQL queries in our database layer. Further investigation revealed around 32 million update requests, making the entire table take up 12% of the requests in a given month.</p><p>Now, here’s an idea, what if we refactor the entire codebase? We can filter our services and sort them by highest request in a month through Datadog, then we can start analysing which services cost the most, after that, we can begin dissecting the business flow and draw some sort of brain map to see the interconnected functions and processes, finally, we can slowly and methodically optimise every code starting from the top. Sure, we can do that. Or… We can start with something simpler and cost-efficient.</p><h3>Caching</h3><p>To solve our issue, we needed a way to increase capacity by processing the data faster. Upgrading the database is a band-aid solution that costs more than it’s worth and it doesn’t address the underlying issue. Going through the whole process of dissecting codes and business flow feels like a theoretically sound idea but it costs too much, takes too much time, and is prone to creating new bugs. We could also incrementally improve existing code, sounds more doable but still takes forever. We were looking for a simpler and cheaper solution and we needed it fast. So we turned to our old friend: caching.</p><p>Caching has been part of our ecosystem for so long but was never wholly harnessed so we set our sight on its untapped potential. The idea was to see if we could relieve pressure on our database due to the high number of queries. A lot of the queries were accessing the same data, so surely we could reduce recomputing the same result. We knew we needed an in-memory data store system for this, so we had to choose between <a href="https://memcached.org/">Memcached</a> and <a href="http://redis.io/">Redis</a>. While both systems store data in memory for fast retrieval, we favoured Redis because it stores data as specific data types while Memcached stores data as string. With how often data updates in our application, the network overhead reduction was very welcomed.</p><p>Next, we had to decide how we would integrate the caching system with our project. Django provides Redis support to its caching system that was made available on version 4.0 but our Django runs on an older version so that was not available to us. Reinventing the wheel didn’t make sense so we looked into open source libraries. One of our engineers initiated the usage of <a href="https://github.com/Suor/django-cacheops">django-cacheops library</a>. The library, also known as Cacheops, fits us like gloves as it was made for Redis and caches Django’s ORM.</p><p>Now that all the pieces are in place, we can start working on implementation. Being on the cautious side, we divided the process into two phases where each phase would have to go through a monitoring period in staging and UAT environment:</p><ol><li>In the first phase, we chose a table with large queries that was mostly safe from complications (writes or updates). The table was widely used across our services but remained quite isolated from any complications due to its simplicity. The TTL targeted for this table was 2 weeks.</li><li>The second phase would then involve our most query intensive table that serves over 12% queries in a month. This table is interconnected with many parts of our applications. It has hundreds of thousands of updates in a day so we settled on 30 seconds TTL.</li></ol><p>Each phase went through queries check on datadog and our codebase, making sure there were no stones unturned (or in this case, queries unturned).</p><h3>Cache Invalidation</h3><p>Caching is easy but what about cache invalidation? That happens to be one of the hardest problems in computer science. It is important that the data in cache gets invalidated as soon as underlying storage changes. There was concern that if not handled well, this could get us into a situation where the data retrieved from our cache layer were stale, and potentially break our business processes.</p><p>When you forget to import the module you’re using in python, at least the compiler will throw an error. In caching, failing to invalidate stale data can accumulate issues silently. It’s difficult to track down because the program still works as intended, only it’s processing the wrong data. When invalidation is done wrong, even the most trivial bug becomes fiendishly difficult to discover.</p><p>Django provides two methods to update data:</p><ul><li>.save() method is used to write a new record or update an existing record of a model instance</li><li>.update() method is used on a queryset object that can update multiple data.</li></ul><p>The package works as we wanted when using the .save() method, however, it behaves unexpectedly with the .update() method. Quoting the <a href="https://docs.djangoproject.com/en/4.1/topics/db/queries/#updating-multiple-objects-at-once">Django’s documentation</a> itself:</p><blockquote><strong>the update() method is converted directly to an SQL statement. It is a bulk operation for direct updates. It doesn’t run any save() methods on your models, or emit the pre_save or post_save signals.</strong></blockquote><p>Django has a signal dispatcher that notifies applications when an action occurs elsewhere within the framework. This signal dispatcher allows us to send signals when an event is triggered so we can prehandle and posthandle the event. For example, if you want to create a user profile as soon as the user registers, you can create a posthandle receiver that will execute when the user model is saved.</p><p>Cacheops event-based invalidation relies on these signals. Do you see the problem here? There is no way of knowing if a data has been updated when using the .update() method that doesn’t emit any signal. We either have to ban the method entirely from our codebase for every table with caching turned on or invalidate the updated data ourselves. Good news is, the package provides an invalidated_update() method to replace Django’s update() method. Yay! That said, this method comes with one additional query cost that we deem a cheap price to pay (+1 query is nothing if you think about the percentage of queries we’ll shave off).</p><h3>The Result?</h3><p>The first phase deployment to production was on 29th September 2022. Using Grafana, you can see the comparison of our database CPU load between one week before caching and the week after. The CPU usage decreases by a whooping 4.7% on average. At the same time Datadog shows reduction from around 100,000 SQL queries per hour to less than 5,000 queries per hour. What a huge improvement, isn’t it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*R9E86SHyw7ONIIB2" /><figcaption>Database CPU load from 21–09–2022 to 29–09–2022 (before phase 1 deployment)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/0*xVqyzi4OQX4ilaP5" /><figcaption>Database CPU load from 29–09–2022 to 07–10–2022 (after phase 1 deployment)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/0*bt9nrjXASb4-1Dvg" /><figcaption>Query requests huge improvement after 20:00 of 29th September</figcaption></figure><p>Finally, we deployed the second phase to production on the evening of 27th October 2022. As you can see, within three days after deployment the caching further reduces the database CPU load to 8.89% on average. We also see a reduction in the frequency of SQL queries by roughly 50%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/0*WlhLH7XNEnjfCA77" /><figcaption>Database CPU load from 27–10–2022 to 31–10–2022 (after phase 2 deployment)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*sOGUV49z2hlHzu0E" /><figcaption>Query requests reduction after evening of 27th October 2022</figcaption></figure><h3>Takeaways</h3><p>As you can see, caching can be a very simple and effective strategy to scale your database by using fast caching system like Redis or Memcached but the application of caching should be carefully approached:</p><ul><li>Choosing what to be cached: If the cache hit ratio is not high enough (fast changing data) then caching may not be effective on such data.</li><li>Choosing appropriate TTL: Time to live is to be chosen carefully so as to decrease the chances of applications processing stale data. This can be mitigated if your framework or code ensures invalidation as soon as the update is done in the underlying storage (as pointed above in the post, this is easier said done in some edge case scenarios. Hint: “distributed systems are hard”).</li><li>Cache invalidation: If possible, ensure code which invalidates the cache on the data update. Invalidation is simply dropping the corresponding cache key so as the next query for this data hits the DB following a cache-miss and recaching can be done. If not handled, then you will be dependent on cache expiry (TTL) for the invalidation which may lead to nasty issues hard to debug.</li></ul><p>Hope you find this useful. Please drop your endeavours, learnings or suggestions on caching.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=985d28d2bf45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/julotech/leverage-caching-to-cushion-our-database-985d28d2bf45">Leverage Caching To Cushion Our Database</a> was originally published in <a href="https://medium.com/julotech">julotech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>