You can configure a timeout period for back-to-origin HTTP requests to efficiently manage the connections between POPs and your origin server. If the timeout period for back-to-origin requests is too short, back-to-origin requests may fail when network connections are unstable. If the timeout period for back-to-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 informationThe time that is consumed by a back-to-origin HTTP request refers to the time that is required to initiate a Layer 7 HTTP request. The time that is consumed by a back-to-origin HTTP request does not include the time that is required to establish a Layer 4 TCP connection.
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.
Back-to-origin retry, back-to-origin 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 preformed 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.
- Back-to-origin 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 back-to-origin HTTP requests.
- Origin probing:
- Abnormal TCP connection: If the TCP connection between a CDN POP and an origin server fails or times out for 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 back-to-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.
- Log on to the Alibaba Cloud CDN console.
- In the left-side navigation pane, click Domain Names.
- On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.
- In the left-side navigation pane of the domain name, click Back-to-origin.
- In the Timeout for HTTP Back-to-origin Requests section, click Modify.
- In the Timeout for HTTP Back-to-origin Requests dialog box, configure the Timeout Value parameter.
- Click OK.