<?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 Hiroyuki Yamada on Medium]]></title>
        <description><![CDATA[Stories by Hiroyuki Yamada on Medium]]></description>
        <link>https://medium.com/@pivotfakie?source=rss-58c84785a684------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*iInHoTvYhsFacpEV.jpg</url>
            <title>Stories by Hiroyuki Yamada on Medium</title>
            <link>https://medium.com/@pivotfakie?source=rss-58c84785a684------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:52:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pivotfakie/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[Stop Solving Microservice Consistency in Your Application Code]]></title>
            <link>https://medium.com/@pivotfakie/stop-solving-microservice-consistency-in-your-application-code-0ceef6eb9adf?source=rss-58c84785a684------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ceef6eb9adf</guid>
            <category><![CDATA[microservice-architecture]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Hiroyuki Yamada]]></dc:creator>
            <pubDate>Thu, 09 Jul 2026 07:18:26 GMT</pubDate>
            <atom:updated>2026-07-09T07:18:26.084Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwy-Picf8tfaZlFBRfd1QQ.png" /><figcaption>Stop Solving Microservice Consistency in Your Application Code</figcaption></figure><p><em>Part 4 of “Architecture in the AI Era,” and the last in the series. (</em><a href="https://medium.com/@pivotfakie/stop-asking-saga-or-2pc-start-asking-what-each-operation-needs-78c1ed163af6"><em>Part 3</em></a><em>: why you compose Saga and two-phase commit per operation, rather than standardizing on one.)</em></p><p>Over the last three pieces, the argument has narrowed to a single question. AI is pushing teams toward microservices (<a href="https://medium.com/@pivotfakie/start-with-a-monolith-was-good-advice-ai-is-changing-that-a2181b8e5ede">Part 1</a>). Splitting a system means consistency across services stops being free (<a href="https://medium.com/@pivotfakie/no-more-free-lunch-for-consistency-across-microservices-f9f7aca9a956">Part 2</a>). You get it back by matching the mechanism to each operation and composing Saga and two-phase commit (<a href="https://medium.com/@pivotfakie/stop-asking-saga-or-2pc-start-asking-what-each-operation-needs-78c1ed163af6">Part 3</a>).</p><p>That settles <em>how</em> you keep data consistent. It leaves the question I’ve been deferring: <em>where</em> that logic should live. And my answer is that the place most teams put it today is the wrong one.</p><h3>Where consistency lives now</h3><p>Open a typical microservices codebase and the machinery for keeping data correct is spread across the application. The retries. The compensating actions that undo a half-finished workflow. The careful ordering of steps so a failure leaves things recoverable. The judgment calls about what’s safe to read while another operation is in flight.</p><p>None of this is business logic. It’s plumbing — distributed-systems plumbing — written by hand, in the application layer, by people who’d rather be building features. And it’s some of the most error-prone code in the system, because the failure cases are exactly the ones that don’t show up in a quick test: the crash between two steps, the message that arrives twice, the read that lands in the half-second window before a compensation runs.</p><p>For many teams, this is just where the problem ended up. You split the system, you inherited the consistency problem, and the application layer was the path of least resistance for dealing with it.</p><h3>Why that’s the wrong layer now</h3><p>Two things have changed that make the application layer a worse home for this than it used to be.</p><p>The first is the argument from Part 1: AI is writing a growing share of that application code. An agent generating a service will handle plenty of the consistency concerns — it produces retries, fallbacks, and plausible failure handling. But it isn’t perfect, and with distributed consistency, the gaps it leaves are subtle and easy to miss. The code mostly works. Closing the distance between “mostly” and “correct” takes human review.</p><p>And that’s the catch. Reviewing distributed consistency — knowing whether a given set of commits and failures is actually safe — is specialist knowledge, not what most application engineers do day to day. So the gaps often go unclosed, not through carelessness, but because the people closest to the code aren’t equipped to spot them. AI sharpens the problem by producing far more plausible-looking code, far faster than anyone can carefully check. The more of your application layer is machine-written, the less you want your correctness guarantees living in it.</p><p>The second is simpler: it was never a good place for it. Consistency is a systemic property. When the logic that enforces it is scattered across dozens of independently developed, independently deployed services, no single place is responsible for it, and no single change can be reasoned about in isolation. That’s the opposite of what you want from a guarantee.</p><h3>The shift: consistency as a property of the infrastructure</h3><p>The alternative is to stop treating consistency as something each service is left to re-implement, and start treating it as something the infrastructure provides.</p><p>In that model, the application says <em>what</em> it wants to happen — reserve this, charge that, do it as one atomic unit, or run this as a long compensable flow — and the layer beneath it is responsible for making those guarantees hold. The composition of Saga and two-phase commit from Part 3 lives there, not in hand-written application code. The retries, the ordering, the recovery, the isolation: handled below the line, once, correctly, instead of in every service, by hand, again and again.</p><p>The idea isn’t new — some systems already handle parts of this below the application layer. It just isn’t the default yet.</p><p>This is the same move the industry already made for storage, for networking, for orchestration. We stopped hand-rolling those in application code and pushed them into infrastructure that does them properly. Data consistency across services is overdue for the same treatment — and in an era where the application layer is increasingly written by AI that won’t reason about any of it, “overdue” is starting to mean “urgent.”</p><h3>Closing the loop</h3><p>Pull the four parts together and the through-line is simple. The AI era rewards moving fast, which pushes you toward microservices. Microservices hand you a consistency problem that’s a genuine business risk, not a technical footnote. That problem is solvable — Saga and two-phase commit, composed per operation, with two-phase commit reconsidered free of its XA-era reputation. And the durable way to solve it is to lift it out of application code and make it a property of the platform underneath, so that correctness doesn’t depend on every service — or every AI agent — getting the hard parts right by hand.</p><p>This is the problem my team at <a href="https://scalar-labs.com/">Scalar</a> works on. If it’s one you’re wrestling with, I’m glad to compare notes — and the comments below are a good place to start.</p><p>Across the whole series: where does consistency live in your systems today — scattered through application code, or handled by something underneath it? And has the rise of AI-written code changed how comfortable you are with the answer?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ceef6eb9adf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Asking “Saga or 2PC.” Start Asking What Each Operation Needs.]]></title>
            <link>https://medium.com/@pivotfakie/stop-asking-saga-or-2pc-start-asking-what-each-operation-needs-78c1ed163af6?source=rss-58c84785a684------2</link>
            <guid isPermaLink="false">https://medium.com/p/78c1ed163af6</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Hiroyuki Yamada]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 03:14:22 GMT</pubDate>
            <atom:updated>2026-07-03T03:14:22.365Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*to_5UodjfgMiBCcOWFimcw.png" /></figure><p><em>Part 3 of “Architecture in the AI Era.” (</em><a href="https://medium.com/@pivotfakie/no-more-free-lunch-for-consistency-across-microservices-f9f7aca9a956"><em>Part 2:</em></a><em> why keeping data consistent across microservices stops being free — and why the usual Saga-vs-2PC advice gets both sides wrong.)</em></p><p>In the last piece I argued that the two standard ways to keep data consistent across services — Saga and two-phase commit — are usually framed as rivals, and that the framing gets both wrong. Saga is oversold by waving away its loss of isolation. Two-phase commit is dismissed on the strength of one aging implementation.</p><p>If both are misjudged, then “which one should we use” is the wrong argument to be having. The better question is narrower: what does <em>this</em> operation actually require?</p><h3>Decide per operation, not per system</h3><p>Most teams pick one approach and apply it everywhere. That’s the mistake. A real system doesn’t have one kind of operation — it has several, with different requirements.</p><p>Some operations need the strong guarantee. Moving money between accounts, committing inventory against an order, anything where another transaction must not see a half-finished state — these need atomicity and isolation across services. That’s the territory of two-phase coordination.</p><p>Others can’t have it, or shouldn’t pay for it. A workflow that runs for minutes, waits on a human approval, or calls an external system you don’t control can’t hold a transaction open across all of it. There, a saga — local steps with compensations — is the right tool, and the loss of isolation is a deliberate, acceptable trade.</p><p>The choice isn’t ideological. It’s per operation: match the mechanism to what the work needs.</p><h3>The answer is usually “both”</h3><p>Follow that logic and you stop choosing between Saga and 2PC at the system level — because a single system, sometimes a single workflow, needs both.</p><p>Picture an order. Reserving inventory and capturing payment is the part that has to be all-or-nothing and isolated: two-phase commit. Around it sits a longer flow — fraud checks, shipment scheduling, notifications, an external payment provider — that runs over time and reaches outside your walls: a saga. A strong-consistency core, wrapped in a longer, looser orchestration. They aren’t alternatives. They compose.</p><p>Which is why having only one of them in your toolkit is a real constraint. If all you have is Saga, you give up isolation even on the operations that genuinely need it, and you patch over the gap with application code. If all you have is 2PC, you can’t model the long-running, outward-facing flows that make up much of real business logic. The useful position is to have both available on common ground, and to apply each where it fits.</p><h3>Which means putting 2PC back on the table</h3><p>The reason teams don’t work this way today is the belief that two-phase commit is off-limits — that it’s locked to specific databases, fragile, and slow. As I argued last time, that reputation belongs to XA, a specific decades-old implementation, not to two-phase coordination as an idea.</p><p>Modern implementations of the same idea reconcile what XA couldn’t. They keep strong consistency across services without depending on database-specific transaction features, so they aren’t confined to a single vendor’s database. They manage the coordinator’s state through a consensus-based, replicated mechanism, so a single failed process is no longer a single point of failure. And distributed transaction technology has come a long way in thirty years: a wide range of optimizations, from parallelizing coordination to protocol-level improvements, are available now that simply weren’t part of the XA-era picture. The protocol was never the real bottleneck.</p><p>Once 2PC is a usable tool again rather than a cautionary tale, “pick the right one per operation, and compose them” becomes something you can actually do — instead of reaching for Saga everywhere because the alternative was ruled out years ago.</p><h3>The question that’s left</h3><p>Deciding per operation, and composing Saga and 2PC, settles <em>how</em> you keep data consistent. It leaves a different question untouched: <em>where</em> that machinery should live.</p><p>Today, most of it lives in application code — the retries, the compensations, the careful ordering, the reasoning about what’s safe to read and when. That’s a great deal of subtle, easy-to-get-wrong logic to carry in the application layer. And it’s precisely the layer that, as I argued in <a href="https://www.linkedin.com/pulse/start-monolith-good-advice-ai-changing-hiroyuki-yamada-ou58c/">Part 1</a>, AI is increasingly writing — without reasoning about any of these guarantees on your behalf.</p><p>So the real question isn’t only which mechanism per operation. It’s whether keeping data correct should be the application’s job at all.</p><p>That’s what I’ll take on to close the series.</p><p>If you run a system with both kinds of operations — the must-be-isolated core and the long-running flows around it — how are you handling the split today: one approach stretched over everything, or two separate stacks bolted together?</p><p><em>← </em><a href="https://medium.com/@pivotfakie/no-more-free-lunch-for-consistency-across-microservices-f9f7aca9a956"><em>Part 2: No More Free Lunch for Consistency Across Microservices.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78c1ed163af6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No More Free Lunch for Consistency Across Microservices]]></title>
            <link>https://medium.com/@pivotfakie/no-more-free-lunch-for-consistency-across-microservices-f9f7aca9a956?source=rss-58c84785a684------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9f7aca9a956</guid>
            <category><![CDATA[microservice-architecture]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Hiroyuki Yamada]]></dc:creator>
            <pubDate>Thu, 25 Jun 2026 13:31:46 GMT</pubDate>
            <atom:updated>2026-06-25T13:31:46.739Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtGAWESzGWWDMq8GSDoUIA.png" /></figure><p><em>Part 2 of “Architecture in the AI Era.” (</em><a href="https://medium.com/@pivotfakie/start-with-a-monolith-was-good-advice-ai-is-changing-that-a2181b8e5ede"><em>Part 1 </em></a><em>made the case that AI is reshaping when to split a system into microservices.)</em></p><p>IInside a single database, consistency is a free lunch. A transaction either commits in full or not at all, and while it’s running, no one sees it half-done. You almost never think about it, because you never have to ask for it.</p><p>Split that transaction across several services — each with its own database — and the lunch stops being free. The guarantee was a property of the single database doing the work. Take the work apart, and the guarantee doesn’t come with it. This is the bill that comes with microservices.</p><p>Nothing about this failure is loud. Nothing crashes; the system keeps responding. The data just quietly stops agreeing with itself.</p><h3>The guarantee you stop getting for free</h3><p>An order that reserves inventory, charges a card, and schedules a shipment used to be one transaction. Across services, it’s three local commits in three systems, each succeeding or failing on its own.</p><p>So you inherit failure modes that simply couldn’t occur before. The charge succeeds but the shipment never gets scheduled. Inventory is reserved against an order that the payment step then rejects. A second request reads a state that’s true in one service and not yet true in another, and makes a decision on it. None of these are bugs in the usual sense — no line of code is wrong. They’re the direct consequence of having taken apart the thing that used to guarantee they couldn’t happen.</p><p>This is the real cost of the move, and it’s the one teams most often discover in production rather than in design.</p><h3>Two standard answers — and two oversimplifications</h3><p>There are two well-known ways to deal with this. The industry tends to recommend one and dismiss the other, and both halves of that advice are too simple.</p><p>Saga. Run the operation as a sequence of local steps, each committed by its own service, and if a later step fails, issue compensating actions to undo the earlier ones. It’s a good fit for long-running work and for steps that reach out to external systems or wait on a human. It’s also the approach most people now reach for by default.</p><p>What the default reaching-for tends to skip over: a saga gives up isolation. Because each step commits on its own, its result is visible to everyone else before the overall operation finishes — or before a later failure rolls it back. Another transaction can read a state that’s about to be compensated away, or two operations can step on the same record and lose one of the updates. These aren’t implementation defects you can engineer out with enough care. They’re structural to the pattern. For plenty of workflows that’s an acceptable trade. The mistake is not noticing you’ve made it.</p><p>Two-phase commit. Coordinate the participants in two phases — first everyone confirms they <em>can</em> commit, then everyone commits together — so the operation is atomic across services, with the in-between hidden. This is the approach a lot of engineers have been taught to avoid: “2PC is slow, it blocks, it’s a single point of failure, it doesn’t scale.”</p><p>Here’s the part worth slowing down on. Almost every one of those criticisms is aimed at XA — a specific, decades-old implementation of distributed transactions — not at the underlying idea of two-phase coordination. Blocking when the coordinator dies, the single point of failure, the requirement that every participant be an XA-compatible resource: those are properties of <em>that</em> design. They’re not laws of nature. Modern, consensus-based implementations of the same two-phase idea address most of them. Dismissing the concept because the 2003 implementation aged badly is its own kind of oversimplification.</p><h3>The debate is framed wrong</h3><p>So the common framing — <em>use Saga, avoid 2PC</em> — gets both sides wrong in opposite directions. It overstates Saga by waving away a real loss of isolation, and it understates two-phase approaches by judging the idea on the basis of one old implementation.</p><p>Neither is universally right, because they aren’t even answering the same question. One trades consistency for flexibility and reach; the other trades flexibility for a strong guarantee. The interesting question was never “which one do we standardize on.” It’s “which one does <em>this</em> operation actually need” — and, underneath that, where the responsibility for getting consistency right should live, now that more of the application layer is being written by AI that won’t reason about any of this on your behalf.</p><p>That’s what I’ll take on in the next piece.</p><p>If you’ve run into this: was it a saga’s missing isolation that bit you — the charged-but-not-shipped class of bug — or did you rule out two-phase commit on reputation without looking at what’s changed? I’d like to hear which.</p><p><em>← </em><a href="https://medium.com/@pivotfakie/start-with-a-monolith-was-good-advice-ai-is-changing-that-a2181b8e5ede"><em>Part 1: “Start With a Monolith” Was Good Advice. AI Is Changing That.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9f7aca9a956" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Start With a Monolith” Was Good Advice. AI Is Changing That.]]></title>
            <link>https://medium.com/@pivotfakie/start-with-a-monolith-was-good-advice-ai-is-changing-that-a2181b8e5ede?source=rss-58c84785a684------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2181b8e5ede</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <dc:creator><![CDATA[Hiroyuki Yamada]]></dc:creator>
            <pubDate>Wed, 24 Jun 2026 06:06:29 GMT</pubDate>
            <atom:updated>2026-06-24T06:06:29.568Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EMQII9oij-k9t58zhTsV5A.png" /></figure><p><em>Part 1 of “Architecture in the AI Era,” a series on how AI is reshaping the way we build systems.</em></p><p>“Don’t reach for microservices too early — start with a monolith.” For most of the last decade, that was the right call. Plenty of teams split their systems up long before they had a reason to, and paid for it in operational complexity and distributed-systems problems they hadn’t earned yet.</p><p>AI is changing the calculus behind that advice. Not because microservices became fashionable again, but because the economics of writing software are shifting — and some of the assumptions that made “monolith first” correct no longer hold the same way.</p><h3>What changed</h3><p>A large and growing share of code is now written by AI under human direction, and increasingly by agents that generate code with limited supervision and work several tasks in parallel. This makes development faster. But speed isn’t the only consequence — it also changes which architectures work <em>with</em> the way code now gets produced, and which work against it.</p><p>Three effects matter.</p><p><strong>Smaller context produces better output.</strong> Models do better work when you hand them a tightly scoped problem. Keeping the relevant surface area small is now basic engineering hygiene, and the cleanest way to keep it small is to keep the software itself in small, well-bounded units.</p><p><strong>Boundaries contain what an agent can change.</strong> When an agent writes code with limited supervision, the failure you most want to prevent is a change in one area silently reaching into something unrelated. In a single large codebase, scoping the agent’s context narrows what it <em>sees</em> but not what it can <em>touch</em>. Independent units put a physical boundary around the blast radius of any one change.</p><p><strong>Independent release became a security property.</strong> A service you can deploy on its own — independent of the rest of the system — is also a service you can patch on its own. AI is getting rapidly better at finding vulnerabilities, and that cuts both ways: defenders surface issues faster, and so do attackers. As the window between a flaw being discovered and exploited shrinks, the ability to fix and ship one service without rebuilding and re-verifying the entire system stops being a convenience and starts being a security posture.</p><p>One caveat I’d insist on: none of this is an argument for microservices specifically. A modular monolith — one application cleanly divided inside — captures much of the same benefit. The principle is <em>small, well-bounded units</em>. Splitting into services is one way to get there, not the only one.</p><h3>The variable everyone argues about is the wrong one</h3><p>The benefit of separating services is usually framed around organizational size: big company, many teams, therefore microservices. That framing quietly tells every mid-sized team that the question isn’t theirs to ask.</p><p>It’s the wrong variable. What drives the benefit is the size and complexity of the <em>software</em>, not the size of the org. Teams fragment because the software grew — not the other way around. A thirty-person company with genuinely complex software gets the full return; a large company with simple software gets almost none. Framed correctly, the question isn’t “are we big enough for this?” It’s “is our software complex enough that keeping it in one block is slowing us down?” For many teams that was already true before AI. AI just raises the stakes, because the speed it unlocks compounds.</p><h3>This is a business decision, not an engineering preference</h3><p>It’s tempting to file architecture under engineering taste. I don’t think that holds here. When independent units let teams build and ship in parallel without blocking each other, the payoff isn’t a cleaner codebase — it’s shorter time to market and a faster response to change. In a market where AI is compressing how long it takes anyone to ship anything, that responsiveness is a competitive position, not a byproduct of it. Which is why the choice of architecture deserves attention at the level where business outcomes are owned — not only inside the engineering team.</p><h3>The part that’s easy to underestimate</h3><p>Splitting an application into services carries a cost that tends to surface later than the benefits do. Calls that were once in-process function calls become calls across a network, and you inherit a class of problems that didn’t exist inside a single process: latency, partial failure, services that are healthy while their dependencies are not.</p><p>The hardest of these is also the most boring to state: keeping data consistent when a single business operation spans several services, each owning its own database. Inside one database, “all of it commits or none of it does” is free. Across services, that guarantee quietly disappears — and getting it back is one of the most underestimated costs of the entire move. It’s also the one I’d least want to leave to “we’ll handle it in the application layer,” especially as more of that application layer is itself written by AI.</p><p>That’s what I’ll take apart next.</p><p>If you’ve moved a system from a monolith toward services, I’m curious which cost showed up first for you — the operational overhead, or the data-consistency problems underneath. In my experience, it’s the second one teams underestimate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2181b8e5ede" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>