All Products
Search
Document Center

Global Accelerator:Use GA and Alibaba Cloud CDN to accelerate content retrieval from origin servers

Last Updated:Mar 24, 2025

Industries such as e-commerce, online gaming, and on-demand audio and video streaming require high access speed and quality. To improve the experience of end users, you can use Global Accelerator (GA) together with Alibaba Cloud CDN (CDN). GA uses high-bandwidth BGP lines and the global transmission network of Alibaba Cloud to accelerate content delivery. You can connect CDN to GA to accelerate the delivery of dynamic content on a global scale.

Scenarios

The example in this topic is based on the following scenario. A web service is deployed on Alibaba Cloud in the US (Silicon Valley) region. The domain name of the service is www.<YOURDOMAIN>.fun. The forwarding port is HTTP port 80. Most clients are located in China (Hong Kong). When clients in China (Hong Kong) access the web service in US (Silicon Valley), issues such as high network latency, network jitter, and packet loss frequently occur due to unstable cross-border Internet connections.

You can deploy CDN to accelerate content delivery from your web service. CDN caches frequently requested content on CDN edge nodes to improve user experience. GA uses high-bandwidth BGP lines and the global transmission network of Alibaba Cloud to accelerate content delivery. You can connect CDN to GA to accelerate the delivery of dynamic content on a global scale.

image

