Microservices Microservices 2 — Questions and Answers
Question 1: What is the primary purpose of an API gateway in a microservices architecture?
- A single entry point that routes, aggregates, and secures requests to backend services (Correct answer)
- A database shared by all services
- A tool for writing service code
- A replacement for the operating system kernel
Correct answer: A single entry point that routes, aggregates, and secures requests to backend services
An API gateway acts as a single entry point handling routing, aggregation, authentication, and rate limiting.
Question 2: Which pattern helps prevent cascading failures when a downstream service is unresponsive?
- Circuit breaker (Correct answer)
- Singleton
- Active record
- Bulk insert
Correct answer: Circuit breaker
The circuit breaker pattern stops calls to a failing service to avoid cascading failures.
Question 3: In the database-per-service pattern, each microservice should:
- Own its private data store and not share it directly with other services (Correct answer)
- Use one global shared schema for all services
- Avoid databases entirely
- Write only to a single central table
Correct answer: Own its private data store and not share it directly with other services
Each service owns its data privately, accessed only through its own API.
Question 4: What does service discovery solve in a dynamic microservices environment?
- Locating network addresses of service instances that change frequently (Correct answer)
- Compiling source code faster
- Encrypting disk volumes
- Designing the UI layout
Correct answer: Locating network addresses of service instances that change frequently
Service discovery lets services find each other's dynamic network locations.
Question 5: Which communication style is asynchronous and decouples sender from receiver?
- Message/event-based messaging via a broker (Correct answer)
- Synchronous blocking HTTP calls
- Direct in-process function calls
- Shared global variables
Correct answer: Message/event-based messaging via a broker
Message brokers enable asynchronous, decoupled communication between services.
Question 6: What is a key benefit of independent deployability in microservices?
- Teams can release a single service without redeploying the whole system (Correct answer)
- All services must always deploy together
- Deployments become impossible
- Code can never change
Correct answer: Teams can release a single service without redeploying the whole system
Independent deployability lets each service be released on its own schedule.
Question 7: Why is centralized logging important in microservices?
- Requests span many services, so aggregated logs are needed to trace behavior (Correct answer)
- Logs are useless in distributed systems
- It reduces the number of services
- It replaces the need for testing
Correct answer: Requests span many services, so aggregated logs are needed to trace behavior
Aggregated, correlated logs are essential because a request flows through many services.
What is the primary purpose of an API gateway in a microservices architecture?