Microservices Architecture and Service Decomposition Questions
Decomposing a system into services along bounded contexts, defining service boundaries and ownership, and managing the tradeoffs against a monolith. Covers cohesion, coupling, data ownership per service, the distributed-monolith anti-pattern, and when a modular monolith beats microservices. Emphasizes decomposition reasoning rather than any single framework.
When should you split a service into two versus keeping it as a single service? Provide measurable indicators (change frequency, team ownership, differing scaling requirements, failure blast radius) and describe a process that avoids premature decomposition while still allowing the service to split later as those signals emerge.
Sample Answer
Direct answer
Split a service into two when at least two of these hold at once: the two parts change at very different frequencies, they're owned (or should be owned) by different teams, they need to scale differently, and a failure in one part shouldn't take down the other. A single one of these signals firing isn't usually enough justification on its own; the process should default to NOT splitting until the signals stack up.
Structured elaboration
Change frequency: if one part of a service is touched every day and another part hasn't changed in a year, bundling them together means every deploy of the fast-changing part carries risk for the stable part too, even though nothing about the stable part actually needed to change. Team ownership: if two different teams are regularly making changes to the same service and stepping on each other's release schedule, that's a coordination cost a split would remove, but only if the teams' work genuinely doesn't need to be coordinated (if they're deeply interdependent, splitting just moves the coordination cost from code review to an API contract). Scaling differences: if one part of a service needs to handle 100x the traffic of another (a hot read path bundled with a rarely-called admin endpoint, for example), scaling the whole service to serve the hot path wastes resources on the cold path. Failure blast radius: if a bug or outage in one part of a service currently takes down an unrelated part, and that unrelated part has a stricter uptime requirement, that's a real argument for isolating them.
The process to avoid premature decomposition: track these signals over time rather than reacting to the first instance of any one of them (one slow deploy or one minor incident isn't a trend), and require at least two signals to agree before committing to a split, since a split that turns out to be unnecessary is expensive to undo (merging two services back into one is rarely done and usually more painful than the original split).
Worked example
A concrete example: an Order service that also handles admin-only bulk data exports. The export feature is used rarely, by a different (internal tooling) team, runs long batch queries that occasionally degrade the Order service's regular request latency, and doesn't need the same uptime service-level agreement (SLA) as live order processing. That's change frequency, team ownership, scaling, and blast radius all pointing the same direction, which is a strong case to split Export into its own service reading from a replica rather than the Order service's primary database.
Trade-offs and pitfalls
The most common overcorrection is splitting on a single weak signal ("these two files feel conceptually different") without checking whether the other three actually agree, producing a service boundary that adds deployment and monitoring overhead without removing any real coordination cost. The opposite mistake, waiting until every signal is screaming before acting, lets a service accumulate enough tangled responsibility that the eventual split becomes a much bigger, riskier project than it would have been if addressed early; the discipline of tracking the four signals over time, rather than reacting to a single incident, is what keeps the timing right in both directions.
Describe the modular monolith architectural pattern as an intermediate step before adopting microservices. What are its benefits and drawbacks, and what technical and organizational decision criteria would lead you to recommend staying with a modular monolith versus moving to microservices?
Sample Answer
Direct answer
A modular monolith is a single deployable application whose internal code is organized into strictly-separated modules, each owning its own data and exposing a defined interface to the others, the same discipline microservices apply at the network boundary but enforced inside one process instead of across services. It buys most of the maintainability and clear-ownership benefits people associate with microservices (an engineer can reason about one module without understanding the whole codebase) while keeping the deployment, testing, and debugging story of a single application.
Structured elaboration
The main benefits are: one deploy pipeline and one set of infrastructure to operate, no network calls (and their associated latency and failure modes) between modules that used to be function calls, easier cross-module refactors (the compiler or a single test suite catches a broken contract immediately, instead of it surfacing later as a runtime failure between two independently-deployed services), and a natural stepping stone toward microservices if a specific module's traffic or ownership needs later diverge from the rest.
The main drawbacks are: the module boundaries are enforced by discipline and code review, not by a hard network boundary, so they erode more easily under schedule pressure than a boundary that would require actually calling a different service to violate; every module still shares the same deploy (so a bug in one module can still take down the process serving all of them, and a slow test suite in one module still blocks everyone's release); and a module can't scale independently of the others without scaling the whole process.
Worked example
Decision criteria for staying with a modular monolith rather than moving to microservices: the team is small enough that a shared deploy pipeline isn't a bottleneck, no single module has a materially different scaling profile from the rest, and the org values the lower operational overhead (fewer things to monitor, deploy, and keep backward-compatible) more than independent per-module deployability. The Shopify engineering team's widely-discussed decision to run a modular monolith at very large scale is a well-known real-world example: strict internal module boundaries with a shared deployable, extracting specific components to their own services only when a concrete scaling or ownership need justified it.
Trade-offs and pitfalls
The most common failure mode is treating "modular monolith" as a label rather than a discipline: without enforced module boundaries (linting rules, code-ownership checks, or architectural review that catches a module reaching directly into another module's tables), a modular monolith degrades back into an ordinary tangled monolith over time, at which point it has neither the deployability benefits of microservices nor the simplicity benefits of a genuinely modular codebase.
Discuss the main approaches to data ownership across microservices: a single owning service as source of truth, replicated read models kept in sync via events, and API composition at query time. For a product that needs low-latency pricing reads alongside eventually-consistent inventory data, which approach (or combination) would you choose, and how would you support a query that needs fields owned by two different services without a cross-service join?
Sample Answer
Direct answer
The three main approaches to data ownership across microservices are: a single service acting as the source of truth that everyone reads from directly (simplest to reason about, but couples every reader to that service's availability and latency), replicated read models kept in sync via events (readers query their own local, eventually-consistent copy, trading a small consistency lag for independence and speed), and API composition at query time (a caller assembles the answer by calling several owning services and combining the results, keeping strong consistency but adding latency and coupling every read to every owner's availability).
Structured elaboration
Single-source-of-truth reads are the right default when correctness matters more than the reading service's independent availability and latency, and when the read volume is low enough that hitting the owning service directly doesn't become a bottleneck. Replicated read models are the right choice when a consumer needs low-latency, high-volume reads and can tolerate a short staleness window (seconds, not hours); the owning service publishes a canonical event stream whenever its data changes, and consumers build their own read-optimized copy from that stream. API composition sits in between: it avoids duplicating data (nothing is replicated, so there's no staleness to manage) but every composed read now depends on every service it calls being up and fast, which can turn a simple query into a slow, fragile fan-out if not designed carefully (with timeouts, partial-result handling, and caching where it matters).
Worked example
For a product needing low-latency pricing reads with eventual consistency acceptable for inventory: pricing, which changes relatively rarely and needs to be read extremely fast on every product page, is a strong candidate for a replicated read model, cached aggressively in the reading service and refreshed via a Pricing-changed event stream. Inventory, where eventual consistency is explicitly acceptable, can also use a replicated model, refreshed on its own change stream, with the understanding that a very recent update might lag by a second or two before every reader sees it. Where a query needs fields owned by two different services and there's no dedicated read model built for that exact combination, the fallback is API composition: call Pricing and Inventory in parallel, with a timeout and a documented fallback (like showing a cached last-known price) if one of them is slow, rather than letting the whole page hang on the slowest owner.
Trade-offs and pitfalls
The most common mistake with replicated read models is treating the replicated copy as a second source of truth and allowing writes against it, which reintroduces exactly the data-ownership ambiguity the pattern was meant to avoid; a replicated read model should always be read-only, with all writes going through the owning service's canonical event stream. The most common mistake with API composition is skipping timeout and partial-failure handling, so a single slow downstream service degrades every caller's latency instead of being isolated to just the field it owns; a well-designed composition layer degrades gracefully (showing what it has, with a clear fallback for what it couldn't fetch in time) rather than failing the whole request.
Explain how Domain-Driven Design concepts like bounded contexts, aggregates, and ubiquitous language influence microservice boundaries. Give an example mapping DDD concepts to services for a payments-and-billing domain, and name one mistake architects commonly make when they equate every code module to its own microservice.
Sample Answer
Direct answer
A bounded context is a boundary within which a specific business concept has one precise, consistent meaning; the same word can mean different things in different contexts (an "order" means a customer purchase in the Sales context and a warehouse picking task in the Fulfillment context), and a bounded context is the boundary that keeps those meanings from colliding. It's the natural starting point for drawing service boundaries because a coherent bounded context is already a low-coupling, internally-consistent unit of the domain.
Structured elaboration
A bounded context is defined by its ubiquitous language, the shared vocabulary that a team and its stakeholders use consistently within that boundary; when the same term needs different definitions depending on who's using it, that's usually the signal that you're looking at two contexts, not one. Within a context, an aggregate is the consistency boundary for a single business transaction (for example, an Order aggregate that enforces its own invariants, like "an order's total must match the sum of its line items," as a single atomic unit), and aggregates are the building blocks a bounded context is made of.
For a payments-and-billing domain, a Payments bounded context might own the concepts of a transaction, an authorization, and a settlement, each with its own aggregate and its own precise meaning of terms like "amount" (post-fees or pre-fees, for example); a Billing bounded context might separately own the concept of an invoice and a subscription, where "amount" means something contractual rather than transactional. Even though both contexts touch money, mapping them to two separate services (rather than one "Money" service) follows directly from the fact that their ubiquitous languages and consistency boundaries genuinely differ.
Worked example
The common mistake architects make is equating every code module or every noun in the domain to its own microservice, treating "Bounded Context = Service" as a mechanical, one-to-one rule rather than a starting point for judgment. A bounded context is a good place to START looking for a service boundary because it's already internally coherent, but a very small, tightly-related pair of bounded contexts (say, Authorization and Settlement within Payments, if they share the same team, the same consistency requirements, and change together) can reasonably stay in one service, while a genuinely large bounded context might still need to be split further along a different axis (like read/write access patterns) once it's grown large enough.
Trade-offs and pitfalls
The risk of treating bounded contexts too literally as service boundaries is producing more services than the org can operate well, each one technically "correct" by the Domain-Driven Design (DDD) definition but not justified by any real difference in scaling, ownership, or release cadence. The opposite risk, ignoring bounded contexts entirely and drawing service boundaries along purely technical or organizational lines, tends to produce services whose internal data model is internally inconsistent, because two different meanings of the same term (like "order") end up living in the same service without a clear boundary between them.
For a 100-engineer organization, propose a team-ownership model for a large microservice landscape. Compare 'service-per-team', 'feature teams that share services', and a dedicated platform-team model, covering governance, shared libraries, and how cross-team changes get made under each.
Sample Answer
Direct answer
For a 100-engineer organization, the three common team-ownership models are service-per-team (each team owns a small, dedicated set of services end to end), feature teams sharing services (cross-functional teams that ship features but don't uniquely own the services they touch), and a dedicated platform team (owning shared infrastructure that every other team builds on); most organizations at this size end up needing a combination, service-per-team for product-facing services plus a platform team for shared concerns, rather than picking one model exclusively.
Structured elaboration
Service-per-team gives the clearest accountability (one team, one on-call rotation, one release cadence per service) and the strongest Conway's Law alignment, but it can lead to duplicated effort across teams solving similar infrastructure problems independently, and it struggles when a feature genuinely needs coordinated changes across several services owned by different teams. Feature teams sharing services optimize for shipping cross-cutting product features quickly, since a team can touch whatever services a feature needs without waiting on another team's roadmap, but they create ambiguous ownership (who's on-call when a shared service breaks, whose roadmap does a needed change compete against) and tend to erode the clean boundaries a service-per-team model would otherwise maintain. A platform-team model centralizes shared infrastructure (deployment pipelines, observability, core libraries) so product teams don't each reinvent it, but if under-resourced relative to demand, it becomes a bottleneck every other team is waiting on.
Worked example
A workable combination at 100 engineers: organize the majority of engineers into a handful of product-facing teams, each owning a small, clear set of services end to end (service-per-team for ownership and on-call clarity), carve out one platform team (perhaps 10-15% of headcount) providing the shared deployment, observability, and core-library tooling every product team depends on, and use temporary, cross-team "feature squads" only for genuinely cross-cutting initiatives that need coordinated changes across several product teams' services, disbanding them once the initiative ships rather than making shared, ambiguous ownership permanent.
Trade-offs and pitfalls
Governance needs to track which model a given piece of work actually fits: a well-understood, product-facing feature fits cleanly inside one team's service-per-team ownership; a genuinely cross-cutting initiative (say, adding a new compliance requirement across every service) needs either a temporary cross-team squad or, if it recurs often enough, its own dedicated team. Shared libraries are a common pitfall regardless of model: without a clear owner and a versioning discipline, a shared library becomes either everyone's problem (nobody prioritizes fixing it) or a de facto dependency that quietly recouples otherwise-independent services, since a breaking change to the shared library now has to be coordinated across every team using it, the same coordination cost service-per-team was meant to avoid.
Unlock Full Question Bank
Get access to all 34 Microservices Architecture and Service Decomposition interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.