top-30-microservices-interview-questions-answers

1. What are Microservices?

Answer

Microservices is an architectural style where an application is divided into small, independent services, each responsible for a single business capability, communicating via lightweight protocols (e.g., REST, gRPC, messaging).

2. What are the main benefits of Microservices?

Answer

3. Difference between Monolith and Microservices?

Answer

4. How do Microservices communicate?

Answer

5. What is API Gateway in Microservices?

Answer

API Gateway acts as an entry point for all requests, handling routing, load balancing, security, rate limiting, and logging. Example: Kong, NGINX, Azure API Management.

6. How do you handle service discovery?

Answer

7. What is Circuit Breaker Pattern?

Answer

It prevents repeated calls to a failing service. If a service fails continuously, the breaker "opens" and stops traffic until it recovers. Example: Polly (.NET), Hystrix (Java).

8. What is the Saga Pattern in Microservices?

Answer

Saga manages distributed transactions by breaking them into smaller local transactions.

9. How do you ensure data consistency in Microservices?

Answer

10. How do you handle the database per microservice?

Answer

Each microservice owns its own database to avoid coupling. For queries across services → use CQRS, API Composition, or Database Views.

11. What is CQRS?

Answer

Command Query Responsibility Segregation separates read (queries) and write (commands) models for performance and scalability.

12. What is Event Sourcing?

Answer

Instead of storing only the final state, every change is stored as an event. The state is rebuilt by replaying events. Useful for audit logs and financial transactions.

13. How do you secure Microservices?

Answer

14. What is Service Mesh?

Answer

Service mesh (e.g., Istio, Linkerd) provides traffic management, security, observability, and service discovery between services without changing code.

15. How do you achieve resilience in Microservices?

Answer

16. How to handle logging in Microservices?

Answer

Use centralized logging:

17. How do you handle monitoring in Microservices?

Answer

18. What is the role of Docker in Microservices?

Answer

Docker packages microservices into portable containers, ensuring consistency across environments.

19. What is Kubernetes in Microservices?

Answer

Kubernetes orchestrates containers, providing scaling, load balancing, auto-healing, and service discovery.

20. How do you achieve scalability in Microservices?

Answer

21. How do you handle inter-service communication failure?

Answer

22. How do you test Microservices?

Answer

23. What are some design patterns in Microservices?

Answer

24. What is the Strangler Fig Pattern?

Answer

It helps migrate from monolith to microservices gradually by building new services around old ones and slowly decommissioning the monolith.

25. What is Blue-Green Deployment?

Answer

Deploy new version in parallel (Green), keep old version (Blue). Switch traffic once stable. Ensures zero downtime.

26. What is Canary Deployment?

Answer

Release a new version to a small subset of users before rolling out to all.

27. How do you handle configuration in Microservices?

Answer

Use Centralized Config Management:

28. What are the common challenges in Microservices?

Answer

29. What is the difference between Orchestration and Choreography?

Answer

30. How do you migrate from a Monolith to Microservices?

Answer