All Products
Search
Document Center

Global Accelerator:Accelerate access to a backend service with a specific domain name

Last Updated:Jan 16, 2024

This topic describes how to use Global Accelerator (GA) to accelerate access to a backend service with a specific domain name and improve user experience.

Scenario

The scenario in the following figure is used as an example. A company that is headquartered in the US (Silicon Valley) deployed a web service on two self-managed servers. The web service can be accessed through the domain name www.example.com and port 80. When users from the office in the China (Shenzhen) region connect to the web service deployed in the US (Silicon Valley) region over the Internet, the network condition is unstable. Issues such as network latency, network jitter, and packet loss occur. 场景示例.png

You can configure a GA instance to forward traffic from users in the China (Shenzhen) region to the access point in the China (Shenzhen) region through an accelerated IP address. Then, GA forwards the requests to the global transmission network of Alibaba Cloud and uses intelligent routing to route the requests to the endpoints in the US (Silicon Valley) region. This accelerates access and improves user experience.

Prerequisites

An A record is added to map the domain name www.example.com to the public IP address of a backend server.

Procedure

配置步骤.png

Note

In this example, a pay-as-you-go standard GA instance is used to show how to configure a GA instance to accelerate access to a backend service with a specified domain name. Before you create a pay-as-you-go standard GA instance, take note of the following information:

  • Pay-as-you-go Global Accelerator instances use the pay-by-data-transfer metering method. You do not need to associate a basic bandwidth plan with pay-as-you-go GA instances. The billing of data transfer over the Global Accelerator network is managed by Cloud Data Transfer (CDT). For more information, see Pay-by-data-transfer.

  • The first time you use a pay-as-you-go GA instance, go to the pay-as-you-go GA activation page and activate GA as prompted.

Step 1: Configure basic information about an instance

  1. Log on to the GA console.

  2. On the Instances page, click Create GA Instance. Select Subscription Standard Instance or Pay-as-you-go Standard Instance based on your business requirements.

    In this example, Pay-as-you-go Standard Instance is selected.

  3. In the Basic Instance Configuration step, configure the following parameters and click Next.

    Parameter

    Description

    GA Instance Name

    Enter a name for the GA instance.

    Instance Billing Method

    Pay-As-You-Go is selected by default.

    You are charged instance fees, Capacity Unit (CU) fees, and data transfer fees for pay-as-you-go standard GA instances.

    Resource Group

    Select the resource group to which the standard GA instance belongs.

    The resource group must be a resource group created in Resource Management by the current Alibaba Cloud account. For more information, see Create a resource group.

Step 2: Add an acceleration area

By adding an acceleration area, you can specify the regions of the GA users and allocate bandwidth to the regions.

On the Configure Acceleration Area wizard page, select an acceleration area and click Next.

Parameter

Description

Acceleration Area

Select one or more regions from the drop-down list and click Add.

In this example, China (Shenzhen) in the China South section is selected.

Note

If the acceleration area contains regions in the Chinese mainland and the service traffic uses HTTP or HTTPS, you must apply for an Internet Content Provider (ICP) number for the service domain name. For more information, see Manage domain names.

Assign Bandwidth

Bandwidth

Specify the bandwidth for the acceleration region.

In this example, 2 Mbit/s is selected.

IP Protocol

Select the IP version that is used to connect to GA.

In this example, IPv4 is selected.

ISP Line Type

Select an ISP line type for the GA instance.

In this example, BGP(Multi ISP) is selected.

Step 3: Configure a listener

A listener listens for connection requests and distributes the requests to endpoints based on the port and the protocol that you specify. Each listener is associated with an endpoint group. You can associate an endpoint group with a listener by specifying the region to which you want to distribute network traffic. After you associate an endpoint group with a listener, network traffic is distributed to the optimal endpoint in the endpoint group.

In the Configure listener step, configure the following parameters and click Next.

Parameter

Description

Listener Name

Enter a name for the listener.

Routing Type

Select a routing type.

