Understanding Microservices Architecture
Which statement best describes the microservices architecture style?
- A collection of small, independently deployable services that communicate over a network.
- A single, large application that handles all business logic in one codebase.
- A system where code is copied across multiple repositories for safety.
- An approach where all services share the same memory space.
- A model with tightly-coupled functions running as a group.
Shared Databases in Microservices
Why is sharing a single database among multiple microservices generally considered a bad practice?
- It leads to tight coupling between services and potential data inconsistency.
- It ensures strong consistency at all times.
- It speeds up service deployment.
- It simplifies troubleshooting and debugging.
- It allows all services to bypass network communication.
Service Discovery Basic Concept
How do microservices typically locate and communicate with each other in a dynamic environment?
- By using a Service Discovery mechanism that registers and tracks service locations.
- By hardcoding IP addresses in every service config file.
- By storing all service information in a single class.
- By relying on a random number generator to choose services.
- By using manual DNS edits for each deployment.
API Gateway Function
What is the primary responsibility of an API Gateway in a microservices setup?
- To act as a single entry point that routes client requests to the appropriate microservice.
- To provide a development environment for microservices.
- To store all user credentials centrally.
- To implement every microservice’s business logic.
- To replicate data between databases.
Database Per Service Pattern
In microservices architecture, what is the main benefit of following the 'Database per Service' pattern?
- Each service can manage its own data independently, reducing dependencies.
- All services instantly receive data updates from others.
- It allows services to run on outdated versions.
- It enables direct table sharing between all services.
- It prevents services from being stateless.
Event-driven Communication
What does 'event-driven communication' between microservices typically involve?
- Publishing and subscribing to events so services can react asynchronously.
- Starting all services at the same time.
- Hardcoding method calls between different services.
- Saving log files instead of sending messages.
- Using only database triggers for messaging.
Fault Tolerance Pattern
Which pattern is commonly used in microservices to prevent cascading failures when a downstream service is unavailable?
- Circuit breaker pattern, which stops requests to a failing service.
- Waterfall pattern, which speeds up request flow.
- Singleton pattern, which ensures one instance per service.
- Round-robin pattern, which cycles requests between services.
- Cryptic breaker, which encrypts all service messages.
Scaling Microservices
What is a key advantage of deploying each microservice independently when scaling?
- You can increase resources only for the services that need more capacity.
- All services are required to scale at the same time.
- Deployment must be paused for all services.
- It decreases fault tolerance for each service.
- Scaling always requires manual code edits in all services.
Stateless Services
Why is it recommended to make microservices stateless whenever possible?
- It allows any instance to handle requests without needing previous session information.
- It forces all data to be stored in-memory only.
- It guarantees faster database joins.
- It eliminates the need for any external storage.
- It means each service can store state in global variables.
Testing Microservices
What is a typical challenge when testing microservices compared to monolithic applications?
- Coordinating interactions between multiple independent services can be complex.
- No debugging tools are available for microservices.
- All microservices are written in the same language.
- Testing is always done manually without automation.
- Microservices never need integration tests.