System Design AI

Microservices vs Monoliths in System Design Interviews: When to Use It and What to Say

A monolith is a single codebase that runs as one process and owns a single database. A microservice is a small, independently deployable service that owns its own data store and communicates with other services over the network.

The Problem Each Architecture Solves

Monolith – When a product is new or the team is small, the biggest friction is coordination. A single codebase lets anyone change any part of the system without worrying about version compatibility. The trade-off is that the whole application must be redeployed for any change, and scaling is coarse-grained.

Microservices – As a product matures, the codebase can grow to millions of lines, and multiple teams start to own different features. Deploying a new version of one feature without affecting the rest becomes painful. Splitting the system into services lets each team own its lifecycle and scale the hot parts independently.

Step-by-Step Walkthrough: Building a Simple URL Shortener

Suppose you are asked to design a URL shortening service like Bitly. We'll start with a monolith and then refactor to microservices.

  1. Request Flow – A client sends POST /shorten with a long URL. The server validates the URL, generates a short key, stores the mapping, and returns the short link.
  2. Data Store – A single relational table url_mappings(id, long_url, short_key) holds all data.
  3. Scaling – To handle more traffic you add more identical servers behind a load balancer. All servers hit the same database, so you must ensure the DB can handle the read/write load.
  4. Pain Point – Imagine a new analytics feature that tracks clicks per short link. Adding a heavy reporting pipeline to the same process will increase latency for the core POST /shorten path.

Refactor to Microservices

  1. Core Service – Shortener Service handles key generation and storage. It owns its own database (shortener_db).
  2. Analytics Service – A separate ClickTracker Service consumes events from a message queue (e.g., Amazon Kinesis) and stores aggregates in its own store.
  3. API Gateway – A thin layer routes POST /shorten to the Shortener and GET /{key} to a Redirect Service that reads from the shortener DB and optionally enriches the response with analytics data.
  4. Deployment – Each service can be deployed independently. If analytics needs more CPU, you scale only the ClickTracker pods.

The key idea is that each service owns a bounded context and can evolve without breaking the others.

Where It Shows Up in Classic Interview Questions

Interview QuestionWhere Architecture Decision Appears
Design Instagram feedDeciding between a monolithic feed generator vs. a microservice per user timeline.
Design a ride-hailing systemChoosing a monolith for the matching engine vs. microservices for driver-location, pricing, and trip management.
Design a video streaming platformDeciding if the transcoding pipeline should be a separate microservice or part of a single media service.

In each case, the interviewer will ask you to justify the choice for the component you highlight.

Trade-offs You Must Own

AspectMonolithMicroservices
DeploymentSingle artifact; simple CI/CD.Multiple artifacts; complex CI/CD pipelines.
ScalingScale whole app; wasteful for uneven load.Scale hot services independently; more efficient.
Data ConsistencyStrong consistency is easy; single DB.Eventual consistency across services; need saga or two-phase commit.
Operational OverheadOne runtime, one monitoring stack.Multiple runtimes, service discovery, network latency, tracing.
Team AutonomyShared codebase; potential bottlenecks.Clear ownership; reduces coordination friction.

Interviewers often follow up with questions like “How will you handle transactions across services?” or “What happens if the network between two services flaps?” Be ready to discuss distributed tracing, retries, and idempotency.

The 30-Second Pitch

"A monolith is a single deployable unit that’s easy to build and reason about, but it scales only as a whole and can become a coordination bottleneck. Microservices break the system into independently deployable services, each owning its data, which lets large teams scale parts of the system separately. The trade-off is added operational complexity—network latency, distributed transactions, and more moving parts. In an interview, I’d pick a monolith for early-stage products or low-latency paths, and microservices when I need independent scaling, clear ownership, or to isolate heavy workloads like analytics."

Common Mistakes Candidates Make

  • Over-engineering – Jumping to microservices for a trivial problem, then spending time on service discovery and circuit breakers that add no value.
  • Ignoring Data Coupling – Claiming that each microservice can have its own database without addressing how you’ll keep data consistent across services.
  • Vague Trade-off Discussion – Saying “microservices are more flexible” without acknowledging the operational burden and latency penalties.
  • Missing the “When” – Failing to tie the choice to product stage, team size, or performance requirements; interviewers want to see you weigh concrete factors.

How to Practice This

  1. Study the worked design in the System Design AI library for a service mesh, the layer that manages calls between microservices.
  2. Draw your own canvas: sketch the request flow, label each component, and write a short note on why you chose monolith or microservice for each.
  3. Run a mock interview: explain your architecture aloud, then answer follow-up questions about scaling, consistency, and operational concerns.

How to Practice This

Questions people ask

When is a monolith still the better choice for a large product?

If the core user-facing path requires ultra-low latency and strong consistency, keeping that path in a single process avoids network hops and distributed transaction complexity.

How do you handle cross-service transactions without a two-phase commit?

Use a saga pattern: each service performs its local transaction and publishes an event; compensating actions undo work if a later step fails.

What monitoring tools help manage many microservices?

Distributed tracing (e.g., AWS X-Ray), centralized logging, and health-check endpoints let you see the health of each service and trace a request across them.

Can a monolith be gradually broken into microservices?

Yes. Start with a modular codebase, extract a high-traffic component into its own service, and route calls through an API gateway. Iterate until you achieve the desired separation.