All Products
Search
Document Center

CDN:Configure a timeout period for HTTP origin requests

Last Updated:Oct 14, 2024

You can configure a timeout period for HTTP origin requests to efficiently manage the connections between POPs and your origin server. If the timeout period for origin requests is too short, origin requests may fail when network connections are unstable. If the timeout period for origin requests is too long, failed requests will continue to occupy connections until they expire. This may cause normal requests to fail when the maximum number of connections to the origin server is reached. We recommend that you configure the timeout period based on your network connectivity and the maximum number of connections that your origin server can handle to ensure that requests can be redirected to the origin server as expected.

Background information

The time that is consumed by an HTTP origin request refers to the time that is required to initiate a Layer 7 HTTP request. The time that is consumed by an HTTP origin request does not include the time that is required to establish a Layer 4 TCP connection. Back-to-origin HTTP requests

Usage notes

The maximum timeout period that you can configure for CDN cannot exceed 36 seconds. The period includes the time consumed by links between CDN points of presence (POPs) and links between CDN POPs and origin servers.

Origin fetch retry, origin fetch timeout, and origin probing

  • Retry order:

    • The retry is performed based on the priority of origin addresses in descending order. You can view the origin addresses in the Alibaba Cloud CDN console.

    • If two addresses have the same priority, the retry order is based on the weight ratio.

  • Retry granularity:

    • Retries are performed for each IP address. If a domain name is specified as an origin address, Alibaba Cloud CDN retries all IP addresses resolved from the domain name and accesses other available origin servers only if all the IP addresses that belong to the domain name are unavailable.

    • Probes automatically skip origin servers that are in the dead table.

  • Retry status code:

    • A CDN POP sends a retry request when it receives an HTTP 5xx status code from the origin server.

  • Origin fetch timeout: The CDN POP sends a retry request after it receives a retry status code from the origin server. If no retry status code is received from the origin server, the timeout processing logic is followed. After the timeout period is reached, the CDN POP is triggered to retry.

    • By default, the timeout period that is required to establish a TCP connection between POPs and an origin server is 10 seconds. To adjust the timeout period, submit a ticket

    • The origin write timeout is the amount of time allocated for data write after the TCP connection is established. By default, the origin write timeout is 30 seconds.

    • The origin read timeout is the amount of time that is required by the origin server to return all content requested by a CDN POP after the TCP connection is established. By default, the origin read timeout is 30 seconds.

    • You can adjust the values of the origin read timeout and origin write timeout by configuring a timeout period for HTTP origin requests.

  • Origin probing:

    • Abnormal TCP connection: If the TCP connection between a CDN POP and an origin server fails or times out two times in a row, CDN removes the IP address of the origin server from the list of available origin IP addresses and adds the IP address to the dead table. In this case, subsequent origin requests are no longer sent to the IP address. Then the CDN POP connects to the origin server over TCP to probe the IP address every 5 minutes. If the TCP connection is established, Alibaba Cloud CDN restores the IP address to the list of available origin IP addresses.

    • Normal TCP connection: If the TCP connection between a CDN POP and an origin server is normal, but the POP receives a retry status code such as the 5xx status code from the origin server, the IP address of the origin server is not removed from the list of available origin IP addresses. In this case, a retry is triggered and subsequent requests are still sent to the origin server based on the weight ratio. If HTTP request errors occur at Layer 7 when the TCP connection is normal, the IP address of the origin server is not automatically removed from the list of available origin IP addresses. If you want Alibaba Cloud CDN to automatically remove the IP address from the list of available origin IP addresses, submit a ticket

Procedure

  1. Log on to the Alibaba Cloud CDN console.

  2. In the left-side navigation pane, click Domain Names.

  3. On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.

  4. In the left-side navigation tree of the domain name, click Origin Fetch.

  5. In the Timeout for HTTP Back-to-origin Requests section, click Modify.

  6. In the Timeout for HTTP Back-to-origin Requests dialog box, configure the Timeout Value parameter.

    Timeout for HTTP Back-to-Origin Requests

  7. Click OK.