<?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 Precious Agoma on Medium]]></title>
        <description><![CDATA[Stories by Precious Agoma on Medium]]></description>
        <link>https://medium.com/@tobiprecious13?source=rss-bee401eaa1a7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GG1IlteiFAaTyID9.jpg</url>
            <title>Stories by Precious Agoma on Medium</title>
            <link>https://medium.com/@tobiprecious13?source=rss-bee401eaa1a7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:54:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tobiprecious13/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[Building Trust in a Real-Time Marketplace: How We Eliminated Race Conditions in ClusterSub]]></title>
            <link>https://medium.com/@tobiprecious13/building-trust-in-a-real-time-marketplace-how-we-eliminated-race-conditions-in-clustersub-a10d811445d3?source=rss-bee401eaa1a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a10d811445d3</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[desystems]]></category>
            <dc:creator><![CDATA[Precious Agoma]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 15:15:09 GMT</pubDate>
            <atom:updated>2026-07-16T15:16:33.033Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_UY026MrvxJ7jXA2RYDWLA.png" /></figure><p>One of the biggest misconceptions about building software is that the hardest problems are usually technical.</p><p>In my experience, they rarely are.</p><p>Most difficult engineering problems begin as human problems.</p><p>When I started building <a href="https://clustersub.com/">ClusterSub</a>, my goal wasn’t to build another subscription platform. I wanted to solve a coordination problem that thousands of people were already dealing with manually.</p><p>Across many African communities, people routinely share subscriptions with friends and family to reduce costs. The behaviour already existed; what didn’t exist was reliable software to coordinate it. Payments were collected manually, reminders were sent over WhatsApp, access was tracked in spreadsheets, and a single missed payment could disrupt everyone else in the group.</p><p>The engineering challenge wasn’t subscriptions.</p><p>It was coordination.</p><p>As the platform grew, one particular problem became increasingly important.</p><p>Imagine a Netflix subscription with one remaining slot.</p><p>Now imagine four people clicking <strong>Join</strong> within milliseconds of one another.</p><p>Without careful coordination, all four requests could succeed.</p><p>One available slot suddenly becomes four new members.</p><p>That single mistake destroys trust in the platform.</p><p>At first glance, the solution seems straightforward.</p><p>Check whether a slot exists before creating the membership.</p><p>Like many engineers, my first instinct looked something like this:</p><pre>$subscription = Subscription::find($id);<br><br>if ($subscription-&gt;available_slots &gt; 0) {<br>    $subscription-&gt;decrement(&#39;available_slots&#39;);<br><br>    ChildSubscription::create(...);<br>}</pre><p>It works perfectly.</p><p>Until multiple users arrive simultaneously.</p><p>The problem is that checking the slot count and reducing it are two completely separate operations. Between those two steps, another request can read exactly the same value.</p><p>Every request believes the last slot is still available.</p><p>This is one of the classic race conditions found in concurrent systems.</p><h3><strong>The Database Wasn’t Enough</strong></h3><p>Our first improvement was introducing pessimistic database locking using Laravel’s lockForUpdate() inside a transaction.</p><p>Instead of allowing several requests to inspect the subscription simultaneously, only one transaction could own that subscription record until the operation completed.</p><p>Every other request waited.</p><p>The race condition disappeared.</p><p>From the database’s perspective, the problem was solved.</p><p>From the user’s perspective, it wasn’t.</p><p>Another user browsing the marketplace could still see one available slot because their browser hadn’t refreshed yet.</p><p>Technically the subscription was already full.</p><p>Visually it wasn’t.</p><p>That gap between reality and perception is where users begin to lose confidence.</p><p>We realised something important.</p><p>The challenge was no longer preventing race conditions.</p><p>The challenge was ensuring everyone experienced the same reality.</p><h3><strong>Keeping Every User in Sync</strong></h3><p>To solve this, we introduced Laravel Reverb for real-time event broadcasting.</p><p>Whenever a slot changed, every connected user viewing that subscription immediately received an update.</p><p>The available slot counter changed instantly.</p><p>Join buttons were disabled automatically when subscriptions became full.</p><p>Instead of waiting for a page refresh, the marketplace reflected reality in real time.</p><p>Interestingly, WebSockets didn’t make the system more correct.</p><p>The database had already done that.</p><p>They made the system more trustworthy.</p><h3><strong>The Problem We Didn’t Expect</strong></h3><p>Even after solving concurrency, another issue appeared.</p><p>A user could click <strong>Join</strong>, complete payment a few seconds later, and discover that someone else had already taken the final slot during the payment process.</p><p>Nothing had gone wrong technically.</p><p>But from the customer’s perspective, they believed they had already secured their place.</p><p>That experience felt broken.</p><p>Rather than thinking about payments first, we began thinking about user intent.</p><p>The moment someone decided to join, the platform temporarily recorded that intention while payment was completed.</p><p>If payment succeeded, the membership became permanent.</p><p>If payment failed or timed out, the reservation expired automatically.</p><p>It was a relatively small architectural change, but it significantly improved the overall experience because the software began reflecting how people naturally expected the process to work.</p><h3>The Bigger Lesson</h3><p>Looking back, none of these solutions were particularly groundbreaking on their own.</p><p>Database transactions already existed.</p><p>WebSockets already existed.</p><p>Temporary reservations already existed.</p><p>The real engineering challenge wasn’t inventing new technology.</p><p>It was recognising that no single technique solved the complete problem.</p><p>Reliable systems are often built by combining several simple ideas into one coherent solution.</p><p>Today, <a href="https://clustersub.com/">ClusterSub</a> has processed thousands of recurring subscription transactions without a single overbooking incident. More importantly, users rarely think about how those guarantees are achieved.</p><p>That, to me, is the best outcome.</p><p>When software quietly coordinates people, payments, and shared resources without users ever noticing the complexity underneath, it has done its job well.</p><h3>Final Thoughts</h3><p>Building <a href="https://clustersub.com/">ClusterSub</a> fundamentally changed how I think about software engineering.</p><p>Earlier in my career, I measured success by writing clean code and delivering features.</p><p>Today, I think much more about designing systems that people can trust.</p><p>Whether the problem involves subscription sharing, government revenue collection, or business messaging infrastructure, the pattern is surprisingly similar.</p><p>Real-world software is rarely just about code.</p><p>It’s about coordinating people, expectations, timing, and information in a way that feels seamless to everyone involved.</p><p>That’s the kind of engineering I enjoy most.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a10d811445d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>