Monolith vs Microservices
A monolith is one deployable process (often one DB).
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
- Score current pain: deploy frequency conflicts, scale hotspots, team ownership.
- If staying monolith, enforce module boundaries and API-free cross-package access.
- If extracting, choose one seam with clear data ownership and a rollback plan.
- Budget for gateway, discovery/DNS, config, resilience, and tracing before go-live.
Informative example
Trade-offs at a glance.
Monolith MicroservicesCode locality single app many apps / reposLocal dev one Boot run compose / mesh / tiltDeploys one pipeline N pipelinesTransactions single DB ACID sagas / outboxFailure domain shared JVM isolated processesScaling vertical/horizontal all scale hot serviceBest fit small/medium teams multi-team domainsSpring 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.
1BeginnerQuestionWhen does a monolith win?+
Answer
2IntermediateQuestionWhat does a modular monolith preserve?+
Answer
3BeginnerQuestionWhy can microservices increase latency?+
Answer
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.