Java Interview Question Basic to Advance
AWS Interview Question
C Language all Interview Question
Docker Interview Question Basic to Advance
Microservices Interview Questions

Topics

  • 1. What are Microservices?
  • 2. Microservices vs Monolithic Architecture 
  • 3. Advantages of Microservices
  • 4. Disadvantages of Microservices
  • 5. When NOT to Use Microservices
  • 6. What is Service Decomposition?
  • 7. How Do Microservices Communicate?
  • 8. What is Bounded Context?
  • 9. What is Domain-Driven Design (DDD)?
  • 10. Stateless vs Stateful Services
  • 11. How Do You Design Microservices?
  • 12. How Do You Decide Service Boundaries?
  • 13. What is an API Gateway?
  • 14. Benefits of API Gateway
  • 15. API Gateway vs Load Balancer
  • Questions Ends from here

1. What are Microservices?

  • Microservices are an architectural style where software is built as a collection of small, independent services, each focused on a single function.

  • Key points:

    • Each service runs independently.

    • Developed and deployed separately.

    • Communicate through APIs (Application Programming Interfaces).

Example (Online Shopping App):

  • User Service: Manages user accounts.

  • Product Service: Handles product catalog.

  • Payment Service: Processes payments.

  • Each service can be updated or scaled without affecting the others.

2. Microservices vs Monolithic Architecture 

Feature Monolithic Microservices
Structure Single large application Many small independent services
Deployment Entire app deployed at once Each service deployed independently
Scalability Scale whole app Scale individual services
Failure impact One bug can crash everything Bug usually affects only one service
Development Harder for multiple teams Easier for multiple teams
Technology Usually one tech stack Each service can use different tech

In short:

  • Monolithic: One big block of code.

  • Microservices: Many small blocks working together.

3. Advantages of Microservices

    1. Scalability: Only the services that need more resources are scaled, saving cost and improving performance.

    2. Independent Deployment: Services can be updated or deployed without affecting the entire application.

    3. Flexibility in Technology: Each service can use the best-suited programming language, framework, or database.

    4. Fault Isolation: Failures in one service usually don’t crash the whole system.

    5. Better Team Organization: Teams can own specific services, reducing conflicts and improving efficiency.

4. Disadvantages of Microservices

  • Complexity: Managing multiple services is more complicated than a single application.

  • Network Latency: Communication between services over APIs can be slower than internal calls in a monolith.

  • Data Management Challenges: Maintaining consistency across distributed services is harder.

  • Monitoring & Debugging Difficulty: Tracing issues across multiple services can be challenging.

  • DevOps Overhead: Requires robust CI/CD pipelines, deployment automation, and monitoring tools.

5. When NOT to Use Microservices

Microservices may not be suitable if:

  • The application is small or simple — a monolithic approach is faster and easier.

  • The team is small or lacks DevOps expertise.

  • There’s little need for independent scaling or deployment.

  • You want simpler data management — microservices often need distributed databases.

6. What is Service Decomposition?

  • Definition: Service decomposition is the process of breaking a large application into smaller, independent microservices, each responsible for a specific business function.

  • Analogy: Like slicing a big cake into smaller pieces, where each slice can be served independently.

  • Benefits: Reduces dependencies, improves maintainability, and allows faster development.

Example (E-commerce App):

  • User Service – handles user accounts

  • Product Service – manages products

  • Order Service – handles orders

  • Payment Service – processes payments

7. How Do Microservices Communicate?

Microservices communicate in two main ways:

  1. Synchronous Communication:

    • Real-time request-response pattern (e.g., HTTP/REST or gRPC).

    • Example: User Service requests order details from Order Service.

  2. Asynchronous Communication:

    • Message queues or event-driven systems (e.g., RabbitMQ, Kafka).

    • Example: Payment Service sends a “Payment Completed” event that Order Service processes later.

Note: Excessive inter-service communication can slow the system; careful design is essential.

8. What is Bounded Context?

  • Definition: A concept from Domain-Driven Design (DDD) that defines the boundaries of a service — what it knows and controls.

  • Each microservice operates within its own context, with its own data, rules, and logic.

  • Purpose: Prevents confusion between different parts of the system and maintains clear ownership of data.

Example:

  • Payment Service: Only knows about payments

  • Order Service: Only knows about orders

  • Communication between services happens via APIs, but each service has its own independent logic and data.

9. What is Domain-Driven Design (DDD)?

  • Definition: Domain-Driven Design is a software design approach that models software around the real-world business domain.

  • Key Points:

    • Focuses on the business rules and processes.

    • Helps define microservices boundaries and bounded contexts.

    • Uses ubiquitous language: both developers and business teams use the same terms for clarity.

Example (Banking Application):

  • Domain concepts: Account, Transaction, Customer

  • Each concept could be implemented as a separate microservice with clear responsibilities.

10. Stateless vs Stateful Services

Feature Stateless Stateful
Definition Does not remember anything from previous requests Remembers past interactions
Example HTTP REST API, Authentication check Shopping cart, Game session
Scaling Easy to scale Harder to scale
Reliability Easy to recover if service crashes Needs session persistence
Communication Request contains all needed info Service keeps track of data between requests

In short:

  • Stateless: Memoryless, easier to manage and scale.

  • Stateful: Remembers previous interactions, sometimes necessary but more complex to handle.