Microservices interview questions and answers for backend engineers

Microservices interview questions test whether you can split a system along business boundaries, keep data correct without distributed transactions, and run many small services without losing sight of failures. Expect questions on service boundaries, synchronous versus event-driven communication, sagas and the transactional outbox, resilience patterns, tracing, deployment and contract testing. The strongest candidates also say clearly when microservices are the wrong choice.

By Published 9 min read

What interviewers are looking for

Microservices questions appear in backend, platform and architect interviews, and inside system design rounds when a design grows past one service. Mid-level candidates are asked to define the patterns and explain their trade-offs. Senior candidates are given a scenario, such as an order flow that charges a card but fails to reserve stock, and asked to keep the data correct, keep the user informed and keep the on-call engineer able to find the fault. Interviewers listen for trade-offs; an answer that treats microservices as automatically better than a monolith is a warning sign.

Fundamentals and decomposition

First-round questions
QuestionWhat it testsWhat a strong answer shows
What is a microservice?DefinitionA small, independently deployable service that owns one business capability and its own data, built and run by one team and reached only through its API or events.
What do you gain, and what do you pay?Trade-offsGains: independent deploys, team autonomy, scaling and technology choice per service. Costs: network failures, eventual consistency, harder debugging, more infrastructure and operational load.
How do you decide service boundaries?DesignFollow business capabilities and domain-driven design's bounded contexts: where a term changes meaning, a boundary is likely. Aim for services that change for one reason and rarely need a coordinated release.
What is a distributed monolith?Anti-patternServices that must be deployed together, share a database or call each other in long synchronous chains. You pay the cost of distribution and keep the coupling of a monolith.
Why one database per service?Data ownershipSo a service can change its schema without breaking others, and no one reads its tables behind its back. Others get data through its API or its events.
How would you migrate a monolith?MigrationThe strangler fig approach: put a routing layer in front, carve out one capability at a time behind it, move its data last, and retire the old code path when traffic is gone.
What does an API gateway do?EdgeOne entry point for clients: routing, authentication, rate limiting, TLS and sometimes response shaping. Keep business logic out of it.
What is a backend for frontend?EdgeA small service per client type (web, mobile) that aggregates calls and shapes responses for that client, so the core services stay generic.
How do services find each other?DiscoveryA registry or the platform's DNS gives a stable name in front of changing instances, with load balancing on the client side, in a proxy, or in a service mesh.
How small should a service be?GranularitySmall enough for one team to own and understand, large enough that most changes stay inside it. Line counts are the wrong measure.
First-round questions. Scroll sideways on a small screen.

Communication and resilience

  • Synchronous or asynchronous calls? Use a request and response (REST or gRPC) when the caller needs the answer now. Use events or messages when work can finish later, when several services react to one fact, or when the caller must keep working while a dependency is down. Long synchronous chains multiply latency and failure.
  • Command or event? A command asks one service to do something ("reserve stock") and can be refused. An event states a fact that already happened ("order placed") and any number of services may react.
  • Why must every remote call have a timeout? Without one, a slow dependency holds threads and connections until the caller runs out and fails too. The timeout should be shorter than the caller's own deadline.
  • How should retries work? Only for errors that may pass, a small number of attempts, exponential backoff with random jitter so clients do not retry in lockstep, and only on idempotent operations or with an idempotency key.
  • What does a circuit breaker do? After repeated failures it stops calling the dependency for a while and fails fast or serves a fallback, then lets a trial request through to test recovery. It protects both sides.
  • What is a bulkhead? Separate pools of threads or connections per dependency, so one slow downstream cannot use up resources that other calls need.
  • How do you handle a message delivered twice? Assume at-least-once delivery. Make consumers idempotent by recording processed message IDs or by making the update naturally repeatable, and send poison messages to a dead-letter queue after a few attempts.
  • How do you keep message order? Most brokers only order within a partition or queue, so route all messages for one entity by its key and design consumers to tolerate gaps and replays.
async function withRetry(fn, { attempts = 4, baseMs = 100, capMs = 2000 } = {}) {
  for (let attempt = 0; ; attempt++) {
    try {
      return await fn();
    } catch (err) {
      const retryable = err.retryable !== false;
      if (!retryable || attempt === attempts - 1) throw err;
      const ceiling = Math.min(capMs, baseMs * 2 ** attempt);
      await new Promise((r) => setTimeout(r, Math.random() * ceiling));
    }
  }
}
Retry with exponential backoff and full jitter: each wait is a random value up to a growing ceiling.

Data consistency: sagas and the outbox

