Ensiklopedia VibeKoding: An Introduction to Monolith-to-Microservices Evolution.Ensiklopedia VibeKoding: An Introduction to Monolith-to-Microservices Evolution.
No architecture is "the best" β there is only "the best fit for the current stage." Moving from monolith to microservices is not a single leap but a gradual evolution as business scale and team size grow. Splitting into microservices too early is just as dangerous as splitting too late.No architecture is "the best" β there is only "the best fit for the current stage." Moving from monolith to microservices is not a single leap but a gradual evolution as business scale and team size grow. Splitting into microservices too early is just as dangerous as splitting too late.
What will you learn from this article?What will you learn from this article?
After reading this chapter, you will gain:After reading this chapter, you will gain:
| Chapter | Content | Core Concepts |
|---|---|---|
| Chapter 1 | Architecture Evolution Path | Monolith β Modular β SOA β Microservices |
| Chapter 2 | When and Why to Split | Conway's Law, team autonomy |
| Chapter 3 | Splitting Strategies | DDD bounded contexts, Strangler Fig pattern |
| Chapter 4 | Service Communication | REST, gRPC, message queues |
| Chapter 5 | Data Splitting | Database decomposition, data synchronization |
------
Architecture evolution is not driven by technology β it is driven by organizational scale. When a team grows from 5 to 500 people, the collaboration efficiency of a monolithic architecture drops precipitously.Architecture evolution is not driven by technology β it is driven by organizational scale. When a team grows from 5 to 500 people, the collaboration efficiency of a monolithic architecture drops precipitously.
| Stage | Architecture | Team Size | Characteristics |
|---|---|---|---|
| Startup | Monolithic application | 1β10 people | All code in one project, simple deployment |
| Growth | Modular monolith | 10β50 people | Code organized by module, but still deployed together |
| Expansion | SOA (Service-Oriented) | 50β200 people | Split into coarse-grained services by business line |
| Scale | Microservices | 200+ people | Fine-grained services, each team develops and deploys independently |
"Organizations which design systems... produce designs which are copies of the communication structures of these organizations." β Melvin Conway Simply put: 3 teams building one system will end up with 3 services. The essence of architecture splitting is organizational splitting. Inverse Conway's Law: Since organizational structure determines system architecture, to get the architecture you want, first restructure the organization accordingly. For example, if you want an independent payment service, first create an independent payment team. Many companies fail at microservice splitting not because of technology, but because the organization didn't adapt."Organizations which design systems... produce designs which are copies of the communication structures of these organizations." β Melvin Conway Simply put: 3 teams building one system will end up with 3 services. The essence of architecture splitting is organizational splitting. Inverse Conway's Law: Since organizational structure determines system architecture, to get the architecture you want, first restructure the organization accordingly. For example, if you want an independent payment service, first create an independent payment team. Many companies fail at microservice splitting not because of technology, but because the organization didn't adapt.
------
Not all systems need microservices. Splitting too early introduces unnecessary complexity.Not all systems need microservices. Splitting too early introduces unnecessary complexity.
| Signal | Description | Recommendation |
|---|---|---|
| Frequent deployment conflicts | Multiple teams modifying the same codebase, frequent conflicts | Consider splitting |
| A module needs independent scaling | The search module needs 10x the resources of other modules | Consider splitting |
| Differentiated tech stacks needed | AI module uses Python, main site uses Java | Consider splitting |
| Team < 10 people | Low communication overhead, monolith is sufficient | Don't split |
| Business still in exploration phase | Requirements change rapidly, boundaries are unclear | Don't split |
| No DevOps capability | No CI/CD, containerization, or monitoring infrastructure | Don't split |
------
The Bounded Context from DDD (Domain-Driven Design) is the best guiding principle for splitting microservices. Each bounded context corresponds to an independent business domain with its own data model and business rules.The Bounded Context from DDD (Domain-Driven Design) is the best guiding principle for splitting microservices. Each bounded context corresponds to an independent business domain with its own data model and business rules.
What is a bounded context? The same word can mean different things in different business domains. For example, "user" in the user domain means registration info (name, email), in the order domain means the buyer (shipping address, payment method), and in the recommendation domain means a behavioral profile (browsing history, preference tags). A bounded context draws a boundary within which terminology and models have a clear, unified meaning.What is a bounded context? The same word can mean different things in different business domains. For example, "user" in the user domain means registration info (name, email), in the order domain means the buyer (shipping address, payment method), and in the recommendation domain means a behavioral profile (browsing history, preference tags). A bounded context draws a boundary within which terminology and models have a clear, unified meaning.
CODE βββββββββββββββ βββββββββββββββ βββββββββββββββ β User Domain β β Order Domainβ βPayment Domainβ β β β β β β β User β β Order β β Payment β β Profile β β OrderItem β β Refund β β Address β β Cart β β Transaction β β β β β β β β User Serviceβ βOrder Serviceβ βPayment Svc β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ β β β βββββββ API calls / event communication ββββββββ
| Bounded Context | Core Entities | Corresponding Service |
|---|---|---|
| User domain | User, Profile, Address | User Service |
| Product domain | Product, Category, SKU | Product Service |
| Order domain | Order, OrderItem | Order Service |
| Payment domain | Payment, Refund | Payment Service |
| Logistics domain | Shipment, Tracking | Logistics Service |
Don't rewrite the entire monolith at once. Instead, like a strangler fig, gradually replace old modules with new services:Don't rewrite the entire monolith at once. Instead, like a strangler fig, gradually replace old modules with new services:
------
| Method | Protocol | Characteristics | Use Cases |
|---|---|---|---|
| REST | HTTP/JSON | Simple and universal, great ecosystem | External APIs, CRUD operations |
| gRPC | HTTP/2 + Protobuf | High performance, strongly typed | High-frequency internal service calls |
| Message queue | AMQP/Kafka | Async decoupling, peak shaving | Event notifications, async tasks |
| GraphQL | HTTP/JSON | Client-driven queries | BFF layer, mobile clients |
- Need immediate results β Synchronous (REST/gRPC) - Don't need immediate results β Asynchronous (message queue) - One event triggers multiple actions β Asynchronous (publish-subscribe) Rule of thumb: go async whenever possible. The longer the synchronous call chain, the more fragile the system.- Need immediate results β Synchronous (REST/gRPC) - Don't need immediate results β Asynchronous (message queue) - One event triggers multiple actions β Asynchronous (publish-subscribe) Rule of thumb: go async whenever possible. The longer the synchronous call chain, the more fragile the system.
------
The most painful part of microservice splitting is not code decomposition β it's database decomposition. Each service should own its own database, but this makes cross-service queries difficult.The most painful part of microservice splitting is not code decomposition β it's database decomposition. Each service should own its own database, but this makes cross-service queries difficult.
| Challenge | Description | Solution |
|---|---|---|
| Cross-service JOINs | Cannot directly JOIN tables from two services | API composition queries, data redundancy |
| Distributed transactions | Cross-database transactions cannot use local transactions | Saga, local message tables |
| Data consistency | Data across services may be temporarily inconsistent | Eventual consistency, event-driven |
| Data migration | Migrating from shared to independent databases | Dual-write transition, data sync tools |
------
Moving from monolith to microservices is a gradual process, not a overnight revolution.Moving from monolith to microservices is a gradual process, not a overnight revolution.
Key takeaways from this chapter:Key takeaways from this chapter: