Interview Prep
Interview Questions on Microservices — Design Patterns, Communication, and What Companies Actually Ask
Every backend developer with 3+ years of experience gets microservices questions. The interview is not about defining microservices — it is about designing systems that handle failure, scale independently, and communicate reliably.

Microservices interviews test system design thinking — not vocabulary. Every answer should include trade-offs.
The Microservices Interview Landscape
Microservices interviews test system design thinking, not vocabulary. Indian product companies (Flipkart, Swiggy, Razorpay) and GCCs (Amazon, Google India) ask these questions for any backend role with 3+ years experience. Service companies ask them less frequently but they are becoming standard for senior roles.
The interviewer is not looking for textbook definitions. They want to hear you reason through trade-offs — when microservices make sense, when they do not, and how you handle the complexity that comes with distributed systems.
This guide covers the actual microservices questions asked in Indian interviews — organized by topic, with architecture examples and the depth interviewers expect at different experience levels.
The best microservices interview answer starts with 'it depends.' Every design decision in distributed systems is a trade-off — and interviewers want to see that you understand both sides.
Design Patterns
These three questions test whether you understand the fundamental patterns behind microservices architecture. Getting the monolith vs microservices question right sets the tone for the entire interview.
Q1: When would you choose microservices over a monolith?
Why they ask: This is not a trick question. The answer is: start with a monolith, split when you have clear bounded contexts and team scaling needs. Premature microservices is worse than a well-structured monolith.
What the interviewer wants: Mention that microservices add operational complexity (networking, deployment, monitoring, data consistency). The trade-off is worth it only when teams need to deploy independently and services have clear boundaries.
// Trade-offs: Monolith vs Microservices // MONOLITH — Choose when: // ✓ Small team (< 10 developers) // ✓ Simple domain with few bounded contexts // ✓ Need to move fast and iterate quickly // ✓ Shared database is acceptable // ✓ Single deployment pipeline is manageable // MICROSERVICES — Choose when: // ✓ Multiple teams need to deploy independently // ✓ Clear bounded contexts (orders, payments, inventory) // ✓ Different services need different scaling // ✓ Technology diversity is needed (Java for payments, Python for ML) // ✓ Failure isolation is critical (payment down ≠ search down) // THE WRONG REASON to choose microservices: // ✗ "Because Netflix does it" // ✗ "Because it is modern" // ✗ "Because monoliths are bad" // The right approach: Start monolith → identify boundaries → extract services
Q2: Explain the API Gateway pattern
Why they ask: The API Gateway is the single entry point for all client requests. Interviewers want to know if you understand routing, authentication, rate limiting, and load balancing at the gateway level.
// API Gateway — Single entry point for all microservices
// Client → API Gateway → Microservices
// → User Service
// → Order Service
// → Payment Service
// What the API Gateway handles:
// 1. Routing — directs requests to the correct service
// 2. Authentication — validates JWT tokens before forwarding
// 3. Rate Limiting — prevents abuse (100 requests/minute per user)
// 4. Load Balancing — distributes traffic across service instances
// 5. Response Aggregation — combines responses from multiple services
// Spring Cloud Gateway example:
spring:
cloud:
gateway:
routes:
- id: user-service
uri: lb://USER-SERVICE
predicates:
- Path=/api/users/**
filters:
- StripPrefix=1
- id: order-service
uri: lb://ORDER-SERVICE
predicates:
- Path=/api/orders/**
// Popular API Gateways:
// Kong, AWS API Gateway, Spring Cloud Gateway, NGINXQ3: What is the Saga pattern and when do you use it?
Why they ask: Distributed transactions are the hardest problem in microservices. The Saga pattern is the standard solution. Interviewers want to know if you understand choreography vs orchestration and what happens when a step fails.
Example: E-commerce order flow — Order → Payment → Inventory → Shipping. What happens when payment succeeds but inventory fails? The Saga pattern defines compensating transactions to undo completed steps.
// Saga Pattern — Two approaches: // 1. CHOREOGRAPHY (event-driven, no central coordinator) // Order Service → publishes "OrderCreated" event // Payment Service → listens, processes payment → publishes "PaymentCompleted" // Inventory Service → listens, reserves stock → publishes "InventoryReserved" // Shipping Service → listens, creates shipment → publishes "ShipmentCreated" // If Inventory fails after Payment succeeds: // Inventory Service → publishes "InventoryFailed" // Payment Service → listens → refunds payment (compensating transaction) // Order Service → listens → marks order as failed // 2. ORCHESTRATION (central coordinator manages the flow) // Saga Orchestrator controls the sequence: // Step 1: Call Payment Service → success // Step 2: Call Inventory Service → FAILS // Step 3: Call Payment Service → refund (compensating transaction) // Step 4: Update Order → failed // Choreography: simpler, loosely coupled, harder to debug // Orchestration: centralized control, easier to understand, single point of failure
Service Communication
How services talk to each other is a core microservices interview topic. Interviewers want to see that you understand the trade-offs between synchronous and asynchronous communication and can pick the right approach for different scenarios.
Q1: Synchronous vs asynchronous communication — when to use each?
Why they ask: This tests whether you understand that not every service call needs an immediate response. The wrong choice here causes cascading failures or unnecessary latency.
Key insight: Use synchronous (REST/gRPC) when the caller needs an immediate response. Use asynchronous (message queues/Kafka) when the caller can continue without waiting. Example: order placement uses sync for payment confirmation, async for email notification.
// SYNCHRONOUS — REST / gRPC
// Use when: caller needs immediate response
// Example: User places order → Payment must confirm before proceeding
// REST call (Spring Boot WebClient)
public Mono<PaymentResponse> processPayment(PaymentRequest request) {
return webClient.post()
.uri("/api/payments")
.bodyValue(request)
.retrieve()
.bodyToMono(PaymentResponse.class);
}
// ASYNCHRONOUS — Message Queues / Kafka
// Use when: caller can continue without waiting
// Example: Order confirmed → Send email notification (no need to wait)
// Kafka producer (Spring Boot)
@Service
public class OrderService {
private final KafkaTemplate<String, OrderEvent> kafkaTemplate;
public void placeOrder(Order order) {
// Process order synchronously
orderRepository.save(order);
// Send notification asynchronously
kafkaTemplate.send("order-events", new OrderEvent(order.getId(), "CREATED"));
}
}
// Sync: REST, gRPC — real-time, tight coupling, cascading failure risk
// Async: Kafka, RabbitMQ — eventual consistency, loose coupling, resilientQ2: What is an event-driven architecture?
Why they ask: Event-driven architecture is the backbone of scalable microservices. Services communicate through events, not direct calls. This creates loose coupling but introduces eventual consistency — interviewers want to see that you understand both sides.
// Event-Driven Architecture
// Services publish events → Event bus → Other services consume events
// Example: Order placed → multiple services react independently
// Order Service publishes "OrderPlaced" event to Kafka
@Service
public class OrderService {
private final KafkaTemplate<String, OrderEvent> kafkaTemplate;
public Order createOrder(OrderRequest request) {
Order order = orderRepository.save(new Order(request));
// Publish event — other services react independently
kafkaTemplate.send("order-events", OrderEvent.created(order));
return order;
}
}
// Payment Service listens and processes payment
@KafkaListener(topics = "order-events", groupId = "payment-service")
public void handleOrderEvent(OrderEvent event) {
if (event.getType().equals("CREATED")) {
paymentService.processPayment(event.getOrderId());
}
}
// Notification Service listens and sends email
@KafkaListener(topics = "order-events", groupId = "notification-service")
public void handleOrderEvent(OrderEvent event) {
if (event.getType().equals("CREATED")) {
emailService.sendOrderConfirmation(event.getOrderId());
}
}
// Advantages: loose coupling, independent scaling, resilience
// Disadvantages: eventual consistency, debugging complexity, event ordering
Microservices communicate through APIs and events — choosing the right pattern for each interaction is what separates good architects from great ones.
Data Management
Data management is where microservices get genuinely hard. Each service owning its own database sounds simple in theory — but cross-service queries and distributed transactions make it complex in practice.
Q1: Database per service or shared database?
Why they ask: Database per service is the microservices ideal — each service owns its data. But interviewers want to hear you discuss the challenges: cross-service queries, data duplication, and eventual consistency.
The shared database anti-pattern: When multiple services share a database, they become coupled through the schema. Changing a table in one service breaks another. This defeats the purpose of microservices — independent deployment and scaling.
// DATABASE PER SERVICE (recommended)
// Each service has its own database — complete data ownership
// Order Service → orders_db (PostgreSQL)
// Payment Service → payments_db (PostgreSQL)
// Product Service → products_db (MongoDB)
// Search Service → search_index (Elasticsearch)
// Challenge: How to query across services?
// Solution 1: API Composition
// The API Gateway or a composite service calls multiple services
// and combines the results
public OrderDetails getOrderDetails(Long orderId) {
Order order = orderService.getOrder(orderId);
User user = userService.getUser(order.getUserId());
Payment payment = paymentService.getPayment(orderId);
return new OrderDetails(order, user, payment);
}
// Solution 2: CQRS (Command Query Responsibility Segregation)
// Separate read and write models
// Write: each service writes to its own database
// Read: a denormalized read database combines data from all services
// Events sync data from write databases to the read database
// SHARED DATABASE (anti-pattern)
// ✗ Services coupled through schema
// ✗ Cannot deploy independently
// ✗ Cannot scale independently
// ✗ One service's migration breaks anotherQ2: How do you handle distributed transactions?
Why they ask: Distributed transactions are the hardest problem in microservices. Interviewers want to see that you understand why two-phase commit does not work well in microservices and why the Saga pattern with eventual consistency is preferred.
// Distributed Transactions — Three approaches: // 1. TWO-PHASE COMMIT (2PC) — Avoid in microservices // Coordinator asks all services to prepare → then commit // Problem: blocking, single point of failure, poor performance // Only use for databases within the same service // 2. SAGA PATTERN (preferred for microservices) // Break transaction into local transactions with compensating actions // Order: Create → Pay → Reserve Inventory → Ship // If Reserve fails: Refund Payment → Cancel Order // 3. EVENTUAL CONSISTENCY // Accept that data will be consistent eventually, not immediately // Example: Order shows "Processing" while payment is being confirmed // The system converges to a consistent state within seconds // CAP Theorem in practical terms: // Consistency: every read gets the most recent write // Availability: every request gets a response // Partition Tolerance: system works despite network failures // In microservices, you MUST handle partitions (network is unreliable) // So the real choice is: Consistency OR Availability // Most microservices choose Availability + Eventual Consistency // Banking/payments may choose Consistency + accept some unavailability
Resilience & Fault Tolerance
In a distributed system, failure is not a possibility — it is a certainty. Interviewers test whether you can design systems that degrade gracefully instead of cascading into complete failure.
Q1: What is a circuit breaker and how does it work?
Why they ask: The circuit breaker pattern prevents cascading failures. When the payment service is down, the order service should fail gracefully, not hang waiting for a response that will never come.
Three states: Closed (normal operation, requests pass through) → Open (service is down, requests fail immediately with fallback) → Half-Open (test if service has recovered by allowing a few requests through).
// Circuit Breaker with Resilience4j (Spring Boot)
@Service
public class OrderService {
private final PaymentClient paymentClient;
@CircuitBreaker(name = "paymentService", fallbackMethod = "paymentFallback")
public PaymentResponse processPayment(PaymentRequest request) {
return paymentClient.charge(request);
}
// Fallback when circuit is OPEN (payment service is down)
public PaymentResponse paymentFallback(PaymentRequest request, Throwable t) {
// Queue payment for retry, show user "payment processing"
paymentQueue.add(request);
return new PaymentResponse("PENDING", "Payment queued for processing");
}
}
// Circuit Breaker States:
// CLOSED → requests pass through normally
// If failure rate > threshold (e.g., 50% of last 10 calls)
// OPEN → requests fail immediately, return fallback
// After wait duration (e.g., 30 seconds)
// HALF-OPEN → allow a few test requests through
// If test requests succeed → back to CLOSED
// If test requests fail → back to OPEN
// Resilience4j configuration:
resilience4j.circuitbreaker:
instances:
paymentService:
failureRateThreshold: 50
waitDurationInOpenState: 30s
slidingWindowSize: 10Q2: How do you handle service discovery?
Why they ask: In a dynamic environment where services scale up and down, hardcoded URLs break. Service discovery allows services to find each other without knowing exact addresses.
// Service Discovery — Two approaches:
// 1. CLIENT-SIDE DISCOVERY (Eureka)
// Services register with a registry (Eureka Server)
// Clients query the registry to find service instances
// Client does the load balancing
// Eureka Server
@EnableEurekaServer
@SpringBootApplication
public class DiscoveryServer { }
// Service registers itself
@EnableEurekaClient
@SpringBootApplication
public class OrderService { }
// Client discovers and calls service by name
@FeignClient(name = "payment-service") // Eureka resolves the name
public interface PaymentClient {
@PostMapping("/api/payments")
PaymentResponse charge(@RequestBody PaymentRequest request);
}
// 2. SERVER-SIDE DISCOVERY (Kubernetes DNS)
// Kubernetes provides built-in service discovery
// Services are accessible via DNS names
// payment-service.default.svc.cluster.local
// Kubernetes handles load balancing via kube-proxy
// Why Kubernetes is winning:
// No need for Eureka — Kubernetes DNS handles discovery natively
// No need for client-side load balancing — Kubernetes does it
// Most Indian product companies are moving to KubernetesDeployment & Scaling
Deploying and monitoring microservices is fundamentally different from monoliths. Interviewers test whether you understand CI/CD per service, containerization, and how to trace a request across multiple services.
Q1: How do you deploy microservices independently?
Why they ask: Independent deployment is the whole point of microservices. If you cannot deploy one service without affecting others, you have a distributed monolith. Interviewers want to see that you understand CI/CD per service, containerization, and deployment strategies.
// Independent Deployment Pipeline (per service)
// Each service has its own:
// 1. Git repository (or monorepo with separate build paths)
// 2. CI/CD pipeline
// 3. Docker image
// 4. Kubernetes deployment
// Dockerfile (per service)
FROM openjdk:17-slim
COPY target/order-service.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
// Kubernetes Deployment (per service)
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-service
spec:
replicas: 3
selector:
matchLabels:
app: order-service
template:
spec:
containers:
- name: order-service
image: registry/order-service:v2.1
ports:
- containerPort: 8080
// Deployment Strategies:
// Blue-Green: run old and new versions simultaneously, switch traffic
// Canary: route 5% of traffic to new version, monitor, then roll out
// Rolling: replace instances one by one (Kubernetes default)
// The key: each service can be deployed without affecting others
// Order service v2.1 deploys while Payment service stays on v1.8Q2: How do you monitor a microservices system?
Why they ask: A single user request in a microservices system touches 5-10 services. When something goes wrong, how do you trace it end-to-end? This is the monitoring challenge that interviewers want you to address.
// Microservices Monitoring — Three Pillars
// 1. DISTRIBUTED TRACING (Jaeger, Zipkin)
// Track a request across all services using a correlation ID
// User request → API Gateway → Order Service → Payment Service → Inventory
// All logs share the same trace ID: "trace-id: abc-123"
// Spring Boot + Micrometer Tracing
// Automatically propagates trace IDs across service calls
management.tracing.sampling.probability=1.0
management.zipkin.tracing.endpoint=http://zipkin:9411/api/v2/spans
// 2. CENTRALIZED LOGGING (ELK Stack)
// Elasticsearch + Logstash + Kibana
// All services send logs to one place
// Search by trace ID to see the full request journey
// Structured logging with correlation IDs:
logger.info("Order created", Map.of(
"orderId", order.getId(),
"userId", order.getUserId(),
"traceId", MDC.get("traceId")
));
// 3. METRICS (Prometheus + Grafana)
// Collect metrics: request rate, error rate, latency (RED method)
// Set alerts: if error rate > 5% or p99 latency > 2s
// Grafana dashboards per service and system-wide
// Correlation IDs — the key to debugging:
// Generate a unique ID at the API Gateway
// Pass it through every service call (HTTP header)
// Include it in every log entry
// Search by correlation ID to trace the full request pathHow to Prepare — By Company Type
The depth of microservices knowledge tested varies by company type. Here is what each expects and how long to prepare:
Product Companies (Flipkart, Swiggy, Razorpay, Zerodha)
Preparation time: 3-4 weeks. Focus on system design and patterns. They test API Gateway, Saga pattern, circuit breakers, and event-driven architecture with real scenarios. Be ready to design a system on a whiteboard — break it into services, define communication patterns, and explain how you handle failures. Know the trade-offs for every decision.
GCCs (Amazon, Google, Microsoft India)
Preparation time: 4-6 weeks. Focus on distributed systems theory plus patterns. Beyond design patterns, they test CAP theorem in practical scenarios, consensus algorithms, distributed caching strategies, and how you would handle data consistency across regions. Expect deep follow-up questions on every answer you give.
Service Companies (TCS, Infosys, Wipro, Cognizant)
Preparation time: 1-2 weeks. Focus on basic patterns and vocabulary. Know the definitions of microservices, API Gateway, service discovery, and circuit breaker. Be able to explain monolith vs microservices and list the advantages. They test breadth of knowledge, not depth of implementation experience.
Practice With Real Interview Simulations
Reading microservices questions is not the same as answering them under pressure. Practice with timed mock interviews that test your ability to design distributed systems, explain trade-offs, and handle follow-up questions on architecture decisions.
TRY INTERVIEW PRACTICE →The best microservices interview answer starts with 'it depends.' Every design decision in distributed systems is a trade-off — and interviewers want to see that you understand both sides.
Microservices interviews are about demonstrating that you can think in distributed systems. Product companies test design patterns and failure handling, GCCs test distributed systems theory and deep trade-off analysis, and service companies test vocabulary and basic patterns. The good news: microservices patterns are finite and learnable. Master the Saga pattern, understand circuit breakers, know when to use sync vs async communication, and practice designing systems on a whiteboard. Every system you design in practice is one less you will struggle with in the interview.
Prepare for Your Microservices Interview
Practice with AI-powered mock interviews, get your resume ATS-ready, and walk into your next system design interview with confidence.
Free · AI-powered · Instant feedback
Related Reading
Interview Prep
Interview Questions on Spring Boot
Core concepts, REST APIs, and microservices with Spring Boot
14 min read
Interview Prep
Interview Questions on DevOps
CI/CD, Docker, Kubernetes, and what companies actually test
12 min read
Resume Guide
Software Engineer Resume — India
Build a resume that gets you to the interview round
14 min read