trendingzones

JAVA + SPRING AI — INTRODUCTION

Microservices vs. a Monolith: What Spring Boot Actually Deploys

Everything covered so far in this pillar — beans, the ApplicationContext, @RestController — happened inside a single running application. This topic zooms out one level: what happens once a system is built from several of those applications, each running independently, instead of just one.

The Quick Answer

A monolith is one large application — all the code for orders, inventory, payments, and everything else, built, deployed, and run as a single unit. A microservice is the opposite instinct: instead of one big application, you build several small ones, each responsible for exactly one piece of the system, and each one independently built, deployed, started, and scaled — without touching any of the others. A microservices architecture is a whole system built this way: many small services, usually talking to each other over the network, that together do what one monolith would otherwise do alone. Everything you already know from this pillar — @SpringBootApplication, an embedded server, a @RestController — still applies to each individual microservice. A microservice isa Spring Boot application; it just isn’t the only one running.

The Food-Court Analogy

Imagine one enormous restaurant kitchen that cooks absolutely everything on a huge menu — burgers, sushi, pizza, dessert, coffee — all from one shared kitchen, one shared staff, one shared set of ovens and fridges. It works, but it has real problems: if the pizza oven breaks, the whole kitchen might have to shut down, even though nobody ordered pizza. If the sushi chef needs a totally different set of tools than the burger cook, they’re still crammed into the same space, fighting over the same refrigerator. And if you want to change how burgers are made, you risk accidentally breaking something in how sushi gets made too, because it’s all one tangled kitchen.

Now imagine a food court instead. The burger stall, the sushi stall, the pizza stall, and the coffee stall are each their own small, independent operation — their own equipment, their own staff, their own fridge. The pizza oven breaking doesn’t touch the sushi stall at all. The burger stall can change its recipe, hire more staff for a busy lunch rush, or even close for renovation, and every other stall keeps running exactly as before. Customers still walk up to one shared area and place orders — they don’t need to know or care that four separate, independent little businesses are actually serving them.

That one giant shared kitchen is a monolith. The food court — several small, independent stalls, each one self-contained — is a microservices architecture. Each stall is a microservice.

Why Teams Actually Split Systems This Way

Splitting one application into several isn’t free — it trades one set of problems for another (the Intermediate and Advanced levels get into exactly what that trade costs). Teams accept that trade for a few concrete reasons:

Spring Boot’s Role: Making Each Stall Self-Sufficient

The previous topic in this pillar covered @SpringBootApplication and its embedded server — the fact that a Spring Boot application doesn’t need a separately installed server program to run; it packages its own and can simply be started. That detail, which might have seemed like a minor convenience back in that topic, turns out to be exactly what makes Spring Boot such a natural fit for microservices: everymicroservice needs to be independently runnable and deployable, on its own, without depending on some shared, pre-existing server installation — and that’s precisely what a Spring Boot application already is, out of the box.

Put plainly: a microservice, in this pillar, is a Spring Boot application. It has its own @SpringBootApplication class, its own embedded server, its own @RestController endpoints, and its own beans, wired by its own ApplicationContext. The only thing that’s new here is that instead of running exactly one of these, a system now runs several — an Order Service, an Inventory Service, a Payment Service — each one its own separate, independently deployable Spring Boot application, each one its own food-court stall.

Fun Fact

“Microservices” isn’t a Spring-specific idea, and it isn’t even a Java-specific one — it’s an architectural style that shows up across essentially every programming ecosystem. What Spring Boot specifically contributes is making the “independently runnable Java application” part of that style almost trivially easy, since auto-configuration and the embedded server remove most of the setup work each individual service would otherwise need.

Test Yourself

What is the key difference between a monolith and a microservices architecture?

In the food-court analogy, what does each independent food stall represent?

What is Spring Boot’s specific role in a microservices architecture?

Ready for the part a food-court analogy can’t quite capture — how these independent services actually find and talk to each other over a real network? Continue to the Intermediate level →