O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monolith to Microservices

Book Description

How do you detangle a monolithic system and migrate it to a microservices architecture? How do you do it while maintaining business-as-usual? As a companion to Sam Newman’s extremely popular Building Microservices, this new book details a proven method for transitioning an existing monolithic system to a microservice architecture.

With many illustrative examples, insightful migration patterns, and a bevy of practical advice to transition your monolith enterprise into a microservice operation, this practical guide covers multiple scenarios and strategies for a successful migration, from initial planning all the way through application and database decomposition. You’ll learn several tried and tested patterns and techniques that you can use as you migrate your existing architecture.

  • Ideal for organizations looking to transition to microservices, rather than rebuild
  • Helps companies determine whether to migrate, when to migrate, and where to begin
  • Addresses communication, integration, and the migration of legacy systems
  • Discusses multiple migration patterns and where they apply
  • Provides database migration examples, along with synchronization strategies
  • Explores application decomposition, including several architectural refactoring patterns
  • Delves into details of database decomposition, including the impact of breaking referential and transactional integrity, new failure modes, and more

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. O’Reilly Online Learning
    4. How to Contact Us
    5. Acknowledgments
  2. 1. Just Enough Microservices
    1. What are microservices?
      1. Independent Deployability
      2. Modelled Around A Business Domain
      3. And Databases
      4. What advantages can microservices bring?
      5. What problems do they create?
      6. User Interfaces
      7. Technology
      8. Size
      9. And Ownership
    2. The Monolith
      1. The Single Process Monolith
      2. The Distributed Monolith
      3. Third-party Black Box Systems
      4. Challenges of Monoliths
      5. Advantages of Monoliths
    3. On Coupling And Cohesion
      1. Cohesion
      2. Coupling
    4. Just Enough Domain-Driven Design
      1. Aggregate
      2. Bounded Context
      3. Mapping Aggregates and Bounded Contexts To Microservices
      4. Further Reading
    5. Summary
  3. 2. Planning A Migration
    1. Understanding The Goal
      1. Three Key Questions
    2. Why Might You Pick Microservices?
      1. Improve Team Autonomy
      2. Faster Time To Market
      3. Cost Effective Scaling For Load
      4. Improve Robustness
      5. Scale Number Of Developers
      6. Embrace New Technology
    3. When might microservices be a bad idea?
      1. Unclear Domain
      2. Startups
      3. Customer-installed & Managed Software
      4. Not Having a Good Reason!
    4. Tradeoffs
    5. Taking People On The Journey
    6. Changing Organizations
      1. Establishing a Sense of Urgency
      2. Creating the Guiding Coalition
      3. Developing a Vision and Strategy
      4. Communicating the Change Vision
      5. Empowering Employees for Broad-Based Action
      6. Generating Short-Term Wins
      7. Consolidating Gains and Producing More Change
      8. Anchoring New Approaches in the Culture
    7. Importance Of Incremental Migration
      1. It’s Production That Counts
    8. Cost of Change
      1. Resersable and Irreversible Decisions
      2. Easier Places To experiment
    9. So where do we start?
    10. Domain-Driven Design
      1. How far do you have to go?
      2. Event Storming
      3. Using A Domain Model For Prioritisation
    11. A combined model
    12. Reorganizing Teams
      1. Shifting Structures
      2. It’s Not One Size Fits All
      3. Making A Change
      4. Changing Skills
    13. How will you know if the transition is working?
      1. Having regular checkpoints
      2. Quantitative Measures
      3. Qualitative Measures
      4. Avoiding The Sunk Cost Fallacy
      5. Be Open To New Approaches
    14. Summary
  4. 3. Splitting the Monolith
    1. To Change The Monolith, Or Not?
      1. Cut, Copy, Or Re-implement?
      2. Refactoring The Monolith
    2. Migration Patterns
    3. Pattern: Strangler Fig Application
      1. How It Works
      2. Where To Use It
      3. Example: HTTP Reverse Proxy
      4. Data?
      5. Proxy Options
      6. Changing Protocols
      7. Example: FTP
      8. Example: Message Interception
      9. Other Protocols
      10. Other Examples Of The Strangler Pattern
    4. Changing Behavior While Migrating Functionality
    5. Pattern: UI Composition
      1. Example: Page Composition
      2. Example: Widget Composition
      3. Example: Micro Frontends
      4. Where To Use It
    6. Pattern: Branch By Abstraction
      1. How It Works
      2. As A Fallback Mechanism
      3. Where To Use It
    7. Pattern: Parallel Run
      1. Example: Comparing Credit Derivative Pricing
      2. Example: Homegate Listings
      3. Verification Techniques
      4. Using Spies
      5. GitHub Scientist
      6. Dark Launching and Canary Releasing
      7. Where to use it
    8. Pattern: Decorating Collaborator
      1. Example: Loyalty Program
      2. Where To Use It
    9. Pattern: Change-Data Capture
      1. Example: Issuing Loyalty Cards
      2. Implementing Change Data Capture
      3. Where To Use It
    10. Summary
  5. 4. Decomposing The Database
    1. Pattern: The Shared Database
      1. Coping Patterns
      2. Where To Use It
    2. But it can’t be done!
    3. Pattern: Database View
      1. The Database As A Public Contract
      2. Views To Present
      3. Limitations
      4. Ownership
      5. Where To Use It
    4. Pattern: Database Wrapping Service
      1. Where To Use It
    5. Pattern: Database As A Service Interface
      1. Implementing A Mapping Engine
      2. Compared To Views
      3. Where To Use It
    6. Transferring Ownership
      1. Pattern: Aggregate Exposing Monolith
      2. Pattern: Change Data Ownership
    7. Data Synchronization
    8. Pattern: Synchronize Data In Application
      1. Step 1: Bulk Synchronize Data
      2. Step 2: Synchronize On Write, Read From Old Schema
      3. Step 3: Synchronize On Write, Read From New Schema
      4. Where to use this pattern
      5. Where To Use It
    9. Pattern: Tracer Write
      1. Data Synchronization
      2. Example: Orders at Square
      3. Where To Use It
    10. Splitting Apart The Database
      1. Physical vs Logical Database Separation
    11. Splitting The Database First, Or The Code?
      1. Split The Database First
      2. Splitting The Code First
      3. Split Database and Code Together
      4. So, which should I split first?
    12. Schema Separation Examples
    13. Pattern: Split Table
      1. Where to use it
    14. Pattern: Move Foreign Key Relationship To Code
      1. Moving The Join
      2. Data Consistency
      3. Where To Use This
      4. Example: Shared Static Data
    15. Transactions
      1. ACID (Atomicity, Consistency, Isolation and Durability) Transactions
      2. Still ACID, but lacking atomicity?
      3. Two Phase Commits
      4. Distributed Transactions - Just Say No
    16. Sagas
      1. Saga Failure Modes
      2. Implementing Sagas
      3. Sagas vs Distributed Transactions
    17. Summary
  6. 5. Growing Pains
    1. More Services, More Pain
    2. Ownership At Scale
      1. How Can This Problem Show Itself?
      2. When Might This Problem Occur?
      3. Potential Solutions
    3. Breaking Changes
      1. How Can This Problem Show Itself?
      2. When Might This Problem Occur?
      3. Potential Solutions
    4. Reporting
      1. When Might This Problem Occur?
      2. Potential Solutions
    5. Monitoring & Troubleshooting
      1. When Might These Problems Occur?
      2. How Can This Problem Show Itself?
      3. Potential Solutions
    6. Local Developer Experience
      1. How Can This Problem Show Itself?
      2. When Might This Occur?
      3. Potential Solutions
    7. Running Too Many Things
      1. How Might This Problem Show Itself?
      2. When Might This Problem Occur?
      3. Potential Solutions
    8. End-To End Testing
      1. How Can This Problem Show Itself?
      2. When Might This Problem Occur?
      3. Potential Solutions
    9. Global vs Local Optimization
      1. How Can This Problem Show Itself?
      2. When Might This Problem Occur?
      3. Potential Solutions
    10. Robustness & Resiliency
      1. How Can This Problem Show Itself?
      2. When Might This Problem Occur?
      3. Potential Solutions
    11. Orphaned Services
      1. How Can This Problem Show Itself?
      2. When Might This Problem Occur?
      3. Potential Solutions
    12. Summary
  7. 6. Closing Words
  8. A. Appendix 1: Bibliography
  9. B. Appendix 2: Pattern Index
  10. Index