In this example, Intelligent Routing is selected.

Protocol

Select a protocol for the listener.

In this example, select HTTP.

Port Number

Specify a port for the listener to receive and forward requests to endpoints. Valid values: 1 to 65499.

In this example, port 80 is used.

Client Affinity

Specify whether to enable client affinity. If you enable client affinity, requests from the same client are forwarded to the same endpoint when the client connects to a stateful application.

In this example, Source IP Address is selected.

Custom HTTP Headers

Select the HTTP headers that you want to add.

In this example, the default settings are used.

Show custom HTTP headers.

  • Obtain the GA instance ID by using the GA-ID header

  • Obtain the information about the acceleration region by using the GA-AP header

  • Obtain the listening protocol of the GA instance by using the GA-X-Forward-Proto header

  • Obtain the listening port of the GA instance by using the GA-X-Forward-Port header

  • Obtain client IP addresses by using the X-Real-IP header

Step 4: Configure an endpoint group and endpoints

  1. In the Configure an endpoint group step, configure the endpoint group and endpoints.

    Parameter

    Description

    Region

    Select the region where the endpoint group is deployed.

    In this example, US (Silicon Valley) is selected.

    Endpoint Configuration

    Client requests are routed to endpoints. To add an endpoint, configure the following parameters:

    • Backend Service Type: Select Custom Domain Name from the drop-down list.

    • Backend Service: Enter the domain name that you want to accelerate.

    • Weight: Enter a weight for the endpoint. Valid values: 0 to 255. GA routes network traffic to endpoints based on the weights of the endpoints. In this example, the default value 255 is used.

    Warning

    If you set the weight of an endpoint to 0, Global Accelerator stops distributing network traffic to the endpoint. Proceed with caution.

    Preserve Client IP

    By default, client IP address preservation is enabled. This feature allows you to view client IP addresses on backend servers. HTTP listeners can retrieve client IP addresses from the X-Forwarded-For HTTP header. For more information, see Preserve client IP addresses.

    Backend Service Protocol

    Select the protocol that is used by backend servers.

    Default value: HTTP.

    Port Mapping

    If the listener port is not the same port over which the endpoint provides services, you must set this parameter.

    • Listener Port: Enter the listener port.

    • Endpoint Port: Enter the port over which the endpoint provides services.

    If the listener port is the same as the port over which the endpoint provides services, you do not need to add a port mapping. GA automatically forwards client requests to the listener port of the endpoint.

    In this example, no port mapping is configured.

    Traffic Distribution Ratio

    Specify a traffic distribution ratio for the endpoint group.

    Valid values: 0 to 100.

    In this example, the default value 100 is used.

    Health Check

    Specify whether to enable the health check feature.

    After you enable this feature, you can use health checks to check the status of endpoints. For more information about the health check feature, see Enable and manage health checks.

    In this example, the health check feature is disabled.

  2. Read Compliance Commitments Regarding Cross-border Data Transfers, select Agree to the Preceding Compliance Agreement, and then click Next.

    In this example, cross-border acceleration is required. Therefore, you must agree to Compliance Commitments Regarding Cross-border Data Transfers.

  3. In the Configuration Review step, check the configurations and click Submit.

    Note

    It takes 3 to 5 minutes to create a Global Accelerator instance.

  4. Optional: After the GA instance is created, click Go to Instance Details below the task details list. On the instance details page, click the Instance Information tab. In the Transmission Network Type section, view the type of the transmission network from the acceleration region to the region where the endpoint group is deployed.

    By default, the Transmission Network Type parameter is set to BGP (Multi-ISP) Pro. You can accelerate content delivery in a cost-effective manner between regions in the Chinese mainland and regions outside the Chinese mainland, including China (Hong Kong), China (Macao), and China (Taiwan). No additional configurations are required. For more information, see Pay-by-data-transfer.

Step 5: Configure a CNAME record

