Monolith vs microservices trade-offs
Lesson 2 of 81 in Microservices Interview Mastery. Free to read, no account needed.
Two ways to build
A monolith and microservices are two ways to structure the same application. A monolith is one deployable unit: one codebase, one running process, and one shared database, with its parts calling each other as ordinary in-process method calls. A microservices architecture splits the application into several services, each running as its own process and owning one business capability, such as payments or deliveries. These services talk over the network, usually with HTTP requests and responses.
Neither shape is the default answer. Each one makes some work easier and other work harder, and that trade-off is what this lesson is about. The QuickBite order for ₹450 can be built either way, and the rest of this deck uses it as the reference.
Comparing four dimensions
Compare the two shapes across the dimensions that matter when a team ships and runs software. Read each row as a trade: what the monolith makes easy is often what microservices make hard, and the reverse.
| Dimension | Monolith | Microservices |
|---|---|---|
| Deployment | One unit; any change ships the whole app | Each service ships on its own |
| Scaling | Scale the whole app, even a quiet part | Scale only the busy service, such as payment-service |
| Team | Teams share one codebase and coordinate releases | Teams own services and release without waiting |
| Operations | One process and one database to run and debug | Many processes; one order can span several |
For QuickBite, order-service and payment-service sit in one build in a monolith. In microservices they become two builds, two deployments, and two teams' release schedules.
Worked example: payment fix
Suppose payment-service rounds the ₹450 charge wrongly, and the fix is a few lines in the payment code. Here is what each shape has to do to ship it.
Monolith:
- Change the payment code inside the single codebase.
- Build the one application.
- Deploy it. Orders, restaurants and delivery all restart with it, so every team waits for the same release.
Microservices:
- Change payment-service only.
- Build and deploy payment-service alone.
- order-service, restaurant-service and delivery-service keep running untouched.
The fix is equally small in both. The difference is how far its release reaches, and how many people must agree before it goes out.
Costs of distribution
In a monolith, order-service takes payment with an in-process method call. That call is a jump inside one program, and it either works or throws an error in the same run. Split payment into payment-service and the same step becomes an HTTP request across the network.
// monolith: in-process call
PaymentResult r = payments.charge(42, 450);
// microservices: HTTP request to payment-service
POST /payments {orderId: 42, amount: 450}Predict it: the network call can fail, be slow, or be sent again. If payment-service charges ₹450 but its reply is lost, what does order-service know? It may not know whether order 42 was paid. Working that out takes extra design, and tracing one order across several services is harder than reading one stack trace.
Splitting too early
Splitting before the boundaries are clear, or before a team can run many services, is a recognised failure mode. The system pays the network and operations costs but gains no independent teams. Neither style is universally better; the right choice depends on team size, how often the code changes, and how mature the team's operations are.
| Factor | Monolith tends to fit | Microservices tend to fit |
|---|---|---|
| Team size | One small team | Several teams with separate areas |
| Change rate | Requirements still shifting | Stable areas changing at different speeds |
| Operations | Limited deployment and monitoring | Mature deployment and monitoring |
You'll meet the modular monolith later as a middle path.
Lessons in How a Microservices System Fits Together
- Tracing one quickbite order across services
- Monolith vs microservices trade-offs
- Bounded context per service
- Synchronous rest vs asynchronous events
- Api gateway as the single entry point
81 lessons across 9 topics. See the full course