Khoa Nguyen

All rights reserved © yunkhngn · v1.6.6

Journal

Engineering · 2026-11-16 · 5 min read

Building Distributed Systems: From Monolith to Microservices

An analysis of the challenges and lessons learned when migrating system architecture from a Monolith to Microservices within a distributed environment.

Building Distributed Systems: From Monolith to Microservices

On this page

  1. Why do we talk about distributed systems?
  2. Core challenges
  3. 1. Consistency vs Availability
  4. 2. Service Discovery and Load Balancing
  5. 3. Distributed Tracing
  6. Data management strategy: Database per Service
  7. The Saga Pattern is a lifesaver
  8. When should you not use Microservices yet?
  9. Conclusion: Don't complicate things unnecessarily
On this page
  1. Why do we talk about distributed systems?
  2. Core challenges
  3. 1. Consistency vs Availability
  4. 2. Service Discovery and Load Balancing
  5. 3. Distributed Tracing
  6. Data management strategy: Database per Service
  7. The Saga Pattern is a lifesaver
  8. When should you not use Microservices yet?
  9. Conclusion: Don't complicate things unnecessarily

Why do we talk about distributed systems?

In recent years, the shift from traditional Monolithic applications to Microservices is no longer just a trend; it has become the standard for many large-scale systems. However, the trade-off is clear: we exchange the simplicity of centralized development and deployment for high scalability and flexibility. When your system exceeds the capacity of a single server, you officially step into the world of distributed systems.

Core challenges

When working with distributed systems, the CAP theorem (Consistency, Availability, Partition Tolerance) always looms overhead. You can never achieve all three elements perfectly at the same time. In a distributed system, Partition Tolerance is mandatory. Therefore, practical choices usually lie with CP or AP.

1. Consistency vs Availability

This is the hardest question: Do you accept the system returning stale data to ensure uptime, or pause processing while waiting for data to sync? For example, with a payment system, Consistency is the top priority (CP). But with a social media news feed, Availability is generally more important (AP).

2. Service Discovery and Load Balancing

In a Monolith architecture, components call each other via in-memory calls. With Microservices, they must communicate over a network (usually HTTP/gRPC). At this point, Service Discovery (such as Consul or Kubernetes Service) becomes essential. You need to know which service is alive, what its IP address is, and how to balance requests fairly.

3. Distributed Tracing

This is a debugging nightmare. A user request may pass through 5-10 different services. If the system reports an error, how do you know where it lies? Without Distributed Tracing (such as Jaeger or Zipkin), tracing takes hours of checking logs for each service. You are forced to attach a Correlation ID to every request right at the Gateway and pass it throughout the entire system.

Data management strategy: Database per Service

One of the most common mistakes is splitting code into services while still sharing a single Database. This leads to tight coupling at the database level, meaning that changing the schema of one service can break others.

The correct philosophy is Database per Service. Each microservice owns its own data. But what is the next challenge? It is handling related data across services. How do you maintain data integrity when you cannot use BEGIN TRANSACTION and COMMIT across different services?

The Saga Pattern is a lifesaver

Instead of Distributed Transactions (which are slow and hard to scale), we use the Saga Pattern. This is a sequence of local transactions. If a step fails, the system executes compensating transactions to undo previous steps, bringing the system back to a consistent state. It resembles a tightly coordinated workflow.

When should you not use Microservices yet?

I often see engineering teams jump into Microservices too early. If your team is small, or your product lacks clear scaling requirements, a Modular Monolith is a much wiser choice.

Microservices introduce infrastructure complexity. You will need a firm grasp of:

  • Docker and Kubernetes for container orchestration.

  • Complex CI/CD pipelines to ensure seamless deployment.

  • Large-scale Monitoring and Alerting (Prometheus/Grafana).

  • Inter-service security (mTLS, API Gateways).

Conclusion: Don't complicate things unnecessarily

Technology is merely a tool to solve business problems. Microservices architecture is a solution to a scale problem, not an end goal. Do not try to apply it just because it is cool. Start small, modularize your code, and when the pressure from actual scaling becomes heavy, consider gradually extracting components into independent services.

Ultimately, whatever architecture you choose, the human factor and observability remain the most critical. A robust distributed system is not one that never fails, but one where when it does fail, you know precisely why and how long it takes to fix.

I hope these insights help on your engineering journey. Leave your thoughts if you have a different experience with Microservices architecture!

Keep exploring

From the journal

2026-11-15

Beautiful on the Surface, Engineered Underneath - My Legacy Website

Building a Personal Website into a Microservice Platform. An engineering retrospective on building a design-driven personal website backed by a microservice architecture, computer vision experiments, automated Docker builds, and production infrastructure."

2026-11-16

Engineering Lawise: Building an AI-Powered LegalTech Platform

From legal documents to actionable intelligence — exploring the engineering behind an AI-powered legal platform built with Next.js, polyglot microservices, PostgreSQL, pgvector, and OpenAI.

2026-11-22

Building a Vector Search and Embeddings System with MongoDB

Explore how to integrate embeddings and Vector Search features directly into MongoDB to build intelligent semantic search applications.

Related work

2025

Yunkhngn Microservice Platform

A sophisticated microservice ecosystem powering a personal portfolio and interactive digital experiences, utilizing AI-driven image processing and a robust, containerized architecture.

2025

Hanoi Rock City (HRC) - Event Ticketing System

A comprehensive Java web application for managing rock concert events, ticket sales, and venue management in Hanoi, Vietnam, streamlining operations for organizers and purchases for customers.