1. How do microservices communicate with each other?

Microservices communicate using:

  • Synchronous protocols → REST, gRPC

  • Asynchronous protocols → Kafka, RabbitMQ, SQS

Asynchronous is preferred because:

  • More scalable

  • Less coupling

  • No blocking


2. What is the difference between synchronous and asynchronous communication?

SynchronousAsynchronous
Immediate response requiredNo immediate response needed
REST, gRPCKafka, SQS
Blocks until replyUses events/queues
Simple but slowerHigh performance and reliable

3. What is Circuit Breaker Pattern?

Protects the system when a microservice is failing.

States:

  • Closed: normal calls

  • Open: stop calls to failing service

  • Half-open: test if service recovered

Libraries:

  • Netflix Hystrix

  • Resilience4j

Prevents cascading failures.


4. What is retry mechanism?

If a service fails, the client retries calling it after intervals.
Helps handle temporary network issues.

Usually combined with:

  • Exponential backoff

  • Circuit breaker


5. What is API Gateway and why is it used?

API Gateway is a single entry point for all client requests.

Functions:

  • Routing to microservices

  • Authentication

  • Rate limiting

  • Load balancing

  • Caching

Examples:

  • Kong

  • Zuul

  • Nginx

  • AWS API Gateway


6. What is Service Registry and Discovery?

Automatically registers and discovers microservices.

Tools:

  • Eureka

  • Consul

  • Zookeeper

When services scale up/down dynamically, discovery keeps track of current IPs.


7. What is Config Server in microservices?

Central place to store environment-specific configurations.
Example: Spring Cloud Config Server

Benefits:

  • Centralized configs

  • Dynamic refresh

  • Secure storage


8. What is the Saga Pattern?

A pattern for managing distributed transactions across microservices.

Two types:

  • Choreography → event-driven, no central coordinator

  • Orchestration → central controller manages transaction steps

Useful when a single database transaction is not possible.


9. What is eventual consistency?

In distributed systems, data may not update immediately, but eventually becomes consistent.
Used in:

  • Microservices databases

  • Event-driven systems


10. What is the database-per-service pattern?

Each microservice owns its database.
Advantages:

  • Isolation

  • Independent scaling

  • Technology freedom

Challenge: distributed transactions → solved using Saga.


11. What is CQRS (Command Query Responsibility Segregation)?

Separates read and write operations into two models:

  • Command model → write

  • Query model → read

Used for improving:

  • Performance

  • Scalability

  • Event-driven architecture


12. What is Event Sourcing?

Instead of storing current state, store every event that changed the state.

Example:
"OrderCreated", "OrderPaid", "OrderShipped"

Allows replaying events to reconstruct state.


13. What is distributed tracing?

Tracking a single request across multiple microservices.

Tools:

  • Jaeger

  • Zipkin

  • OpenTelemetry

Shows:

  • Latency

  • Failed services

  • Dependency graph

Helps debugging complex flows.


14. What is logging aggregation?

Collecting logs from all services into one place.

Tools:

  • ELK Stack

  • Grafana Loki

  • Splunk

Makes debugging easier.


15. What is observability?

Includes:

  • Logs

  • Metrics

  • Traces

Helps understand system behavior.

Tools: Prometheus, Grafana, Jaeger.


16. What is load balancing in microservices?

Distributes network traffic across service instances.

Types:

  • Client-side load balancing (Ribbon)

  • Server-side (Nginx, HAProxy)

  • Cloud LB (AWS ALB, Cloudflare)


17. What is rate limiting?

Limits number of requests per second to prevent overload.

Used to:

  • Protect microservices

  • Prevent DDoS attacks

  • Control traffic bursts

Tools: API Gateway, Kong


18. What is blue-green deployment?

Two environments:

  • Blue → current version

  • Green → new version

Switch traffic to green when ready.

Zero downtime deployment.


19. What is canary deployment?

Release updates to a small set of users first.
If stable → gradually release to all.


20. What are microservice design principles?

  • Single Responsibility

  • Loose coupling

  • High cohesion

  • Resilience

  • Fault isolation

  • Automation


21. What are anti-patterns in microservices?

  • Shared database

  • Chatty communication (too many API calls)

  • Using microservices without reason

  • Too many small services


22. What is Idempotency?

An operation that produces the same result no matter how many times it's executed.

Example:
Retrying payment status check should not duplicate payments.


23. What is bulkhead pattern?

Isolates services so that failure in one does not impact others.


24. What is timeout pattern?

Limits how long a service waits for another service's response.

Prevents blocked threads.


25. How do you secure communication between microservices?

  • OAuth2

  • JWT tokens

  • mTLS (Mutual TLS)

  • API Gateway auth


26. What is container orchestration?

Management of container lifecycle:

  • Scaling

  • Deployment

  • Self-healing

Tools: Kubernetes, Docker Swarm


27. What is Kubernetes Service?

A stable IP to access a set of Pods.
Types:

  • ClusterIP

  • NodePort

  • LoadBalancer

Used for service discovery and routing.


28. What is horizontal scaling?

Adding more instances of a service instead of increasing server size.


29. What is vertical scaling?

Increasing server power (RAM/CPU).
Not preferred in microservices.


30. What are distributed systems challenges?

  • Network latency

  • Failure handling

  • Data consistency

  • Debugging complexity

  • Deployment overhead