Prerequisites

  • Applications are deployed on the origin server.

    In this example, the Alibaba Cloud Linux 3 operating system is used. NGINX and Netcat are used to build a web page that includes dynamic time display and static images to simulate the server.

    Example: Deploy a test service on ECS

    1. Run the vi ECS_server_install.sh command and press the i key to enter the edit mode.

    2. Copy and paste the following script content:

      #!/bin/bash
      
      # Update the system and install NGINX and Netcat.
      sudo yum update -y
      sudo yum install nginx -y
      sudo yum install -y nc
      
      # Start NGINX and configure NGINX to start automatically.
      sudo systemctl start nginx
      sudo systemctl enable nginx
      
      # Configure NGINX.
      sudo bash -c 'cat > /etc/nginx/nginx.conf <<EOF
      user nginx;
      worker_processes auto;
      error_log /var/log/nginx/error.log;
      pid /run/nginx.pid;
      
      events {
          worker_connections 1024;
      }
      
      http {
          include /etc/nginx/mime.types;
          default_type application/octet-stream;
          log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" '
                            '\$status \$body_bytes_sent "\$http_referer" '
                            '"\$http_user_agent" "\$http_x_forwarded_for"';
          access_log /var/log/nginx/access.log main;
          sendfile on;
          keepalive_timeout 65;
          include /etc/nginx/conf.d/*.conf;
      
          server {
              listen       80;
              listen       [::]:80;
              server_name  _;
              root         /usr/share/nginx/html;
      
              location / {
                  try_files \$uri \$uri/ =404;
              }
      
              location /dynamic {
                  proxy_pass http://127.0.0.1:8080;
                  proxy_set_header Host \$host;
                  proxy_set_header X-Real-IP \$remote_addr;
                  proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
                  proxy_set_header X-Forwarded-Proto \$scheme;
              }
      
              error_page 404 /404.html;
                  location = /40x.html {
              }
      
              error_page 500 502 503 504 /50x.html;
                  location = /50x.html {
              }
          }
      }
      EOF'
      
      # Create static content.
      sudo bash -c 'echo "<img src=\"test.png\" alt=\"Static Image\" width=\"300\"/>" > /usr/share/nginx/html/test.png'
      
      # Create a dynamic content script.
      sudo bash -c 'cat > /usr/share/nginx/html/dynamic_script.sh <<EOF
      #!/bin/bash
      while true; do
          echo -e "HTTP/1.1 200 OK\r\nContent-Length: \$(date | wc -c)\r\n\r\n\$(date)" | /usr/bin/nc -l -p 8080
      done
      EOF'
      
      # Grant execution permissions to the dynamic script and run the script in the background.
      sudo chmod +x /usr/share/nginx/html/dynamic_script.sh
      nohup /usr/share/nginx/html/dynamic_script.sh > /dev/null 2>&1 &
      
      # Restart the NGINX service.
      sudo systemctl restart nginx
      
      # Create the index.html file.
      sudo bash -c 'cat > /usr/share/nginx/html/index.html <<EOF
      <!DOCTYPE html>
      <html>
      <head>
          <title>Test Page</title>
      </head>
      <body>
          <h1>GA and CDN Test Page</h1>
          <h2>Static Content: Image</h2>
          <img src="test.png" alt="Static Image" width="300"/>
      
          <h2>Dynamic Content: Current Time</h2>
          <div id="dynamic-time">Loading current time...</div>
      
          <script>
              function fetchTime() {
                  fetch("/dynamic")
                  .then(response => response.text())
                  .then(data => {
                      document.getElementById("dynamic-time").innerText = data;
                  })
                  .catch(error => {
                      document.getElementById("dynamic-time").innerText = "Failed to load current time.";
                  });
              }
      
              setInterval(fetchTime, 1000);
              fetchTime();
          </script>
      </body>
      </html>
      EOF'
    3. Press the Esc key to exit the edit mode and enter :wq to save and exit the file.

    4. Run the sudo sh ECS_server_install.sh command to execute the script.

    5. Upload the test.png image file to the /usr/share/nginx/html directory specified by the sample script.

  • An A record is created that maps the service domain name www.<YOURDOMAIN>.fun to the public IP address of the origin server.

    This topic uses Alibaba Cloud DNS as an example to describe how to configure DNS records. For more information about how to configure DNS records, see Add DNS records. If you use a third-party DNS service, refer to the user guide provided by the service provider.

  • CDN is activated.

Procedure

Step 1: Configure a GA instance

In this example, a pay-as-you-go standard GA instance is used.

  1. On the Standard Instance > Instances page of the GA console, click Create Standard Pay-as-you-go Instance.

  2. In the Basic Instance Configuration step, configure the basic information and click Next.

    GA基础配置.png

  3. In the Configure Acceleration Area step, add an acceleration region, allocate bandwidth to the region, and then click Next.

    In this example, the China (Hong Kong) region is used. The Acceleration Area parameter is set to China (Hong Kong) and the ISP Line Type parameter is set to BGP (Multi-ISP). You can use the default values for other parameters or modify the parameters based on your business requirements. For more information, see Add and manage acceleration areas.

    Important

    If you specify a small value for the maximum bandwidth, throttling may occur and packets may be dropped. Specify a maximum bandwidth based on your business requirements.

    GA加速区域.png

  4. In the Configure listeners step, configure the forwarding protocol and the port, and then click Next.

    In this example, the Protocol parameter is set to HTTP and the Port parameter is set to 80. You can use the default values for other parameters or modify the parameters based on your business requirements. For more information about how to configure a listener, see Add and manage intelligent routing listeners.

    HTTP监听.png

  5. In the Configure an endpoint group step, configure the endpoint and click Next.

    In this example, Region to US (Silicon Valley), Backend Service Type is set to ECS, and Backend Service is set to the ECS instance where the service is deployed. Read and select Compliance Commitments Regarding Cross-border Data Transfers. For more information about how to configure an endpoint group, see Add and manage intelligent routing listeners.

    EPG.png

    GA 跨境合规 INTL.png

  6. In the Configuration Review step, confirm the configurations and click Submit.

  7. On the Instances page, find the created GA instance and obtain the CNAME assigned to the GA instance in the CNAME column.

Step 2: Configure CDN

  1. On the Domain Names page of the CDN console, click Add Domain Name.

  2. In the Specify Domain Name Information step, configure Business Information and Origin Servers.

    1. Configure Business Information.

      In the Business Information section, Region is set to Global (Excluding the Chinese Mainland) and Domain Name to Accelerate is set to www.<YOURDOMAIN>.fun. You can use the default values for other parameters or modify other parameters based on your business requirements. For more information, see Add a domain name.

      CDN 添加域名 INTL.png

    2. Configure Origin Servers.

      In the Origin Servers section, click Add Origin Server. In the Add Origin Server dialog box, select the type of the origin server, enter the address, and then click OK.

      In this example, Origin Info is set to Site Domain. Enter the CNAME of GA and set Weight to 100. You can use the default values for other parameters or modify other parameters based on your business requirements. For more information about how to configure an origin server, see Add a domain name.

      CDN 配置源站.png

    3. Select Compliance Warranty Regarding Cross-border Data Transfers and click Next.

  3. In the Recommended Features step, you can configure features such as cache expiration, bandwidth cap, and page optimization for the domain name. You can configure the parameters and click Configure or click Skip based on your business requirements.

    In this example, find the default cache rule in the Cache Expiration section, click Modify in the Actions column, set Object to /dynamic, and set Expire In to 0 seconds. For more information about the recommended configurations, see (Optional) Configure system-recommended features.

    CDN PHP不缓存.png

  4. On the Domain Names page, find the added domain name and obtain the CNAME assigned by CDN in the CNAME column.

Step 3: Configure DNS records

After the domain name is added, you must create a DNS record of the domain name to the CNAME assigned by CDN. Then, requests that are sent to the domain name can be forwarded to CDN for acceleration.

To avoid conflicts between the existing A record and the CNAME record, you can set different DNS request sources or resolution lines for the records. In this example, you can add a CNAME record for the China (Hong Kong) region to perform a test. If the test is successful, you can gradually apply the CNAME record to other regions or switch to the default line.

  1. On the Authoritative DNS Resolution page, find the domain name that you want to use and click DNS Settings in the Actions column.

    Note

    For a domain name that is not registered with Alibaba Cloud, you must add the domain name to the Alibaba Cloud DNS console before you can configure DNS records.

  2. On the DNS Settings page, click Add DNS Record, configure a CNAME record, and then click OK.

    In this example, the Record Type parameter is set to CNAME, the Hostname parameter is set to www, the DNS Request Source parameter is set to Asia_Hong Kong, and the Record Value parameter is set to the CDN CNAME. You can use the default values for other parameters or modify other parameters based on your business requirements. For more information, see Add DNS records.

    DNS解析.png

Step 4: Verify the acceleration performance

On a computer in the acceleration region, use the developer tool of a browser to visit www.<YOURDOMAIN>.fun. Check the loading time of each resource on the current web page.

  1. Check the network latency after GA and CDN are configured.

    CDN+GA回源加速效果.png

  2. Check the network latency when only CDN is configured.

    You can change the origin site of CDN from the CNAME of GA to the public IP address of the origin server, delete the endpoint group from GA, and then perform a test.

    CDN加速.png

  3. Check the network latency when GA and CDN are not configured.

    You can disable the accelerated domain name in CDN, disable the CNAME record in DNS, and then perform a test.

    未使用CDN+GA.png

  4. Compare the results.

    The test data shows that after CDN is used, the access latency of static content (test.png) is reduced. After CDN and GA are used, the access latency of dynamic content (dynamic) is reduced.

    Scenario

    Static content test.png

    Time consumed (in milliseconds)

    Dynamic content dynamic

    Time consumed (in milliseconds)

    Comparison

    Scenario 1: Use GA and CDN

    5

    228

    Compared with Scenario 2, the access speed of dynamic content is 50.5% faster.

    Scenario 2: Use CDN only

    5

    461

    Compared with Scenario 3, the access speed of static content is 98.1% faster.

    Scenario 3: GA and CDN are not used

    261

    474

    /

Note

The acceleration performance varies based on the actual workload.

References

  • Pay-as-you go GA fees include GA instance fees, capacity unit (CU) fees, and data transfer fees. For more information, see Billing of pay-as-you-go GA instances.

  • When you use GA and CDN to accelerate content delivery, CDN data transfer or bandwidth fees are incurred. For more information, see Billing overview.