📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Your company has around 40 microservices, six teams, and delivery has slowed down: most features need changes in several services and releases are coordinated. How would you assess whether to consolidate services, decide which ones to merge, and carry it out without stopping feature work?

Assessing an over-split microservices estate with data (change coupling, call graphs, ownership, cost and DORA metrics), deciding which services to merge into fewer, team-aligned services or a modular monolith, and executing the consolidation incrementally with stakeholder buy-in.

Staff / Architect Architecture Expert architecture-decisions distributed-systems dora-metrics microservices modular-monolith service-consolidation

🎯 Key points

  • Measure before deciding: DORA metrics, PRs touching multiple services, coordinated releases, incident causes, cloud cost per service
  • Build a change-coupling and call graph from git history and distributed traces; services that change and deploy together are candidates to merge
  • Map services to teams: 40 services for 6 teams (~7 each) is a cognitive-load and on-call problem
  • Merge along business capabilities into team-aligned services or modular monoliths with enforced internal modules; keep async event-driven links between teams' services
  • Keep separate what has a real reason: different scaling, availability, security or compliance (e.g. payments, PII), or a different owning team
  • Consolidate incrementally: one cluster at a time, code into modules first, then data; external routes and events stable behind YARP or Azure API Management; cut over with feature flags or weighted routing and keep the old service running until traffic is drained
  • Record the decision in ADRs with success measures; sell it as lead-time and cost improvement, not as "microservices failed"
  • Prevent re-fragmentation with boundary criteria for new services and architecture tests

⏱ 30-second answer

Start with evidence, not opinions: DORA metrics, the share of PRs touching several services, coordinated releases, incident causes and cost per service. Build a change-coupling graph from git history and a call graph from traces: services that change, deploy and fail together are one thing pretending to be several. Map services to teams: 40 services for six teams means each team runs ~7, which is too much cognitive load and on-call surface. Merge clusters along business capabilities into team-aligned services or modular monoliths with enforced modules, and keep separate only what has a real reason (scaling, availability, compliance, a different team). Do it incrementally, one cluster at a time, behind stable external contracts, and record it in ADRs with measures. The trade-off: fewer deployables means less independence per component, which is fine when teams, not components, are the unit of independence.

🗣 Full answer (senior)

How I would answer this in an interview

"I'd start by treating it as a hypothesis to test, because 'too many services' is a feeling and leadership will want numbers. I'd gather four things over a couple of weeks: DORA metrics per team, the share of pull requests in the last six months that touched more than one service, how many releases needed coordination, and the causes of the last quarter's incidents. Then I'd generate two graphs: a change-coupling graph from git history, which services change in the same week for the same ticket, and a runtime call graph from distributed traces. Clusters that change together, deploy together and call each other synchronously are really one service split across several repos.

For example, at [company] we had [N] services for [M] teams. The data showed [60%] of features touched three or more services, and [one cluster of nine services] always released together. I proposed consolidating that cluster into [two] team-aligned services, each a modular monolith with internal modules enforced by architecture tests, while keeping payments separate because of PCI scope and different availability needs. We did it one cluster at a time: move code into modules first, keep the external routes stable behind the gateway, then merge databases using schemas. Over [two quarters] lead time went from [X] to [Y] and we [retired N pipelines and cut cloud spend by Z%].

I'd present it to leadership as an optimisation of team throughput and cost, not as reversing a mistake, and record it in ADRs with success measures. And I'd put guard rails in so we don't fragment again: criteria for creating a new service, like a different owning team or a genuinely different scaling or compliance need. The mistake I see is either a big-bang 'back to the monolith' rewrite, or doing nothing because merging feels like admitting failure. The unit of independence should be the team, and the number of deployables should follow from that."


Evidence to gather

Signal Source What it suggests
Lead time, deployment frequency, change failure rate, time to restore (DORA) Pipelines, incident tool Baseline and success measure
% PRs/tickets touching ≥2 services Git history, work items Boundaries in the wrong place
Coordinated releases per month Release calendar Distributed monolith
Change coupling between services Commits per ticket or week Merge candidates
Synchronous call depth and chattiness Traces (application map) Latency and fragility
Services per team, pages per team Catalogue, on-call tool Cognitive load
Cost per service (compute, databases, pipelines) Azure Cost Management tags Fixed overhead of many small services

Merge or keep separate?

Merge when… Keep separate when…
Same owning team Different owning teams
Change and deploy together Change independently
Chatty synchronous calls between them Mostly async, few interactions
Same scaling and availability profile Very different load or SLOs
No special compliance boundary Different security or compliance scope (payments, health or identity data)
Tiny services with more pipeline than code Large enough to justify their overhead

Target shapes

Shape Fits
Team-aligned service (one per team or capability) Most clusters
Modular monolith per team Several capabilities, one team, strong internal boundaries
Keep as is Real independence reasons

Production example

Consolidating [40] services into [14] for [6] teams cut coordinated releases from ~8 a month to ~1, lead time from ~9 days to ~3, and Azure spend by ~25% from fewer databases, App Service plans and pipelines, while keeping payments and identity as separate services.

🔍 What the interviewer is checking

Checks staff-level judgement: using evidence to reshape an architecture to fit the organisation, and executing it safely with buy-in.

Green flags

  • Gathers data first (DORA, change coupling, traces, cost, team load)
  • Clear merge vs keep criteria including compliance and scaling
  • Incremental execution with stable external contracts and internal module boundaries
  • ADRs, success measures and guard rails against re-fragmentation
  • Frames it for leadership in business terms

Red flags

  • "Rewrite it as a monolith"
  • Merges everything regardless of teams or compliance
  • No measurement or stakeholder plan

📚 Learn in depth

1. How estates get over-split

Common causes: splitting by entity or layer, "one service per developer" enthusiasm, copying Netflix-scale architecture with a fraction of the teams, and reorganisations that leave services behind. The result is a distributed monolith: separate deployables, joint releases, and every feature crossing the network several times.

2. Change coupling analysis

From git history (or work items), count how often two services change for the same ticket or within the same short window.

            Catalogue  Pricing  Stock  Promotions  Orders  Payments
Catalogue       -        41      37       29         6       0
Pricing        41        -       33       35         5       1
Stock          37       33        -       12         9       0
Promotions     29       35       12        -         3       0
Orders          6        5        9        3         -      14
Payments        0        1        0        0        14       -
(shared tickets, last 6 months)

The top-left block is one capability (Catalogue) in four pieces. Orders–Payments coupling is moderate and Payments has a compliance reason to stay separate. Tools: git log scripts, CodeScene, or work-item queries.

3. Runtime call graph

From traces, list synchronous edges with call counts and latency. Long chains (≥3 hops in a user request) and high call counts between two services both point to merges or to replicating data via events.

4. Team cognitive load

Team Topologies' point: a team can only own so much. Six teams with 40 services means ~7 each, each with pipelines, dashboards, dependencies to patch and alerts. Consolidating per team reduces that without reducing team independence.

5. Executing a merge

Step 1: code         Step 2: hosting        Step 3: data              Step 4: clean up
Pricing repo  --->   Catalogue host runs    pricing schema moves      delete old pipeline,
moved as a module    both modules; gateway  into catalogue DB;        infra, alerts; update
inside Catalogue     routes /prices to it   in-process calls replace  catalogue entry
solution             (YARP / APIM)          HTTP between modules

Principles:

  • External contracts stay the same: routes, events and auth scopes don't change for other teams; the gateway or YARP hides the move.
  • Modules keep boundaries inside the merged service: separate projects, internal types, architecture tests, schema per module. That keeps the option to split again.
  • One cluster at a time, each a few sprints, alongside feature work.
  • Measure after each step against the baseline.

6. Selling it

Frame for leadership: lead time, change failure rate, on-call load and cloud cost. Avoid "microservices were a mistake": the original split may have suited a different organisation. Record in ADRs: context, evidence, decision, consequences and measures. Agree criteria for new services so the estate doesn't drift back.

Try it yourself

  1. Write a script that maps commits to services by path and work-item id, and builds a co-change matrix for the last six months.
  2. Export the application map or trace dependencies and count synchronous hops for your top five journeys.
  3. Tag Azure resources by service and pull a cost-per-service report from Cost Management.
  4. Draft an ADR for merging two tightly coupled services, with three success measures.