This is where senior interviews spend the most time. A business operation that touches several services (place an order: reserve stock, charge the card, book delivery) cannot use one database transaction. Two-phase commit across services is rarely used because it blocks on a coordinator and few brokers and services support it. The usual answer is a saga: a sequence of local transactions, each publishing an event or replying to a coordinator, with a compensating action for every step that can be undone. The background on why strong consistency costs availability is in consistency and the CAP theorem.

Consistency questions for experienced candidates
QuestionWhat it testsWhat a strong answer shows
Choreography or orchestration for a saga?Saga designChoreography: each service reacts to events, with no central brain; simple for short flows but hard to follow as they grow. Orchestration: a coordinator tells each service what to do and tracks state; easier to reason about and monitor, at the cost of a central component.
What is a compensating transaction?RollbackA business-level undo such as a refund or a stock release. It does not erase history, it must be idempotent, and some steps (an email already sent) cannot be compensated, so put them last.
What is the dual-write problem?AtomicityWriting to your database and publishing to a broker are two operations; a crash between them leaves one done and one not. You either lose the event or announce a change that never committed.
How does the transactional outbox solve it?OutboxWrite the business row and an outbox row in the same local transaction. A relay (polling or change data capture) publishes outbox rows and marks them sent. Delivery becomes at-least-once, so consumers must be idempotent.
What is CQRS and when is it worth it?Read modelsSeparate the write model from read models built from events, so queries that join many services' data are fast. Worth it for heavy, varied reads; overkill for simple CRUD.
Event sourcing versus storing current state?PersistenceEvent sourcing stores every change as an event and derives state by replaying them, which gives a full audit trail and new projections later, but adds schema evolution and replay costs.
How do you answer "show the user their order" when data lives in four services?QueriesAn API composition call for small cases, or a read model kept up to date from events when the view is popular or must be fast.
Consistency questions for experienced candidates. Scroll sideways on a small screen.
BEGIN;
INSERT INTO orders (id, customer_id, total_cents, status)
VALUES ('ord_81', 'cus_7', 4599, 'pending');

INSERT INTO outbox (id, aggregate_id, event_type, payload)
VALUES (gen_random_uuid(), 'ord_81', 'OrderPlaced',
        '{"orderId": "ord_81", "customerId": "cus_7", "totalCents": 4599}');
COMMIT;

-- relay, in its own transaction: claim a batch, publish it, then mark it sent
SELECT id, event_type, payload
FROM outbox
WHERE published_at IS NULL
ORDER BY created_at
LIMIT 100
FOR UPDATE SKIP LOCKED;
The outbox write in PostgreSQL: both rows commit or neither does. The relay then claims unsent rows without blocking other relay instances.
async function runSaga(steps, ctx) {
  const completed = [];
  for (const step of steps) {
    try {
      await step.action(ctx);
      completed.push(step);
    } catch (err) {
      for (const done of completed.reverse()) {
        await done.compensate(ctx); // must be idempotent; a real orchestrator persists state and retries
      }
      return { ok: false, failedAt: step.name, reason: err.message };
    }
  }
  return { ok: true };
}

const placeOrder = [
  { name: "reserveStock", action: async (c) => c.log.push("stock reserved"), compensate: async (c) => c.log.push("stock released") },
  { name: "chargeCard", action: async (c) => c.log.push("card charged"), compensate: async (c) => c.log.push("payment refunded") },
  { name: "bookCourier", action: async () => { throw new Error("no courier in area"); }, compensate: async () => {} },
];

const ctx = { log: [] };
runSaga(placeOrder, ctx).then((result) => console.log(result, ctx.log));
// { ok: false, failedAt: 'bookCourier', reason: 'no courier in area' }
// [ 'stock reserved', 'card charged', 'payment refunded', 'stock released' ]
An orchestrated saga reduced to its core: run steps in order, and on failure run the completed steps' compensations in reverse.

