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.
Define a framework for deciding HOW to decompose a system into services: by business domain (Domain-Driven Design), by technical surface area (e.g. data-store boundaries), or by team boundaries. Explain the trade-offs of each axis in terms of coupling, deployment independence, cognitive load, and cross-cutting concerns like auth and logging. Apply your framework to a concrete product (for example one with billing, user management, and content delivery) and justify the decomposition you'd choose.
Sample Answer
Direct answer
There are three common axes for deciding how to decompose a system into services: by business domain (Domain-Driven Design's bounded contexts), by technical surface area (splitting along data-store or infrastructure boundaries), or by team boundaries (whoever owns a piece of functionality gets a service). Business-domain decomposition is the default that ages best, because it tracks how the business actually changes over time; the other two axes are useful corrective signals, not primary decomposition strategies on their own.
Structured elaboration
Each axis optimizes for something different, and each has a failure mode when used alone. Business-domain decomposition (what does billing mean, what does user management mean, what does content delivery mean, each becoming its own service with its own data) tends to produce services whose boundaries stay stable even as the implementation underneath changes, because business concepts change more slowly than code. Technical-surface decomposition (split wherever the data store or infrastructure naturally differs, for example an analytics pipeline that needs a column store versus an online-transaction-processing (OLTP) path that needs a row store) is a good secondary signal, since forcing two workloads with very different infrastructure needs into one service creates real operational friction, but decomposing purely along technical lines without regard to the business concept tends to produce services that don't map to anything a product manager or a new engineer can reason about. Team-boundary decomposition (whoever owns it gets a service) optimizes for deployment autonomy and follows Conway's Law directly, but used alone it tends to fragment a single business concept across several services just because the org chart happened to split that way, creating coordination overhead between services that should have been one.
Worked example
Applying this to a product with billing, user management, and content-delivery features: billing and user management are natural, stable business-domain boundaries, each becoming its own service with a clear owner. Content delivery is more of a technical-surface concern (the actual bottleneck is serving large media efficiently, which pulls in content-delivery-network (CDN) and caching infrastructure decisions that don't map neatly to a single business domain); treating it as its own service is justified less by "it's a distinct business capability" and more by "it has a genuinely different infrastructure and scaling profile from the rest." If the org later splits user management across two teams (one for authentication, one for profile data) without a real business reason for the split, that's the team-boundary axis fragmenting a domain that should stay together, and it's worth pushing back on.
Trade-offs and pitfalls
The most common decomposition mistake is applying the technical-surface or team-boundary axis as the primary driver instead of a secondary check, producing services with unclear ownership from a product perspective, or services whose boundary exists only because two teams happen to sit in different parts of the org chart. Coupling shows up differently depending on the axis: business-domain decomposition risks under-splitting a domain that's actually grown too large for one team; technical-surface decomposition risks over-splitting a coherent business concept across several infrastructure-driven services; team-boundary decomposition risks mirroring org chart churn directly into architecture churn. The practical fix in all three cases is the same: use business domain as the default lens, and only cross it with the other two axes when there's a concrete, measurable reason (a genuinely different infrastructure need, or a genuinely different release cadence for a sub-piece of the domain).
A user-profile subsystem for a global application needs to serve a large, latency-sensitive user base. Describe how you would decompose responsibilities across services (for example profile storage, authentication, preferences, avatar/media processing): where you'd draw the boundaries, whether each inter-service call should be synchronous or asynchronous, how you'd isolate one service's failures from the others, and how the owning teams should coordinate their APIs and contracts.
Sample Answer
Direct answer
For a global, latency-sensitive user-profile subsystem, a reasonable decomposition splits Profile Storage, Authentication, Preferences, and Avatar/Media Processing into separate services, each with a clearly different access pattern and failure-isolation need, communicating synchronously only where a request genuinely can't proceed without an immediate answer.
Structured elaboration
Authentication is kept separate because it's a security-sensitive, extremely high-frequency, low-latency dependency that nearly every other request needs to check, and isolating it means an issue in less-critical functionality (like avatar processing) can never take down the ability to authenticate a request. Profile Storage owns the core profile fields (name, settings, account state) and needs to be read on nearly every request, so it's optimized for fast, simple reads, kept narrowly scoped to just that core data rather than accumulating every profile-adjacent feature over time. Preferences (notification settings, UI preferences, and similar lower-stakes, less frequently-read data) is split out specifically because it doesn't need the same latency or availability guarantees as core profile and authentication data; if the Preferences service is slow or briefly unavailable, the rest of the profile experience should still work with sensible defaults, whereas Authentication being unavailable is a much more serious failure. Avatar/media processing is naturally asynchronous (resizing, transcoding, or moderating an uploaded image takes real time and doesn't need to block the rest of the profile experience) and has a very different resource profile (CPU/IO-heavy batch-style work) from the fast, simple reads the other services handle, making it a clear candidate for its own service with its own scaling behavior.
On communication choices: reading a user's core profile (needed on most page loads) should be synchronous, since the caller can't meaningfully proceed without it; updating a display avatar can be asynchronous, since the caller doesn't need to wait for image processing to finish, just for the upload to be accepted. Failure isolation follows from the split: if Avatar Processing is degraded, users can still authenticate, read their profile, and use the rest of the product, with a graceful fallback (a default avatar, or the previous one) rather than the whole profile experience failing.
Worked example
For team coordination across these services: the team owning Authentication needs the strictest change-management discipline given its security sensitivity and blast radius if it breaks, and its API contract with the other three services should be the most stable and carefully versioned of the four; Profile Storage's API needs to stay backward-compatible for the many other services and clients that read from it directly; Preferences and Avatar Processing, being lower-stakes and more independently used, can iterate faster with a lighter review process, as long as their optional, non-blocking nature is preserved (nothing else should come to depend on them synchronously in a way that would undo the isolation benefit).
Trade-offs and pitfalls
The most common mistake in a decomposition like this is letting Profile Storage's scope creep to absorb Preferences or other adjacent data over time ("it's just one more field"), which quietly recreates the coupling the split was meant to avoid; keeping the boundary honest requires treating a new field's home as a deliberate decision (does this need Profile Storage's stricter availability and latency guarantees, or can it live in the more relaxed Preferences service) rather than defaulting to wherever's most convenient to add it.
Explain what a microservices architecture is and how it differs from a monolithic architecture. Cover how service boundaries and deployment differ between the two styles, and the main trade-offs across development velocity, operational complexity, testing, and fault isolation. Give one concrete scenario where you would recommend a monolith and one where you would recommend microservices.
Sample Answer
Direct answer
A monolith is a single deployable unit that contains all of an application's functionality and typically talks to one shared database. A microservices architecture splits that functionality into a set of independently deployable services, each owning its own data and communicating with the others over the network (HTTP, gRPC, or messaging). The core trade-off is operational and organizational complexity (many moving parts, network calls where there used to be function calls) traded for independent deployability and independent scaling of each piece.
Structured elaboration
Four dimensions decide which style fits a given system:
- Deployability: in a monolith, every release ships the whole application together, so a one-line change and a schema migration go out in the same deploy. In microservices, each service ships on its own schedule, but that independence only pays off once you also have per-service CI/CD, versioned contracts between services, and a way to test one service's change without spinning up the whole system.
- Team scaling: a monolith lets a handful of engineers move fast because there is one codebase and one deploy pipeline to reason about. As the team grows past roughly 20-30 engineers, a shared codebase and shared release train start to produce merge contention and "who owns this file" ambiguity; independently-owned services give each team a boundary to work inside without coordinating every change with everyone else.
- Scaling the system: a monolith scales by running more copies of the whole application, even if only one code path (say, search) is actually hot. Microservices let you scale the hot path's service independently, at the cost of running and monitoring more separate processes.
- Operational overhead: a monolith has one thing to deploy, log into, and page on-call for. Microservices multiply that by the number of services: more deployment pipelines, more inter-service contracts to keep backward-compatible, more places a request can fail partway through, and a genuinely different debugging experience (a single stack trace becomes a distributed trace across several services).
Worked example
A payments feature that reconciles overnight batches for one company and needs to add a new reconciliation rule once a quarter is a poor fit for microservices: the team is small, the release cadence is low, and there is no independent-scaling need, so a monolith (or a module inside one) minimizes operational overhead for the actual rate of change. A checkout system at a retailer during a high-traffic sale, by contrast, needs to scale the payment-authorization path independently of the product-catalog browsing path, and different teams own each; that combination of an independent-scaling need and independent-team-ownership need is what makes the added operational cost of a separate service worth paying.
Trade-offs and pitfalls
The most common mistake is treating microservices as inherently "better" architecture rather than a trade of operational complexity for independent deployability and scaling. A small team adopting microservices before it has the release cadence, team count, or scaling need to justify it typically pays the distributed-systems tax (network failures, harder debugging, contract versioning) without getting the corresponding benefit. The reverse mistake, staying monolithic well past the point where deployment coordination and scaling mismatch are actively slowing the team down, is just as real; the earlier answer about a modular monolith gives one commonly-used middle ground between the two.
Explain the strangler fig pattern for migrating a monolith to microservices: the role of a routing/intercept layer, the role of anti-corruption layers when the new service must still talk to the old monolith's data, and how you would manage shared-database access during the transition period. Describe how you'd prioritize which components to extract first.
Sample Answer
Direct answer
The strangler fig pattern migrates a monolith to microservices incrementally: you place a routing layer in front of the monolith, redirect one slice of functionality at a time to a newly-built service behind that layer, and let the monolith's role shrink slice by slice until, eventually, it can be retired, rather than attempting a single big-bang rewrite.
Structured elaboration
The routing (or intercept) layer is the mechanism that makes this incremental: it sits in front of the monolith and inspects each incoming request, forwarding requests for the not-yet-migrated functionality to the monolith as before, and requests for the newly-extracted slice to the new service instead. Because the routing decision happens per-request, the cutover for any one slice can be gradual (a percentage of traffic, or a specific subset of users) and reversible (route back to the monolith if the new service misbehaves), rather than an all-at-once switch.
An anti-corruption layer handles the case where the new service still needs to talk to the old monolith, either because the monolith still owns some data the new service needs, or because other parts of the monolith still call into the functionality that's now been extracted. Rather than letting the new service's clean domain model get contaminated by the monolith's legacy data shapes and conventions, the anti-corruption layer translates between the two, so the new service's internal model stays coherent even while it's still dependent on the old system underneath.
Managing shared database access during migration is the trickiest part: in the transition window, both the monolith and the new service may need to read or write data that hasn't fully moved yet. A common approach is dual-write (the monolith continues writing to its tables while also publishing changes the new service consumes) with reconciliation to catch drift, or a change-data-capture stream from the monolith's database that the new service consumes without writing to the monolith's tables directly, avoiding a genuine two-way dependency on the same schema.
Worked example
Prioritizing which components to extract first: start with a slice that's relatively self-contained (few dependencies on the rest of the monolith), has a clear owning team ready to take it on, and delivers a visible win (either operational, like removing a frequent source of incidents, or business, like unblocking a team that's currently release-blocked by the monolith's shared deploy train). Extracting the riskiest, most deeply-entangled part of the monolith first, even if it's the part causing the most pain, tends to produce the highest-risk first migration when the team has the least experience running this pattern; a smaller early win builds the operational muscle (routing, dual-write, monitoring the new service) that the harder extractions will need later.
Trade-offs and pitfalls
The most common failure is leaving the routing layer and the dual-write/reconciliation logic in place indefinitely instead of treating them as temporary migration scaffolding; if a slice never gets fully cut over (the monolith keeps a code path alive "just in case"), the system ends up permanently carrying the complexity of both the old and new implementations, which is worse than either the original monolith or a clean microservice on its own.
Compare polyglot persistence (each bounded context choosing its own storage technology) with a single database technology standardized across all bounded contexts. Discuss the trade-offs in operational overhead, developer autonomy, backup/restore/recovery complexity, and data-migration difficulty, and describe when polyglot persistence earns its added complexity.
Sample Answer
Direct answer
Polyglot persistence means each bounded context picks the storage technology that fits its own access pattern (a graph database for a recommendations service, a document store for a catalog service, a relational database for a transactional payments service), while single-database-technology-per-bounded-context still gives each service its own schema and its own database instance, but standardizes on one storage technology (usually relational) across all of them. Polyglot persistence is justified when a service's access pattern is genuinely a poor fit for the standard choice, not merely because a newer technology looks appealing.
Structured elaboration
The case for polyglot persistence: a service whose core operation is graph traversal (like finding connections between entities several hops apart) performs and scales dramatically better on a graph database than forcing that traversal into relational joins; a service that's fundamentally a high-write-throughput time series (metrics, events) is a much better fit for a time-series-optimized store than a general relational database. The case against defaulting to it everywhere: every additional storage technology in production is a new thing to operate (backup strategy, failover strategy, monitoring, and staff who actually know how to run it well), and a team spread across five different database technologies has a much smaller bench of people who can debug any one of them under pressure than a team standardized on one or two.
The trade-offs concretely: operational overhead scales roughly with the number of distinct storage technologies in production, not the number of service instances, so ten services all using the same relational database technology (even in separate schemas) is operationally simpler than three services each using a different specialized store. Developer autonomy goes the other way: a team that owns its own service and its own storage choice can move faster on its own roadmap without waiting for a shared database team's priorities, but that autonomy is exactly what makes a later data-migration or recovery effort harder, since there's no common tooling or shared expertise across a genuinely polyglot fleet. Backup, restore, and recovery complexity multiplies with each distinct technology, since a well-tested disaster-recovery runbook for a relational database usually doesn't transfer to a graph database or a time-series store.
Worked example
A pragmatic middle ground: standardize on one or two default storage technologies (say, a relational database for anything with clear transactional needs, and a document store for anything schema-flexible) that cover the vast majority of services, and reserve a genuinely specialized technology (graph, time-series, search index) for the specific services whose access pattern would be actively painful on the default, requiring an explicit justification and sign-off rather than letting every team pick whatever's currently popular.
Trade-offs and pitfalls
The failure mode on the polyglot side is technology sprawl: a dozen services each independently choosing whatever database is trendy, with no shared operational playbook, so an incident in any one of them requires expertise the rest of the org doesn't have. The failure mode on the standardization side is forcing an access pattern that's fundamentally a poor fit (heavy graph traversal, for example) into a relational model, producing queries that are slow, hard to maintain, and eventually get worked around with ad hoc caching layers that recreate the complexity a purpose-built store would have handled natively.
Unlock Full Question Bank
Get access to all 37 Microservices Architecture and Service Decomposition interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.