Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 67

    Monolith vs Microservices

    A monolith is one deployable process (often one DB).

    Course progress0%
    Focus
    12 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    A monolith is one deployable process (often one DB). Microservices are many processes and usually many DBs. Both are valid architectures for TechLearningPRO Orders — the choice hinges on team size, domain boundaries, and operational maturity.

    Monoliths win on local reasoning, transactional consistency, and simple debugging. Microservices win when teams need independent release trains and hot paths need isolated scale.

    Spring Boot 3 serves both styles. The mistake is copying Netflix's topology with a five-person team — or refusing to extract a service when deploy coupling is crushing velocity.

    This lesson is a decision lens, not a religion.

    Purpose of this lesson

    Compare monolith and microservices trade-offs and pick a default posture for Orders.

    Understanding the topic

    Optimise for team coordination cost versus network and ops cost.

    • Monolith: one artifact, in-process calls, one primary DB, simple txs.
    • Microservices: N artifacts, network calls, data per service, eventual consistency.
    • Modular monolith: strong module boundaries with option value to extract later.
    • Scale: scale the whole app vs scale the hot service only.
    • Failure: all-or-nothing JVM vs isolated processes (cascades still possible).

    Step-by-step explanation

    1. Score current pain: deploy frequency conflicts, scale hotspots, team ownership.
    2. If staying monolith, enforce module boundaries and API-free cross-package access.
    3. If extracting, choose one seam with clear data ownership and a rollback plan.
    4. Budget for gateway, discovery/DNS, config, resilience, and tracing before go-live.

    Informative example

    Trade-offs at a glance.

    bash
    Monolith Microservices
    Code locality single app many apps / repos
    Local dev one Boot run compose / mesh / tilt
    Deploys one pipeline N pipelines
    Transactions single DB ACID sagas / outbox
    Failure domain shared JVM isolated processes
    Scaling vertical/horizontal all scale hot service
    Best fit small/medium teams multi-team domains
    Spring fit modules + packages Boot apps + Cloud/K8s

    Real-world use

    TechLearningPRO Orders stayed monolith through the first 40 engineers by enforcing checkout/inventory packages and an internal event bus. When warehouse robotics needed weekly deploys without touching checkout, inventory became its own Boot service. The monolith was not a failure — it was the right phase.

    Security implications

    Different topologies, same need for defense in depth.

    • Monolith: one hardened perimeter + method security still required.
    • Microservices: mTLS or token-based S2S auth between Orders and inventory.
    • Never share DB credentials across services 'temporarily'.

    Best practices

    • Default to modular monolith on this course track until pain is measured.
    • Document ownership (team + data) before any extract.
    • Prefer async integration at seams that need loose coupling.

    Common mistakes

    • Microservices for resume-driven development.
    • Monolith with zero module boundaries that cannot be extracted later.
    • Assuming microservices remove the need for good design — they amplify bad boundaries.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    3 questions
    1BeginnerQuestionWhen does a monolith win?+

    Answer

    When team size and domain fit one release train and you value simple transactions and debugging.
    2IntermediateQuestionWhat does a modular monolith preserve?+

    Answer

    Clear boundaries and extraction option value without paying distributed ops cost yet.
    3BeginnerQuestionWhy can microservices increase latency?+

    Answer

    In-process calls become network hops with serialization, retries, and failure modes.

    Hands-on exercise

    Lab. Write a one-page ADR: keep Orders as modular monolith vs extract inventory. Include forces, decision, and consequences for transactions and on-call.

    Summary

    Architecture is a trade-off ledger. Next: how services find each other — Eureka and modern alternatives.

    Ready to mark this lesson complete?Track your journey across the entire course.