Between 2018 and 2022, microservice architecture was preached as the only acceptable architecture for scalable technology companies. At Opstin, we followed the industry trend on an institutional project, splitting a cohesive business application into 14 distinct microservices deployed on an elastic Kubernetes cluster.

Within two years, our reality clashed with the industry hype:

  • Developer Onboarding Grated to a Halt: Running 14 Docker containers, 3 message brokers, and distinct databases locally required 32GB RAM developer machines and an entire morning of troubleshooting.
  • Distributed Tracing Nightmare: Debugging a simple customer checkout bug required correlating OpenTelemetry spans across 6 service hops.
  • Latency Tax: Every user action suffered dozens of internal JSON serialization/deserialization cycles and network hops.

We made the deliberate executive decision to consolidate the 14 services back into a single modular monolith. Here is what happened.


Architectural Comparison: Microservices vs Modular Monolith

Architecture Schematic
Microservices Architecture (Before)
[Client] ──► [API Gateway] ──► [Auth Service] (Network Hop)
                                    │
                                    ▼ (gRPC / Network Hop)
                              [Billing Service]
                                    │
                                    ▼ (Kafka / Asynchronous Hop)
                              [Notification Service]

Modular Monolith Architecture (After)
[Client] ──► [API Gateway / Next.js Server]
             └──► [In-Process Modules: Auth, Billing, Notifications]
                  (Function Calls in Memory: 0.002ms Latency)

Quantifiable Production Results

Metric14 Microservices SetupModular Monolith (Consolidated)Improvement
P99 API Latency280 ms42 ms6.6x Faster
AWS Cloud Infrastructure Cost$14,200 / month$2,950 / month79% Cost Reduction
Full Build & CI Test Pipeline24 minutes3.2 minutes7.5x Faster
Local Dev Machine Setup4 hours12 minutes95% Faster

How to Enforce Boundaries in a Monolith

The legitimate fear regarding monoliths is the emergence of a "big ball of mud"—spaghetti code where every module directly imports internal database models from other modules.

We prevent this by enforcing strict architectural boundaries using TypeScript path aliases and lint rules:

typescript
// Allowed: Importing from the public domain boundary
import { BillingFacade } from "@/modules/billing";

// FORBIDDEN by ESLint & compiler: Direct internal access
// import { BillingInternalRepository } from "@/modules/billing/internal/repository";

By enforcing boundaries at the compiler level rather than the network level, engineering teams achieve the architectural purity of microservices with the raw performance and simplicity of a single deployable binary.