📌Before You Start
Microservices interviews are about trade-offs, not definitions. Interviewers want to see if you understand *when not* to use them. This guide moves from basics to distributed-systems depth. Go hands-on with our Microservices course.
📌Fundamentals
1. What are microservices?
An architectural style where an application is a suite of small, independently deployable services, each owning its own data and communicating over the network.2. Monolith vs microservices — when to choose which?
Start with a monolith for small teams and unclear domains. Move to microservices when you need independent scaling, independent deployments, and team autonomy — and can afford the operational complexity.3. What are the main drawbacks?
Distributed-system complexity: network failures, eventual consistency, harder debugging, and operational overhead (monitoring, tracing, deployment).📌Communication
4. Synchronous vs asynchronous communication?
Sync (REST/gRPC) is simple but couples availability. Async (Kafka/RabbitMQ) decouples services and improves resilience but adds eventual consistency.5. REST vs gRPC?
REST is human-readable and universal. gRPC uses HTTP/2 + Protobuf — faster, strongly typed, great for internal service-to-service calls and streaming.6. What is an API Gateway?
A single entry point that handles routing, authentication, rate limiting, and aggregation — so clients don't call each service directly.7. What is service discovery?
A registry (Eureka, Consul, or Kubernetes DNS) that lets services find each other's network locations dynamically instead of hardcoding hosts.📌Data Management
8. What is the database-per-service pattern?
Each service owns its database. No other service reads it directly — you preserve loose coupling but lose easy joins and ACID across services.9. How do you handle transactions across services?
The Saga pattern — a sequence of local transactions with compensating actions on failure. Two flavors: choreography (event-driven) and orchestration (a central coordinator).10. What is eventual consistency?
Data becomes consistent across services *over time*, not instantly. You trade immediate consistency for availability and scalability.11. What is CQRS?
Command Query Responsibility Segregation — separate the write model from the read model, often with different data stores optimized for each.12. What is the Outbox pattern?
Write the business change and an event to the same database transaction (an "outbox" table), then a relay publishes the event — solving the dual-write problem.📌Resilience
13. What is a circuit breaker?
@CircuitBreaker(name = "inventory", fallbackMethod = "fallback")public Inventory check(String sku) { return inventoryClient.get(sku);}public Inventory fallback(String sku, Throwable t) { return Inventory.unknown(sku); // graceful degradation}It stops calling a failing service after a threshold, giving it time to recover and preventing cascading failures.
14. Retry, timeout, and bulkhead — explain each.
Timeout: cap how long you wait. Retry: re-attempt transient failures (with backoff + jitter). Bulkhead: isolate resources so one failing dependency can't exhaust all threads.15. How do you prevent cascading failures?
Circuit breakers + timeouts + bulkheads + graceful degradation + load shedding.📌Observability
16. How do you trace a request across services?
Distributed tracing (OpenTelemetry, Jaeger, Zipkin) with a correlation/trace ID propagated through headers.17. What are the three pillars of observability?
Logs, metrics, and traces.📌Deployment
18. How do microservices get deployed?
Containerized with Docker, orchestrated with Kubernetes, delivered via CI/CD pipelines — see our GitHub Actions tutorial.19. What is a service mesh?
Infrastructure (Istio, Linkerd) that handles service-to-service concerns — mTLS, retries, traffic shifting — outside your application code via sidecar proxies.20. Blue-green vs canary deployment?
Blue-green swaps all traffic between two environments. Canary shifts a small percentage first, then ramps up if metrics look healthy.📌The Other 15
📌Closing Advice
For every answer, mention the trade-off. Saying "microservices are always better" is an instant red flag. The senior signal is knowing the cost.