Google is committed to advancing racial equity for Black communities. See how.

Best practices for configuring I/O timeout

The API requests made by the client applications flow through various components in Apigee Edge before they reach the backend services. Most client applications expect the responses to these requests to be received in a timely manner.

To achieve timely responses, the I/O timeout values are set in each of the components through which the API requests flow through. If any of the components in the flow take more time than the preceding component, the preceding component times out and responds back with 504 Gateway Timeout errors.

While configuring the timeout, the values should be configured in each of the components with utmost care, otherwise it can lead to 504 Gateway Timeout errors.

This document describes best practices for configuring I/O timeout on various components through which the API requests flow in Apigee Edge.

Best practices for configuring I/O timeout

Consider the following best practices when configuring the I/O timeout:

  • First component: Always use the highest timeout on the first component in the API request flow, which is the Client Application in Apigee Edge.
  • Last component: Always use the lowest timeout on the last component in the API request flow, which is the Backend Service in Apigee Edge.
  • Between components: Ensure that there is a difference of at least 2-3 seconds in the timeout value configured in each component between the first component and the last component in the flow.
  • Router: It is always a good practice to configure (modify) the I/O timeout value for a specific virtual host as opposed to configuring it on the Router. This ensures that the new timeout value affects only those API Proxies which are using the specific virtual host and not all the API Proxies being served by the Router.

    Configure (modify) the I/O timeout on the Router only when you are absolutely sure that the new I/O timeout value is required or applicable for all the API Proxies running on the Router.

  • Message Processor: It is always a good practice to configure (modify) the I/O timeout value for a specific API proxy as opposed to configuring it on the Message Processor. This ensures that the new timeout value affects only the specific API proxy and not all the API proxies being served by the Message Processor.

    Configure (modify) the I/O timeout on the Message Processor only when you are absolutely sure that the new I/O timeout value is required or applicable for all the API Proxies running on the Message Processor.

Example scenarios

The scenarios in this section can help you understand how to correctly set the I/O timeout values.

Scenario 1: Requests to Apigee Edge from client applications directly

This section describes the best practices to follow while setting up the timeout values in an Apigee Edge setup where there are no intermediate components between the client application and Apigee Edge and between Apigee Edge and your backend server.

Sample Apigee setup with no intermediate components

Flow starting at Client going to Router and then to Message Processor and then to Backend Server

If Apigee Edge is set up as shown in the diagram above, with no intermediate components, then use the following best practices:

  1. The client application is the first component in the flow. The highest timeout value should be set on the client.
  2. The backend server is the last component in the flow. The lowest timeout value should be set on the backend server.
  3. Configure the timeout values on each of the components in the following order:

    Configure timeout on client, then Router, then Message Processor, then Backend Server

    The following example shows timeout values set on the various components as per guidelines given above to avoid any issues:

    Configure timeout on client at 60 seconds, then Router at 57 seconds, then Message Processor at 55 seconds, then Backend Server at 52 seconds

Scenario 2: Requests to Apigee Edge from client applications through intermediate components

This section describes the best practices to follow while setting up the timeout values in an Apigee Edge setup where there are one or more intermediate components between the client application and Apigee Edge and also between Apigee Edge and your backend server.

The intermediate components can be a load balancer, content delivery network (CDN), Nginx, and so on.

Sample Apigee setup with one intermediate component between Client and Apigee Edge and between Apigee Edge and backend server

Flow starting at Client going to Intermediate Component 1 and then to Router and then to Message Processor and then to Intermediate Component 2 and then to Backend Server

If Apigee Edge is set up as shown in the diagram above, with one or more intermediate components, then use the following best practices:

  1. The client application is the first component in the flow. The highest timeout value should be set on the client.
  2. The backend server is the last component in the flow. The lowest timeout value should be set on the backend server.
  3. Configure the timeout values on each of the components, including the intermediate components, in the following order:

    Configure timeout on client, then Intermediate Component 1, then Router, then Message Processor, then Intermediate Component 2, then Backend Server

    The following example shows timeout values set on the various components as per guidelines given above to avoid any issues:

    Configure timeout on client at 63 seconds, then Intermediate Component 1 at 60 seconds, then Router at 57 seconds, then Message Processor st 55 seconds, then Intermediate Component 2 at 52 seconds, then Backend Server at 59 seconds