Microservices Interview Questions and Answers
Microservices interviews are about trade-offs, not definitions. You should be able to say when a monolith is the better choice, how to draw service boundaries around business capabilities, and what you pay for the split: network failures, data consistency, versioning and operational overhead.
Expect the standard toolkit: synchronous versus asynchronous communication, the API gateway, service discovery, the circuit breaker, retries with backoff, bulkheads, the saga pattern for distributed transactions, idempotency, distributed tracing and centralised logging. These answers explain each one with its failure mode.
Questions
- What is the difference between Synchronous and Asynchronous communication in microservices?
- How is REST used in microservices and what are its trade-offs?
- What are gRPC and Protocol Buffers, and when would you use them over REST?
- What problem does GraphQL and schema federation solve in a microservices system?
- What role do Message Queues play in microservices?
- How does Event Streaming with Kafka differ from a traditional message queue?
- What are the core patterns of Event-Driven Architecture (EDA)?
- What is the difference between Choreography and Orchestration?
- What is the Database-Per-Service pattern and why is it important?
- What is Polyglot Persistence?
- What is the Distributed Transaction Problem?
- Explain the Saga Pattern and its two coordination styles.
- Exercise — Saga Pattern: design a booking that reserves a flight and a hotel atomically.
- What is Event Sourcing?
- Exercise — Event Sourcing: rebuild an account balance from an event stream, with snapshots.
- What is CQRS and when should you use it?
- Exercise — CQRS: build a read projection kept in sync with the write side.
- What is the Outbox Pattern and how does CDC support it?
- Exercise — Outbox Pattern: guarantee an event is published exactly when the row is committed.
- How do you handle Eventual Consistency in a microservices system?
- Exercise — Eventual Consistency: make a consumer idempotent and order-tolerant.
- What are the common Failure Modes in distributed systems?
- Explain Timeouts, Retries, and Exponential Backoff.
- Exercise — Timeouts, Retries, and Backoff: wrap a flaky call safely.
- What is the Circuit Breaker pattern?
- Exercise — Circuit Breaker: add fallback behavior when a dependency is down.
- What is the Bulkhead pattern?
- Exercise — Bulkhead Pattern: isolate a slow dependency behind its own pool.
- What are Cascading Failures and how do you prevent them?
- What are Graceful Degradation and Fallbacks?
- How does Service-to-Service Authentication work in microservices?
- How do you manage Secrets Across Services?
- What are the main Deployment Strategies for microservices?
- How do you handle Configuration Management and Feature Flags?
- Exercise — Configuration and Feature Flags: roll out a feature to 5% of users.
- What is Service Discovery and why is it needed?
- Exercise — Service Discovery: register a service and resolve a healthy instance.
- What is the API Gateway pattern?
- What is the Backend for Frontend (BFF) pattern?
- What is a Service Mesh and what problems does it solve?
- What are common Load Balancing Strategies?
- Exercise — Load Balancing Strategies: implement consistent hashing for sticky routing.
- What is Distributed Tracing and why is it essential?
- Exercise — Distributed Tracing: propagate a correlation id across two services.
- What are effective Centralized Logging strategies?
- How do you approach Metrics, Health Checks, and Monitoring?
- Exercise — Metrics and Monitoring: expose a custom business metric and alert on it.
- How do you Test Microservices effectively?
- Describe Netflix's microservices architecture and its key lessons.
- What is Uber's Domain-Oriented Microservices Architecture (DOMA)?
- What do Amazon's "Two-Pizza Teams" and service ownership teach about microservices?
- How do you approach a Monolith-to-Microservices migration?
- What are the most common Microservices interview questions to expect?
- What are the major Microservices Anti-Patterns?
- How do you decide the right size/boundaries for a microservice?
- How do you build a microservice with Spring Boot and Spring Cloud?
- How do you call another service in Java using OpenFeign with resilience?
- How do you implement asynchronous messaging between Java services with Kafka?
- How do you externalize configuration for Java microservices across environments?
- How do you build a microservice in Node.js and call another service?
- How do you implement async processing in Node with a message queue?
- How do you handle authentication and correlation IDs across Node microservices?
- How do you design databases for microservices (schema-per-service) in SQL?
- How do you implement the Transactional Outbox table in SQL?
- How do you enforce idempotency at the database level in SQL?
- How does a React frontend consume a microservices backend without coupling to every service?
- How do you handle partial failures and loading states in React with a microservices backend?
- What are Micro-Frontends and how do they relate to microservices?
- How do you keep API contracts stable between a React frontend and evolving services?
- When should you NOT use microservices?
- What is Short Polling and what are its drawbacks?
- What is Long Polling and how does it improve on short polling?
- What is Server-Sent Events (SSE) and when is it a good fit?
- What are WebSockets and how do they differ from HTTP?
- What is WebRTC and when would you use it?
- Compare Short Polling, Long Polling, SSE, and WebSocket.
- How do you scale WebSocket connections across many servers?
- How do you handle reconnection and heartbeats for persistent connections?
- What is HTTP/2 Server Push and gRPC streaming, versus WebSocket?
- Exercise — Real-Time Communication: choose the right technique for a live system.
Related
- System design interview questions
- Kafka interview questions
- Spring Boot interview questions
- Practice coding problems online
Frequently asked questions
When should you not use microservices?
When the team is small, the domain is still changing, or you cannot invest in deployment, monitoring and testing automation. A well-structured monolith is often faster to build and easier to run.
How do you handle a transaction across services?
Avoid it by design where you can. Otherwise use the saga pattern: a sequence of local transactions with compensating actions, coordinated by choreography (events) or orchestration (a coordinator).
What is a circuit breaker?
A guard around a remote call that stops calling a failing service after repeated errors, fails fast, and tries again after a cool-down so the failure does not cascade.