Microservices Interview Questions

February 26, 2026By Surya SinghSystem Design • Microservices • Architecture • Interview

Microservices architecture interview questions — service discovery, API gateway, event-driven design.

System DesignMicroservicesArchitectureInterview

Key Takeaways

  • 1Microservices split an app into small, independent services, each owning its data and deployed separately.
  • 2Benefits: independent scaling, technology flexibility, fault isolation. Drawbacks: operational complexity, distributed tracing, eventual consistency.
  • 3Communication: synchronous (REST, gRPC) vs asynchronous (message queues, event-driven).
  • 4Patterns: API Gateway, service discovery, circuit breaker, saga for distributed transactions.

The questions below are commonly asked in technical interviews. Each answer is written to help you understand the concept clearly and explain it confidently. Focus on understanding the "why" behind each answer—that is what interviewers care about.

Interview Questions & Answers

What are microservices and how do they differ from a monolith?

A monolith is a single deployable unit with all features in one codebase and one database. Microservices split the system into small services—each handles one business capability (e.g., user service, order service, payment service) and owns its data. Services communicate via APIs or events. Each service can be developed, deployed, and scaled independently. A monolith is simpler to operate but harder to scale and change; microservices add flexibility but require dealing with distributed systems—networks, failures, and consistency.

How do microservices communicate and when do I use sync vs async?

Synchronous: REST or gRPC. The caller waits for a response. Use when you need an immediate answer (e.g., check user balance before placing an order). Async: message queues (Kafka, RabbitMQ, SQS). The sender publishes a message and does not wait. Use when the operation can be handled later (e.g., send email, update analytics) or when you want to decouple services. Async improves resilience (if the consumer is down, messages queue up) but you must handle eventual consistency and idempotency.

What is the saga pattern for distributed transactions?

In a monolith, you use a database transaction. In microservices, each service has its own database, so you cannot have a single ACID transaction. A saga is a sequence of local transactions, each with a compensating action if a later step fails. For example, Order service creates an order, Payment service charges the card, Inventory service reserves items. If Inventory fails, you run compensation: refund the payment and cancel the order. Implement as choreography (each service emits events and reacts) or orchestration (a central coordinator tells each service what to do and handles rollback).

What is an API Gateway and why use it?

An API Gateway is a single entry point for clients. It routes requests to the appropriate microservice, can handle authentication (validate JWT, forward user ID), rate limiting, SSL termination, and request/response transformation. Without it, clients would need to know and call each service directly, and you would duplicate auth and rate limiting in every service. The gateway can also aggregate responses from multiple services (BFF pattern) to reduce round trips. Examples: Kong, AWS API Gateway, Nginx, Envoy.

How do I handle service discovery in microservices?

Services need to find each other. In a small system, you might hardcode URLs or use environment variables. For dynamic scaling, use a service registry: each service registers itself (IP, port, health) on startup and deregisters on shutdown. When service A needs to call service B, it queries the registry for B's address. Implementations include Consul, Etcd, ZooKeeper, or cloud-native options (Kubernetes DNS, AWS Cloud Map). DNS-based discovery (e.g., servicename.namespace.svc.cluster.local in K8s) avoids a separate registry.

Loading...

Surya Singh

Surya Singh

Azure Solutions Architect & AI Engineer

Microsoft-certified Azure Solutions Architect with 8+ years in enterprise software, cloud architecture, and AI/ML deployment. I build production AI systems and write about what actually works—based on shipping code, not theory.

  • Microsoft Certified: Azure Solutions Architect Expert
  • Built 20+ production AI/ML pipelines on Azure
  • 8+ years in .NET, C#, and cloud-native architecture