💻 Code

Merging two services into one host as separate modules, keeping their external routes and an enforced boundary.

// Catalogue host after consolidation: Pricing is a module, not a separate service.
using Catalogue.Module;
using Pricing.Module;

var builder = WebApplication.CreateBuilder(args);

builder.AddCatalogueModule(); // own DbContext on schema "catalogue"
builder.AddPricingModule();   // own DbContext on schema "pricing"; exposes IPricingApi to other modules

var app = builder.Build();

// External routes unchanged, so consumers and the gateway config don't need to change.
app.MapGroup("/products").MapCatalogueEndpoints();
app.MapGroup("/prices").MapPricingEndpoints();

app.Run();
namespace Pricing.Module;

// The module's public surface: an in-process interface replaces the old HTTP client.
public interface IPricingApi
{
    Task<decimal?> GetPriceAsync(string sku, CancellationToken ct);
}

internal sealed class PricingApi(PricingDbContext db) : IPricingApi
{
    public async Task<decimal?> GetPriceAsync(string sku, CancellationToken ct) =>
        await db.Prices.Where(p => p.Sku == sku).Select(p => (decimal?)p.Amount).SingleOrDefaultAsync(ct);
}
// Architecture test: Catalogue may use Pricing's public API only, never its internals or DbContext.
[Fact]
public void Catalogue_uses_only_pricing_public_api()
{
    var result = Types.InAssembly(typeof(Catalogue.Module.CatalogueModule).Assembly)
        .ShouldNot().HaveDependencyOnAny("Pricing.Module.Data", "Pricing.Module.Domain")
        .GetResult();

    Assert.True(result.IsSuccessful);
}

⚠ Common mistakes

  • Mistake: Deciding from opinions ("microservices are too complex"). Why it is wrong: no baseline, no buy-in, no way to show success. Instead: DORA metrics, change coupling, call graphs and cost.
  • Mistake: Big-bang return to a single monolith. Why it is wrong: months of no features and high risk. Instead: one cluster at a time, alongside feature work.
  • Mistake: Hard cutover from the old services to the merged one. Why it is wrong: no quick way back if the merged host misbehaves under real load. Instead: deploy the merged host alongside the old services, shift traffic gradually with weighted routes in YARP or API Management (or blue-green slots) and feature flags, compare error rates and latency, and keep the old service until traffic is drained.
  • Mistake: Merging services owned by different teams. Why it is wrong: creates a shared deployable and coordination again. Instead: consolidate within a team's scope.
  • Mistake: Merging away a compliance or scaling boundary (payments, identity, health data). Why it is wrong: widens audit scope or forces one scaling profile on everything. Instead: keep those separate deliberately.
  • Mistake: Merging code into one big ball with no internal boundaries. Why it is wrong: you lose the option to split later and get a tangled monolith. Instead: modules with schemas, internal types and architecture tests.
  • Mistake: Changing external routes and events during the merge. Why it is wrong: every consumer team has to change too. Instead: keep contracts stable; route via the gateway or YARP.
  • Mistake: Replacing asynchronous events between teams' services with in-process calls after merging too widely. Why it is wrong: re-couples teams' availability and release cycles. Instead: in-process calls only between modules of one team's service; events between teams.
  • Mistake: No guard against re-fragmentation. Why it is wrong: the estate drifts back to 40 services. Instead: written criteria for new services and an ADR per new deployable.

🏛 Senior insight: trade-offs

At staff level the question isn't "microservices or monolith" but matching the number of deployables to the organisation. Independence is valuable at the team level; inside a team, a modular monolith gives most of the structure without the network. The hard part is political: presenting consolidation as an evidence-based optimisation, getting product leaders to fund it alongside features, and avoiding blame for past decisions.

Option When it fits Cost When not to
Keep 40 services, improve tooling Boundaries are right, pain is tooling Platform investment Change coupling is high
Consolidate per capability/team High change coupling, few teams Migration effort over quarters Teams genuinely independent already
Single modular monolith 1–3 teams, one product Loses independent scaling Many teams, different compliance needs
Rewrite Rarely Very high risk Almost always

