Advanced API Gateway Patterns: Routing, Filtering, and Rate Limiting Quiz Quiz

Explore your understanding of advanced API gateway patterns, including routing strategies, filtering techniques, and rate limiting approaches. Assess your knowledge of practical gateway scenarios, best practices, and key concepts to effectively manage and secure API traffic.

  1. Understanding Path-Based Routing

    Which routing strategy directs incoming requests to different backend services based on the request URL's path, such as '/users' or '/orders'?

    1. Header-based routing
    2. Method-based routing
    3. Host-based routing
    4. Path-based routing

    Explanation: Path-based routing inspects the path portion of the request URL to determine which backend service should handle the traffic. Host-based routing is based on the domain part rather than the path. Method-based routing uses HTTP verbs like GET or POST, and header-based routing relies on specific headers. Each strategy serves different routing needs, but only path-based routing uses the URL path for service selection.

  2. Role of Filters in API Gateways

    When an API gateway uses a filter to remove or obfuscate sensitive information from requests or responses, what is this technique commonly called?

    1. Data masking
    2. Data shuffling
    3. Data splitting
    4. Data clustering

    Explanation: Data masking is the process of hiding or altering sensitive data, ensuring that private information does not reach logs or clients unnecessarily. Data splitting refers to breaking data into parts, which is not related to confidentiality. Data shuffling reorders data, and data clustering groups data points, neither of which serve the masking purpose in API gateways.

  3. Understanding Rate Limiting

    Which concept in API gateways involves restricting how many requests a client can make in a set period, for example, 100 requests per minute?

    1. Rate limiting
    2. Latency injection
    3. Load shedding
    4. Auto scaling

    Explanation: Rate limiting controls traffic by specifying how many requests are accepted from a client within a defined timeframe. Load shedding drops excess load but is not user-based. Auto scaling deals with infrastructure resizing, not request limitations. Latency injection adds artificial delays, but does not restrict request counts.

  4. Scenario: Route by HTTP Method

    If an API gateway directs all GET requests to Service A and all POST requests to Service B, what type of routing is being used?

    1. Protocol-based routing
    2. Time-based routing
    3. Method-based routing
    4. Domain-based routing

    Explanation: Method-based routing uses the HTTP method (such as GET or POST) to decide which backend service should process the request. Time-based routing is not commonly used for this purpose. Domain-based routing makes decisions based on domain names, while protocol-based routing considers network protocols, not HTTP methods.

  5. Header-Based Routing Example

    An API gateway sends users with a request header 'Region: EU' to a different backend service. What is this pattern called?

    1. Header-based routing
    2. Session-based routing
    3. Token-based routing
    4. Cookie-based routing

    Explanation: Header-based routing inspects HTTP headers, such as 'Region', to route requests. Token-based and session-based routing involve authentication, and cookie-based routing checks for specific cookies, not headers. Only header-based routing uses the value of HTTP headers as the basis for decision-making.

  6. API Gateway as a Reverse Proxy

    In which way does an API gateway act as a reverse proxy?

    1. It controls network firewalls
    2. It receives client requests and forwards them to backend services
    3. It stores user passwords
    4. It directly manages client-side UIs

    Explanation: A reverse proxy accepts requests from clients and distributes them to backend servers, which is a key role of an API gateway. It does not handle user interfaces directly, nor is it responsible for storing passwords or managing firewalls. The reverse proxy pattern focuses on request forwarding between clients and services.

  7. Throttling vs. Quota

    What distinguishes request throttling from a quota in API gateways?

    1. Throttling logs requests; quota ignores them
    2. Throttling controls request rate in real time; quota limits total requests over a longer period
    3. Throttling only works during business hours; quota works always
    4. Throttling encrypts requests; quota decrypts responses

    Explanation: Throttling provides immediate control by limiting request rates in real time, while quotas enforce limits over a span, like per day or per month. Encryption and decryption are not related to these features. Business hours and logging are unrelated to the primary distinction between throttling and quotas.

  8. Implementing Caching at the Gateway

    How can caching at the API gateway improve backend performance in handling repeated identical requests?

    1. By sending requests in random order
    2. By delaying response delivery up to one minute
    3. By blocking all repeated requests
    4. By returning cached responses and reducing redundant traffic

    Explanation: Caching allows the gateway to serve identical requests with stored responses, reducing load and latency for backend services. Blocking all repeated requests would harm usability. Randomizing request order and delaying responses do not enhance performance or efficiency and are not conventional uses of caching.

  9. Filtering Invalid Requests

    What role does request filtering play in an API gateway when it intercepts and rejects malformed or unauthorized requests?

    1. It accelerates all processing
    2. It encrypts all outgoing requests
    3. It improves security and prevents unwanted access
    4. It sends spam emails to blocked clients

    Explanation: Filtering at the gateway level helps secure backend services by blocking malformed or unauthorized requests before they reach sensitive systems. Processing speed is not necessarily increased by filtering. Encryption is outside the scope of basic filtering, and sending spam is not an intended security function.

  10. Scenario: Blue-Green Deployment Routing

    During a blue-green deployment, how does an API gateway route traffic to support both the old and new version of a service?

    1. It merges both versions into one response
    2. It blocks all traffic to the old version
    3. It directs a portion of traffic to each version based on routing rules
    4. It randomly deletes requests

    Explanation: In blue-green deployments, routing rules enable the gateway to control which percentage of traffic hits each version, allowing smooth rollout or rollback. Blocking the old version immediately defeats the purpose of phased deployment. Merging different versions' responses is not part of this pattern, and deleting requests is incorrect and would disrupt service.