Microservices architecture is the standard at every major Indian product company: Flipkart, Swiggy, Razorpay, PhonePe, and CRED all run distributed microservices in production. Understanding microservices is no longer an advanced topic: it is expected knowledge for any SDE-2+ role at an Indian product company. This guide covers the most commonly tested microservices concepts and interview questions.
Core microservices concepts tested in interviews
Q: What is the difference between monolith and microservices? A monolith deploys all functionality as a single unit. Microservices decompose the application into independent services, each owning its own data, deployed independently. Trade-offs: monolith is simpler to develop and debug, faster for early-stage; microservices scale independently and allow team autonomy but introduce distributed systems complexity.
Q: How do microservices communicate? Two primary patterns: synchronous (REST HTTP or gRPC: the caller waits for a response) and asynchronous (message queues like Kafka or RabbitMQ: the caller sends a message and continues). Synchronous is simpler but creates coupling and cascading failures. Asynchronous is more resilient but harder to reason about.
Q: What is an API Gateway? A single entry point that routes requests to downstream services, handles cross-cutting concerns (authentication, rate limiting, SSL termination, logging), and can perform request aggregation. Examples: AWS API Gateway, Kong, Nginx.
Q: What is service discovery? In microservices, service instances have dynamic IPs. Service discovery allows services to find each other: either client-side (the client queries a registry like Consul or Eureka) or server-side (a load balancer queries the registry on behalf of the client).
Q: What is the Circuit Breaker pattern? Prevents cascading failures. When a service is unavailable, instead of waiting for timeouts, the circuit breaker opens (stops forwarding requests) and returns a fallback response. After a timeout, it half-opens to test if the service recovered. Libraries: Resilience4j (Java), Hystrix (deprecated but conceptually important).
Data management in microservices
This is the most nuanced area in microservices interviews:
Q: Why should each microservice have its own database? Database per service ensures loose coupling: service A cannot break service B by changing its schema. It allows each service to use the best database type for its needs (PostgreSQL for orders, Redis for sessions, Elasticsearch for search).
Q: How do you handle transactions across multiple services? Traditional ACID transactions do not span services. Solutions: Saga pattern (sequence of local transactions with compensating transactions on failure) or Two-Phase Commit (2PC: more consistent but less available, rarely used in practice at scale). Know both and explain when to use each.
Q: What is eventual consistency and when is it acceptable? In distributed systems, strong consistency across services is expensive. Eventual consistency means all nodes will converge to the same state eventually, but might be briefly inconsistent. Acceptable for: inventory counts, user feed ranking, recommendation updates. Not acceptable for: payment debits (must be immediate and consistent).
Q: What is CQRS (Command Query Responsibility Segregation)? Separates write operations (commands) from read operations (queries) using separate models. Often combined with Event Sourcing. Used when read and write patterns have very different performance characteristics.
Operational questions on microservices
Senior SDE interviews probe operational knowledge:
Q: How do you trace a request across multiple microservices? Distributed tracing using a correlation ID that flows through all service calls. Tools: Jaeger, Zipkin, AWS X-Ray. Each service logs the correlation ID, allowing reconstruction of the full request path and identification of latency bottlenecks.
Q: How do you handle a microservice that is consistently slow? First, identify the bottleneck using distributed tracing. Then investigate: N+1 query problem? Missing database index? External API call without timeout? Memory pressure causing GC pauses? Network saturation? Address the root cause, not the symptom.
Q: What is a sidecar pattern? A helper container deployed alongside the main service container in the same pod. The sidecar handles cross-cutting concerns (logging, service mesh proxy, configuration injection). Examples: Envoy proxy in a service mesh (Istio), Fluentd for log aggregation.
Q: How do you do zero-downtime deployments in a microservices environment? Blue-green deployment (two identical environments, switch traffic atomically) or rolling deployment (replace instances one by one). Kubernetes Deployments handle rolling updates natively with configurable maxUnavailable and maxSurge.
Explain microservices architecture clearly under pressure. Practise with HireStepX's AI mock interviewer and get feedback on the depth and clarity of your technical explanations.
Practice freeMicroservices interview questions specific to Indian companies
These questions have been reported at Swiggy, Razorpay, Flipkart, and Meesho:
'How would you decompose a monolithic e-commerce application into microservices?': Discuss the seams: user/auth, product catalogue, inventory, order management, payment, notification, search, recommendation. Each is independently deployable. Identify the order-payment interface as a critical boundary (strong consistency required).
'Our payment service and order service are tightly coupled. How do you decouple them?': Introduce an event (OrderCreated event on Kafka). The payment service subscribes and initiates payment asynchronously. Use the Saga pattern with compensating transactions (cancel order if payment fails after 30 seconds).
'How do you handle a scenario where Service A calls Service B, which calls Service C, and Service C is down?': Circuit breaker on each service boundary. Service A's call to B fails fast with the circuit open. A returns a cached or degraded response. Alert on the circuit being open. Recovery testing in the half-open state.
Frequently asked questions
Practice these questions on HireStepX