Observability, deployment and testing

  • How do you follow one request through ten services? Distributed tracing: the edge assigns a trace ID, every service propagates it in headers and message metadata, and spans are sent to a tracing backend. OpenTelemetry is the common standard for producing them.
  • What should every service log? Structured logs (JSON) with the trace ID, service name, version and a request ID, so logs can be joined with traces. Never log secrets or full personal data.
  • Which metrics matter per service? Rate, errors and duration for each endpoint and each dependency, plus saturation of pools and queues. Alert on SLO burn, not on every spike.
  • How do you deploy services independently and safely? A pipeline per service, immutable versioned artifacts, canary or blue-green releases with automatic rollback on error rate, and feature flags to separate deploy from release.
  • How do you test without spinning up everything? Unit and component tests inside each service, and consumer-driven contract tests (for example with Pact) that prove a provider still satisfies what each consumer expects. Keep a small number of end-to-end tests for critical journeys.
  • What does a service mesh add? A sidecar or node proxy handles mTLS, retries, timeouts and traffic metrics without code changes. It also adds latency, complexity and another system to operate.
  • How should services authenticate to each other? Mutual TLS or short-lived service tokens, with the end user's identity passed along as a verified token, so each service can make its own authorization decision.
  • How do you manage configuration and secrets across services? Configuration from the environment or a config service, secrets from a secret manager with rotation, and nothing sensitive baked into images or repositories.

When not to use microservices

Judgment questions that senior interviews often end on
QuestionWhat it testsWhat a strong answer shows
A five-person startup wants microservices from day one. Your advice?JudgmentStart with a modular monolith with clear internal boundaries. Split later when a module needs independent scaling, deployment or ownership, and the domain is understood.
What is a modular monolith?AlternativesOne deployable with strict module boundaries enforced in code, each module owning its tables. It keeps most design benefits without network failure modes.
What signals say it is time to split a service out?TimingTeams blocking each other's releases, one part needing very different scaling or availability, or a capability with a clearly separate lifecycle.
Have you ever merged services back together?ExperienceA thoughtful answer names services that always changed together or chatted constantly, and explains how merging reduced latency and failures.
What is the biggest hidden cost of microservices?OperationsOperational load: deployments, monitoring, on-call, versioning and debugging across process boundaries, multiplied by the number of services.
Judgment questions that senior interviews often end on. Scroll sideways on a small screen.

Fictional example

Answering "Customers are charged but some orders never ship"
Interviewer
Orders go through order, payment and fulfilment services. A few customers a day are charged but fulfilment never hears about the order. How would you investigate and fix it?
Candidate
My first guess is a dual write: the order or payment service commits to its database and then publishes an event, and sometimes the publish fails or the process dies in between. To confirm, I would take a few affected order IDs and follow their trace IDs: is there a payment-succeeded span with no matching publish, or a publish that fulfilment never consumed? I would also check the broker's dead-letter queue. If it is the dual write, the fix is a transactional outbox in the payment service so the event commits with the payment, plus an idempotent consumer in fulfilment keyed by order ID, since the outbox can deliver twice. For the customers already affected, a reconciliation job compares paid orders with shipments and replays the missing events. Longer term I would add an alert on paid orders with no shipment after a set time, so we notice before customers do.

Two-week microservices practice plan

  • Days 1 to 3: take a product you know (a food delivery app works well) and draw its bounded contexts. For each, write what data it owns and which events it publishes.
  • Days 4 to 6: build two tiny services that talk over HTTP, then add a timeout, retries with jitter and a circuit breaker. Kill the second service and watch what the first does.
  • Days 7 to 9: implement the outbox with a real database and a polling relay, then make the consumer idempotent and prove it by delivering every message twice.
  • Days 10 and 11: add trace propagation between the services and find a slow call from the trace alone.
  • Days 12 to 14: practice three spoken answers: saga versus two-phase commit, how you would split a monolith, and when you would not use microservices at all.

Microservices questions overlap with design and API rounds. REST API interview questions covers the contracts between services, system design guides work through complete architectures such as a notification system, and Linux interview questions covers the hosts all of this runs on.

Architecture answers can sound complete while skipping the failure cases interviewers listen for. Natively, an AI interview assistant for Mac and Windows, records a transcript of a practice design discussion so you can check afterwards whether you covered retries, idempotency and observability. In practice it can read a screenshot of an architecture diagram or a failing trace and suggest what to check, and with Pro or the free trial it uses the résumé and job description you add. Sessions are saved with notes so you can compare one mock against the next.

Questions people ask

What microservices questions are asked in interviews?

How to find service boundaries, synchronous versus event-driven communication, database per service, sagas, the transactional outbox, retries and circuit breakers, distributed tracing, contract testing and when a monolith is the better choice.

What is the saga pattern?

A way to run a business operation across services as a series of local transactions, with a compensating action for each step, so a failure part-way through is undone at the business level instead of by a distributed transaction.

What is the transactional outbox pattern?

The service writes its business change and an event row in the same database transaction, and a separate relay publishes the event. It avoids losing events when a crash happens between the write and the publish.

When should you not use microservices?

When the team is small, the domain is still unclear or the product is early. A modular monolith keeps clean boundaries without network failures, and services can be split out later when there is a real reason.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP