Abekus — AI learning and job matching platform logo

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.

DimensionMonolithMicroservices
DeploymentOne unit; any change ships the whole appEach service ships on its own
ScalingScale the whole app, even a quiet partScale only the busy service, such as payment-service
TeamTeams share one codebase and coordinate releasesTeams own services and release without waiting
OperationsOne process and one database to run and debugMany 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:

  1. Change the payment code inside the single codebase.
  2. Build the one application.
  3. Deploy it. Orders, restaurants and delivery all restart with it, so every team waits for the same release.

Microservices:

  1. Change payment-service only.
  2. Build and deploy payment-service alone.
  3. 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.

FactorMonolith tends to fitMicroservices tend to fit
Team sizeOne small teamSeveral teams with separate areas
Change rateRequirements still shiftingStable areas changing at different speeds
OperationsLimited deployment and monitoringMature deployment and monitoring

You'll meet the modular monolith later as a middle path.

Lessons in How a Microservices System Fits Together

  1. Tracing one quickbite order across services
  2. Monolith vs microservices trade-offs
  3. Bounded context per service
  4. Synchronous rest vs asynchronous events
  5. Api gateway as the single entry point

81 lessons across 9 topics. See the full course