Definition of API Gateway
Which of the following best describes the role of an API gateway in a microservices architecture?
- It acts as a single entry point for client requests to multiple microservices.
- It stores all database records for every microservice.
- It is only used for internal communication between microservices.
- It replaces every microservice with a single application.
- It monitors the power usage of all services.
Handling Client Requests
When a client application needs to access several microservices, what is a common benefit of using an API gateway?
- The gateway reduces the number of requests the client must make by aggregating responses.
- The gateway forces clients to call each microservice individually.
- The gateway translates requests into different programming languages.
- The gateway hides all service endpoints from the client permanently.
- The gateway permanently stores all client passwords.
Security Function
Which security-related task is commonly managed by an API gateway in microservices?
- Authenticating and authorizing incoming client requests.
- Generating reports about application profits.
- Displaying user interfaces to end-users.
- Encrypting files on the client's local device.
- Connecting hardware devices directly to the cloud.
API Gateway vs. Load Balancer
What is a key difference between an API gateway and a load balancer in the context of microservices?
- An API gateway manages API-specific tasks like request routing and security, while a load balancer only distributes network traffic.
- A load balancer handles authentication, but an API gateway cannot.
- An API gateway stores all persistent data, whereas a load balancer stores none.
- A load balancer acts as the user interface, but an API gateway does not.
- An API gateway is used only for internal traffic, not client requests.
Cross-Cutting Concerns
In a scenario where multiple microservices require request logging, how does using an API gateway help?
- It centralizes logging for all incoming requests, simplifying management.
- It disables logging for all services to improve speed.
- It duplicates logs in all microservice databases.
- It only logs failed requests but not successful ones.
- It removes the need for any monitoring tools completely.
Rate Limiting Purpose
Why might an API gateway implement rate limiting for requests from clients?
- To prevent excessive use of resources by restricting the number of requests in a given time period.
- To permanently ban clients after a single failed request.
- To track the location of every client device.
- To automatically convert data formats for clients.
- To encrypt files stored on client computers.
Request Transformation
If a client sends a request with data in XML but the backend microservice expects JSON, how can an API gateway help?
- It can transform the XML request from the client into JSON for the microservice.
- It can block all requests containing XML.
- It can require the client to change its code to send only JSON.
- It can encrypt the XML without transforming it.
- It can reroute the request to a random microservice.
Caching Feature
How does an API gateway improve performance using caching when multiple clients request the same data?
- It stores recent responses and serves them to clients, reducing calls to backend services.
- It prevents all clients from accessing the cached data.
- It only caches data on the client device.
- It erases all cached data after each response.
- It replaces backend services with static files.
Protocol Translation
What is one way an API gateway can facilitate communication when microservices use different communication protocols?
- By translating requests and responses between protocols such as HTTP and messaging formats.
- By forcing all microservices to use only one protocol.
- By blocking communication from unsupported protocols.
- By automatically creating new microservices for each protocol.
- By archiving protocol information in storage.
Avoiding Direct Exposure
Why is it beneficial for an API gateway to act as a barrier between client applications and individual microservices?
- It protects backend microservices from direct external access, enhancing security.
- It allows clients to change microservice code directly.
- It exposes sensitive backend details to all clients.
- It makes deploying new microservices impossible.
- It ensures each client has a private database copy.