Skip to main content

Why We Merged Two Backends Into One

Updated 6 min readMarkdown

Two services quietly cost more than they look like, even when both are doing everything "right".

How it usually starts

  • A request comes in from the UI.

  • Hits a Node.js service first.

  • Gets forwarded to a Spring Boot service for the next stage.

  • From there, reaches the actual backend doing the real work.

  • Three hops. Two different runtimes in the middle. Before the request even reaches where it needs to go.

Both services followed the same observability methodology. Same logging conventions. Same OpenTelemetry setup. Same approach to metrics. This wasn't two teams doing things differently, the standard was genuinely shared.

Worth noting too: the actual backend at the end of that chain was already Python. So the request path went from Node, to Java, to Python, three languages for one logical flow, when the last hop was already speaking the language the new merged service would eventually use anyway.

With everything now in Python, the local dev and debugging story got a lot simpler too, one runtime to install, one debugger to attach, one set of tooling to learn, instead of a dev needing Node and JVM environments both set up just to reproduce one end-to-end request locally.

And that's exactly what made the real cost easy to miss at first: It wasn't inconsistency causing pain. It was duplication of identical effort.

Same methodology, built twice

  • OpenTelemetry setup was consistent, but wired up twice, in two separate SDKs, each needing its own config, testing, and upgrades.

  • Logging format was unified by design, but two codebases had to independently keep honouring it, catching drift whenever a dependency update changed default behaviour on one side and not the other.

  • Retry and timeout policy existed as two separate implementations meant to behave identically. Usually did. Not always.

  • The extra hop itself had a cost, every request crossed one more network boundary than it strictly needed to.

It wasn't just about observability

Worth being honest here. Node.js and Spring Boot weren't two copies of the same logic. Each owned genuinely different business logic, different responsibilities, built at different times, for different reasons. Observability duplication was real, but on its own, it wouldn't have justified a merge. A few other things carried real weight:

  • Wasted latency. The Node-to-Spring hop did no meaningful work, just handed a request between runtimes before real processing even started.

  • Two dependency graphs, two upgrade treadmills. Security patches, framework upgrades, breaking changes, tracked and rolled out independently, twice, forever.

  • Auth and session trust had to agree across a language boundary. Whatever proved a request was legitimate on the Node side had to be re-validated on the Spring side. Two independent trust boundaries in sync is more fragile than one.

  • Real-time features fought the architecture.

  • Two infrastructure footprints. Separate pods, separate resource limits, separate scaling, for two services that always scaled together anyway, since one request touched both.

  • Debugging meant stitching two stack traces into one mental model. Slower than it needed to be, every single time, even with good tracing in place.

  • One stack is easier to hire and ramp into. Needing engineers comfortable in both Node and Java to own "the backend" narrows who can confidently work across the whole system.

None of these alone was a slam-dunk. Together, the cost of staying split outweighed the reason it got split in the first place.

Why FastAPI specifically

This wasn't "Python is nicer", a few concrete technical reasons made FastAPI the right landing spot, not just "a Python framework":

  • Native async/await, all the way down. Built on Starlette + ASGI (not WSGI), so async I/O, calls to Kafka, downstream HTTP calls, WebSocket connections, is a first-class citizen, not bolted on.

  • Pydantic models replace manual validation in two languages. One schema definition, automatic request/response validation, automatic serialization, instead of hand-rolled validation logic written once in Node and once in Java, hoping they agree.

  • Automatic OpenAPI generation, for free. Every endpoint's schema is derivable straight from the code, no separate API doc to maintain by hand, and no drift between "what the code does" and "what the docs say."

  • Dependency injection built into the framework. Auth checks, DB sessions, shared request-scoped logic, declared once, reused everywhere, without two separate middleware implementations agreeing to behave the same way.

  • Background tasks without a separate job runner. Simple fire-and-forget work can run inline via FastAPI's BackgroundTasks, without standing up extra infrastructure for things that don't need a full task queue.

  • Lower memory footprint per pod. A JVM needs its own heap setting plus extra memory on top for things like class loading and garbage collection, get that balance wrong, and Kubernetes kills the pod for using too much memory, even though the JVM thought it had room. A Python/ASGI process is much simpler here: what you ask for is close to what it actually uses, so more of it fits per node, and it costs less at scale.

  • Type hints catch mistakes before runtime, without Java's verbosity, most of the safety benefit, a fraction of the boilerplate.

This isn't an argument against microservices

  • Plenty of systems genuinely need separate services.

  • Different scaling needs. Different teams owning different domains. Real security boundaries.

  • The point isn't "always consolidate."

  • It's narrower: even when two services share an identical, well-maintained standard, maintaining that standard twice still costs real, ongoing effort.

  • That cost is worth weighing honestly against whatever reason the split originally existed for.

  • The real tradeoff: microservices buy you clear ownership and independent scaling per responsibility, combining buys you fewer seams for a request to cross. Neither is free. Pick based on whether the boundary reflects a real organizational or scaling need, not just "this is how it happened to grow."

What made the actual migration hard

  • Cutting over needed a real rollback path, not just a rewrite. Running both in parallel, shifting traffic gradually, mattered more than getting new code right on the first attempt.

  • Removing a hop changes failure modes. UI → Node → Spring → backend fails differently than UI → FastAPI → backend. Some error-handling assumptions built around three hops needed rethinking, not just porting over.

The one-line version

Doing the same thing well in two places still means doing it twice. Collapsing two services into one doesn't fix a broken standard, it removes the tax of maintaining a good one twice, on top of finally giving real-time, async-heavy features a single runtime to actually live in.

Went the other direction, split one service into several and it genuinely helped? Curious what tipped that decision for you. Find me on LinkedIn 😄.

About the author

  • I'm a backend engineer who spends most days deep in distributed systems, services talking to each other, breaking in interesting ways, and occasionally behaving. I write here about what I actually learn while building and debugging things, not the polished version.

No comments yet. Be the first to comment.