To enable the acceleration service based on the CNAME assigned to your GA instance, you must configure a CNAME record to map the accelerated domain name to the CNAME. You must complete the following operations:

  • Change the default ISP line of the existing A record to the ISP line of a specific region. In this example, select the ISP line of North America_United States.

  • Add a CNAME record. In this example, add a CNAME record to map the www.example.com domain name to the CNAME allocated by GA.

Note

The Free Edition of Alibaba Cloud DNS is selected by default. Only the Enterprise Standard Edition and Enterprise Ultimate Edition can return IP addresses based on geographical locations. You must upgrade your Alibaba Cloud DNS. For more information, see Upgrade.

  1. Log on to the Alibaba Cloud DNS console.

  2. If your domain name is not registered by using Alibaba Cloud Domains, you must add your domain name to Alibaba Cloud DNS.

    Note

    If your domain name is not registered by using Alibaba Cloud Domains, you must add your domain name to Alibaba Cloud DNS before you can configure a DNS record. For more information, see the "Add a domain name" section of the Manage domain names topic. If your domain name is registered by using Alibaba Cloud Domains, skip this step.

  3. On the Domain Name Resolution page, find the domain name that you want to manage and click DNS Settings in the Actions column.

  4. On the DNS Settings page, perform the following steps to modify the existing A record and click OK.

    1. Find the A record and click Modify.

    2. In the Modify DNS Record panel, select Outside mainland China, North America, and United States from the DNS Request Source drop-down list.

  5. On the DNS Settings page, click Add DNS Record, configure the parameters in the following table, and then click OK.

    Parameter

    Description

    Record Type

    Select CNAME from the drop-down list.

    Hostname

    Enter the prefix of the domain name that you want to accelerate.

    • If the domain name that you want to accelerate is www.aliyun.com, set the prefix to www.

    • If the domain name that you want to accelerate is aliyun.com, set the prefix to @.

    • If the domain name that you want to accelerate is *.aliyun.com, set the prefix to *.

    • If the domain name that you want to accelerate is mail.aliyun.com, set the prefix to mail.

    In this example, www is entered.

    DNS Request Source

    Select Default from the drop-down list.

    Record Value

    Enter the CNAME assigned by GA.

    You can find the CNAME assigned by GA on the Instances page.

    TTL

    Specify the period of time for which a record is cached by a DNS server. A smaller TTL value specifies that a modified DNS record takes effect in a shorter period of time.

    In this example, the default value 10 Minutes is used.

Step 6: Test the acceleration performance

In this example, the Alibaba Cloud Linux 3 operating system is used. The command that is used to run the test may vary based on the operating system. For more information, refer to the user guide of the operating system.

Note

If you specify UDP as the protocol when you add a listener to GA, you can verify the acceleration performance of GA by using UDPing. For more information, see Verify the acceleration performance of a UDP listener.

  1. Open the command prompt on an on-premises machine in the China (Shenzhen) region.

  2. Run the following command to check whether the CNAME record takes effect:

    ping <accelerated domain name>

    If the CNAME in the output is the same as the CNAME allocated by GA, the CNAME record takes effect.CNAME生效测试.png

  3. Run the following command to test the network latency:

    curl -o /dev/null -s -w "time_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" "http[s]://<Accelerated domain name>"

    The following section describes the parameters:

    • time_connect: The period of time that is required to establish a TCP connection. Unit: seconds.

    • time_starttransfer: The start time of data transfer. The start time refers to the period of time from when the client sends a request to the backend server to when the first byte is sent to the client. Unit: seconds.

    • time_total: The total connection time. The total connection time refers to the period of time from when the client sends a request to when the client receives the last byte from the backend server. Unit: seconds.

    The test result shows that the total connection time is reduced. This indicates that GA has reduced the network latency when users from the China (Shenzhen) region access the web services deployed in the US (Silicon Valley) region.

    Figure 1. Network latency before acceleration加速前.png

    Figure 2. Network latency after acceleration加速后.png

    Note

    The acceleration performance of GA varies based on the actual workloads.