VibeKoding / Ensiklopedia Β· Fondasi KuatEnsiklopedia Β· Fondasi Kuat / An Introduction to Monolith-to-Microservices EvolutionAn Introduction to Monolith-to-Microservices Evolution
VK

An Introduction to Monolith-to-Microservices EvolutionAn Introduction to Monolith-to-Microservices Evolution

πŸ“š Ensiklopedia Β· Fondasi KuatEnsiklopedia Β· Fondasi Kuat 🌏 Dual Bahasa (ID / EN) ⚑ VibeKoding Native

Ensiklopedia VibeKoding: An Introduction to Monolith-to-Microservices Evolution.Ensiklopedia VibeKoding: An Introduction to Monolith-to-Microservices Evolution.

πŸ’‘ Tips PraktisπŸ’‘ Pro Tip

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:

ChapterContentCore Concepts
Chapter 1Architecture Evolution PathMonolith β†’ Modular β†’ SOA β†’ Microservices
Chapter 2When and Why to SplitConway's Law, team autonomy
Chapter 3Splitting StrategiesDDD bounded contexts, Strangler Fig pattern
Chapter 4Service CommunicationREST, gRPC, message queues
Chapter 5Data SplittingDatabase decomposition, data synchronization

------

1. Architecture Evolution Path1. Architecture Evolution Path

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.

StageArchitectureTeam SizeCharacteristics
StartupMonolithic application1–10 peopleAll code in one project, simple deployment
GrowthModular monolith10–50 peopleCode organized by module, but still deployed together
ExpansionSOA (Service-Oriented)50–200 peopleSplit into coarse-grained services by business line
ScaleMicroservices200+ peopleFine-grained services, each team develops and deploys independently

πŸ’‘ Tips PraktisπŸ’‘ Pro Tip

"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.

------

2. Criteria for Split into Microservices2. Criteria for Split into Microservices

Not all systems need microservices. Splitting too early introduces unnecessary complexity.Not all systems need microservices. Splitting too early introduces unnecessary complexity.

SignalDescriptionRecommendation
Frequent deployment conflictsMultiple teams modifying the same codebase, frequent conflictsConsider splitting
A module needs independent scalingThe search module needs 10x the resources of other modulesConsider splitting
Differentiated tech stacks neededAI module uses Python, main site uses JavaConsider splitting
Team < 10 peopleLow communication overhead, monolith is sufficientDon't split
Business still in exploration phaseRequirements change rapidly, boundaries are unclearDon't split
No DevOps capabilityNo CI/CD, containerization, or monitoring infrastructureDon't split

------

3. Splitting Strategies3. Splitting Strategies

3.1 Split by Business Domain (DDD Bounded Contexts)3.1 Split by Business Domain (DDD Bounded Contexts)

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 ContextCore EntitiesCorresponding Service
User domainUser, Profile, AddressUser Service
Product domainProduct, Category, SKUProduct Service
Order domainOrder, OrderItemOrder Service
Payment domainPayment, RefundPayment Service
Logistics domainShipment, TrackingLogistics Service

3.2 Strangler Fig Pattern3.2 Strangler Fig Pattern

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:

  1. Create a new service outside the monolithCreate a new service outside the monolith
  2. Route some traffic to the new service through a proxy layerRoute some traffic to the new service through a proxy layer
  3. After verifying the new service is stable, gradually migrate more trafficAfter verifying the new service is stable, gradually migrate more traffic
  4. Eventually replace the old module entirelyEventually replace the old module entirely
  5. ------

    4. Service Communication Patterns4. Service Communication Patterns

    MethodProtocolCharacteristicsUse Cases
    RESTHTTP/JSONSimple and universal, great ecosystemExternal APIs, CRUD operations
    gRPCHTTP/2 + ProtobufHigh performance, strongly typedHigh-frequency internal service calls
    Message queueAMQP/KafkaAsync decoupling, peak shavingEvent notifications, async tasks
    GraphQLHTTP/JSONClient-driven queriesBFF layer, mobile clients
    πŸ’‘ Tips PraktisπŸ’‘ Pro Tip

    - 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.

    ------

    5. Data Splitting: The Hardest Part5. Data Splitting: The Hardest Part

    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.

    ChallengeDescriptionSolution
    Cross-service JOINsCannot directly JOIN tables from two servicesAPI composition queries, data redundancy
    Distributed transactionsCross-database transactions cannot use local transactionsSaga, local message tables
    Data consistencyData across services may be temporarily inconsistentEventual consistency, event-driven
    Data migrationMigrating from shared to independent databasesDual-write transition, data sync tools

    ------

    SummarySummary

    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:

    1. Evolution Path: Monolith β†’ modular monolith β†’ SOA β†’ microservices, each step driven by clear motivationsEvolution Path: Monolith β†’ modular monolith β†’ SOA β†’ microservices, each step driven by clear motivations
    2. When to Split: Team size, deployment conflicts, and scaling needs are signals to splitWhen to Split: Team size, deployment conflicts, and scaling needs are signals to split
    3. Splitting Strategies: Use DDD bounded contexts to guide splitting and the Strangler Fig pattern for gradual migrationSplitting Strategies: Use DDD bounded contexts to guide splitting and the Strangler Fig pattern for gradual migration
    4. Communication Choices: Go async whenever possible; keep synchronous call chains as short as possibleCommunication Choices: Go async whenever possible; keep synchronous call chains as short as possible
    5. Data Splitting: The hardest but most important part β€” accepting eventual consistency is the key mindset shiftData Splitting: The hardest but most important part β€” accepting eventual consistency is the key mindset shift
    6. Further ReadingFurther Reading

      • [Building Microservices](https://www.oreilly.com/library/view/building-microservices-2nd/9781492034018/) - Sam Newman's microservices classic[Building Microservices](https://www.oreilly.com/library/view/building-microservices-2nd/9781492034018/) - Sam Newman's microservices classic
      • [Monolith to Microservices](https://www.oreilly.com/library/view/monolith-to-microservices/9781492047834/) - A guide to incremental migration[Monolith to Microservices](https://www.oreilly.com/library/view/monolith-to-microservices/9781492047834/) - A guide to incremental migration
      • [Domain-Driven Design](https://www.domainlanguage.com/ddd/) - Eric Evans' DDD classic[Domain-Driven Design](https://www.domainlanguage.com/ddd/) - Eric Evans' DDD classic
      • [The Strangler Fig Pattern](https://martinfowler.com/bliki/StranglerFigApplication.html) - Martin Fowler on the Strangler Fig pattern[The Strangler Fig Pattern](https://martinfowler.com/bliki/StranglerFigApplication.html) - Martin Fowler on the Strangler Fig pattern