Microservices vs Monolith: Making the Right Choice
When to use microservices and when to stick with a monolith. Practical guidance based on real experience.

A founder once showed me an architecture diagram with eleven services for a product that had no users yet. The team was four people. Every box had its own repository, its own pipeline and its own database, and the first sprint was going to be spent on service discovery. I asked which boundary they were most sure about. After a long pause, the answer was "none of them, but it's how big companies do it."
That answer is the whole debate in one sentence. Microservices are an answer to organizational and scaling problems you may not have yet, and they carry a fixed price from day one. This post is the decision guide I use: how to choose, how to build a monolith that stays easy to split, and how to extract your first service without a rewrite.
Quick takeaways
- Default to a monolith for new products. You do not know the right service boundaries until the domain has been in production for a while.
- A modular monolith, with one public entry point per module and boundaries enforced by tooling, keeps the option to split later.
- Extract a service because of a concrete pressure (independent scaling, team ownership, different runtime needs), not because of fashion.
- The first extraction should be the least coupled module, moved behind the same interface the monolith already uses.
- Every service owns its data. A shared database is a monolith with extra network hops.
Should I start with a monolith or microservices?
For a small team and an unclear product, start with a monolith. One codebase means one deployment, simple debugging with a real stack trace, and refactoring that your IDE can do in a minute. There is no network between components, so no latency, no partial failure and no serialization format to maintain. You spend the saved effort on the product.
Choose microservices when the pressure is real: a large team that keeps stepping on each other in one codebase, parts of the system that need to scale or be deployed at very different rates, or components with different runtime requirements, such as a GPU-bound model server next to a CRUD API. A rough threshold I use is a team of roughly ten or more people with stable, well-understood domain boundaries. Below that, the coordination you save rarely pays for the operations you add.
What do microservices actually cost you?
The benefits are real: scale one hot service instead of everything, let teams deploy independently, and keep a failure in one service from taking down the rest. The costs arrive immediately and never stop. You need distributed tracing, because a request now crosses processes. You need to decide how services talk, which is a topic of its own in REST vs gRPC vs queues: how I pick the protocol. You lose cross-service transactions and must design for eventual consistency. Local development, testing and on-call all get harder. If nobody on the team has operated a distributed system before, budget for that learning curve explicitly.
How do I build a modular monolith that can be split later?
A modular monolith is one deployable unit with strict internal boundaries. The goal is that moving a module into its own service becomes a mechanical change instead of an archaeology project. The rule is simple: modules talk to each other only through a small public interface, never through each other's internals.
src/
modules/
billing/
index.ts <- the only file other modules may import
internal/ <- tables, queries, helpers: private
catalog/
orders/
shared/ <- logging, config, tiny utilities only
Define each module's contract as an interface, and pass it in as a dependency:
// src/modules/billing/index.ts
export interface BillingApi {
chargeOrder(orderId: string, amountCents: number): Promise<{ paymentId: string }>;
}
export { createBilling } from "./internal/create-billing";
// src/modules/orders/place-order.ts
import type { BillingApi } from "../billing";
export async function placeOrder(billing: BillingApi, orderId: string, totalCents: number) {
const { paymentId } = await billing.chargeOrder(orderId, totalCents);
return { orderId, paymentId };
}
Conventions erode without enforcement, so let a tool fail the build. With dependency-cruiser, a single rule forbids importing anything from another module except its index.ts:
// .dependency-cruiser.cjs
module.exports = {
forbidden: [
{
name: "no-deep-imports-across-modules",
severity: "error",
from: { path: "^src/modules/([^/]+)/" },
to: {
path: "^src/modules/[^/]+/(?!index\\.ts$)",
pathNot: "^src/modules/$1/",
},
},
],
};
Also give each module its own database tables and avoid joins across module boundaries. That one habit decides whether extraction later takes a week or a quarter. If you want the wider map of options between these two extremes, the step between monolith and microservices compares layered, event-driven and hexagonal styles.
Which signals say it is time to extract a service?
Look for evidence, not opinions:
- One module needs ten times the instances of everything else, and scaling the whole monolith for it is expensive.
- Two teams constantly block each other's releases because they share a deploy.
- A component needs a different language or runtime, or a different security boundary (payments, for example).
- One part has a very different release cadence from the rest.
If none of these is true, extraction is a cost without a benefit. Use domain boundaries drawn around data, not nouns to check that the candidate really is a separable unit.
How do I extract the first service safely?
Pick the least coupled module and keep the same interface. Behind the BillingApi seam, swap the in-process implementation for an HTTP client. The calling code does not change:
export function createBillingHttpClient(baseUrl: string): BillingApi {
return {
async chargeOrder(orderId, amountCents) {
const res = await fetch(`${baseUrl}/charges`, {
method: "POST",
headers: { "content-type": "application/json", "idempotency-key": orderId },
body: JSON.stringify({ orderId, amountCents }),
signal: AbortSignal.timeout(3000),
});
if (!res.ok) throw new Error(`billing responded ${res.status}`);
return (await res.json()) as { paymentId: string };
},
};
}
Notice what changed: a timeout, an idempotency key, and an error path that did not exist in-process. Those are the new failure modes you now own. Then route external traffic gradually with the strangler pattern. A reverse proxy lets you move one path at a time and roll back by editing one line:
upstream monolith { server app:3000; }
upstream billing_service { server billing:4000; }
server {
listen 80;
location /api/billing/ { proxy_pass http://billing_service; }
location / { proxy_pass http://monolith; }
}
Run both implementations in parallel for a while if you can, compare results, and only then delete the old code path.
Which mistakes do teams make most often?
- Starting with microservices. You will guess the boundaries wrong, and moving code between services is far more expensive than moving it between modules.
- Wrong service boundaries. Cutting by technical layer or by noun produces chatty services. Cut by business capability and data ownership.
- A shared database. If two services read and write the same tables, you have coupled them in the way that matters most.
- Ignoring operations. Monitoring, tracing, alerting and on-call all need to exist before the second service goes live, not after the first outage.
What should I do this week?
Take your largest codebase and draw its modules on paper. For each pair, count the imports that skip a public interface. Pick the single most tangled pair, introduce one interface between them, and add the dependency-cruiser rule above in warning mode. Next sprint, turn the warnings into errors. You will either discover that you do not need microservices at all, or you will have done the groundwork that makes the first extraction boring.
Uğur Kaval
AI/ML Engineer & Full Stack Developer specializing in building innovative solutions with modern technologies. Passionate about automation, machine learning, and web development.