Measure before and after: lead time, deployment frequency, change failure rate, coordinated releases, pages per team and cloud cost.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate discusses leadership pressure or stakeholder management Why: Checks how they push back on and record architecture decisions driven from above.
    How to answer

    I'd start by asking what problem the mandate is meant to solve: slow delivery, outages, scaling, hiring, or a board-level "modernise" goal. Then I'd gather evidence: DORA metrics, change coupling from git history, incident causes, load data, team structure and cloud cost.

    With four teams and no platform team, 15 services in six months would most likely produce a distributed monolith with higher cost and slower delivery. So I'd propose a phased plan tied to their goal: modularise the monolith with enforced boundaries and team ownership, extract one to three services where there's a measured driver, and build platform capability as we go.

    I'd record it in an ADR with the alternatives and triggers for further splits, and present it in business terms: risk, cost, time to value.

    The trade-off: I'm asking leadership to trade a bold headline for measurable outcomes.

  2. When: Candidate mentions modular monolith as a target Why: Checks they know when and how to split again later.
    How to answer

    I keep a modular monolith until a module has a measured reason to become its own deployable: it needs to scale independently, it has a different release cadence or owning team, it needs fault or security isolation, or it needs a different runtime. "Microservices are modern" isn't a reason.

    The first candidate should have few inbound dependencies, a clean contract and its own schema already. Extraction is incremental: make the module talk only through its contract, stop cross-module joins and transactions, move its data, deploy it as a service, and switch traffic behind a feature flag with a rollback path.

    The trade-off: every extracted module turns method calls into network calls, so you gain autonomy and isolation but pay with latency, partial failures and eventual consistency.

  3. When: Candidate talks about where boundaries should be Why: Checks the boundary criteria they'd use for the merged services.
    How to answer

    Start from business capabilities (ordering, pricing, payments, fulfilment) and bounded contexts, the areas where a word like "Order" has one consistent meaning. A good boundary has one owner for its data and one owning team, and by Conway's law it should match how teams communicate. Test a proposed boundary with real change history and call flows: most features should change one service, and a user request should need few synchronous hops. Wrong boundaries show up as changes that always span services, chatty calls and shared tables. The trade-off: smaller services give more autonomy but more coordination, so start coarse and split when the seam is proven.

🛠 Real-world problems: how you handle them

Consolidating an over-split estate of 40 services for six teams
Situation
A [retail] company with [40] .NET microservices on AKS and [6] product teams; most services were [under 3,000 lines] and had been split by entity [three years earlier].
Signals
Lead time ~9 days; ~8 coordinated releases a month; 60% of features touching three or more services; on-call pages spread across many small services; Azure spend rising with [40] databases and pipelines; engineers complaining about time spent on dependency updates.
Investigation
Built a co-change matrix from six months of commits and work items; exported the application map to count synchronous hops per journey; mapped services to teams and pages per team; pulled cost per service from Cost Management tags; interviewed team leads.
Resolution
Proposed consolidation into [14] team-aligned services (modular monoliths where a team owned several capabilities), keeping payments and identity separate for compliance and availability. Executed cluster by cluster over [two quarters]: code into modules first, external routes kept stable behind the gateway, then databases merged as schemas; old pipelines and infrastructure retired.
Prevention
ADRs per consolidation with measures; criteria for new services (different team, scaling, compliance) reviewed by the architecture forum; architecture tests enforcing module boundaries; quarterly review of change coupling and DORA metrics.

How to tell it (STAR)

**S:** At [company] we had [40] microservices for [six] teams, and features routinely needed changes and coordinated releases across several services. **T:** As [staff engineer / architect] I was asked whether our architecture was slowing us down and what to do. **A:** I gathered evidence: DORA metrics, a co-change matrix from git history, call graphs from traces, services and pages per team, and cost per service. It showed a few clusters that always changed together. I proposed merging them into team-aligned services with enforced internal modules, kept payments and identity separate, wrote it up as ADRs with targets, and we did it one cluster at a time without pausing features. **R:** Over [two quarters] coordinated releases fell from [~8] to [~1] a month, lead time from [~9] to [~3] days, and cloud spend by [~25%].

More in Microservices

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me