How it works
A service boundary is expensive. Calls that were function calls can now time out, one database transaction becomes several steps that can half-finish, and each service needs its own deploys, dashboards, and versioned contract. Failures multiply too: if a request needs 4 services that are each 99.9% available, and failures are independent, it succeeds about 99.6% of the time (0.999 to the 4th power).
A modular monolith keeps one deployable but enforces internal boundaries. Each module exposes a small interface and owns its tables, and other modules do not query those tables directly. An automated check in the build should enforce this, because good intentions erode. You keep one deploy and can still use a database transaction when you need one, and a clean module is cheaper to extract later.
Extract a service when you can name the pressure. Team coordination: for example, three teams must agree before any of them can ship. Deploy conflicts: one team’s failing tests or risky release regularly blocks the others. Independent scaling: one part needs very different resources, and running it as a separate worker pool from the same codebase was not enough. Failure isolation: a crash-prone component keeps taking down unrelated features.
No head count settles this. A five-person team may rightly isolate a PDF renderer that keeps crashing web servers, and a large team may do well in one codebase with a fast test suite. Extract one module at a time, starting with the clearest owner and the fewest shared tables, then check whether the pressure actually fell.
A seven-person team runs one codebase. Month-end PDF generation uses so much memory that web servers are killed, and a teammate proposes a separate PDF microservice with its own repository, database, and API. What do you do?
First run PDF generation in a separate worker pool from the same codebase, so its memory use cannot kill web processes and there is no new network contract or database. Reconsider if it still needs its own runtime or deploy schedule, for example a headless browser with a different security profile, or if a distinct team comes to own it. Extraction would then add retries, versioning, and another deploy to run.
Use this as a guide for self review; written answers are not graded.Keep in mind
- A modular monolith gives you boundaries without network failures.
- Extract a service for a named pressure: coordination, deploys, scaling, or failure isolation.
- Try a separate worker pool from the same codebase before a new service.