All Products
Search
Document Center

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

更新時間:Dec 17, 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.

Scenarios

The following scenario is used as an example in this topic. A company that is headquartered in the US (Silicon Valley) region 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 high network latency, network jitter, and packet loss occur.

image

You can configure a Global Accelerator 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.

Note

In this example, a pay-as-you-go standard Global Accelerator instance is used to show how to configure a Global Accelerator instance to accelerate access to a backend service with a specified domain name. Before you create a pay-as-you-go standard Global Accelerator 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 Global Accelerator instance, go to the pay-as-you-go GA activation page and activate Global Accelerator as prompted.

Step 1: Configure basic information about an instance

  1. Log on to the GA console.

  2. On the Instances page, click Create Standard Pay-as-you-go Instance.

  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 Global Accelerator instances.

    Resource Group

    Select the resource group to which the standard Global Accelerator instance belongs.

    The resource group must be created by the current Alibaba Cloud account in Resource Management. 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 Global Accelerator users and allocate bandwidth to the regions.

In the Configure Acceleration Area step, 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 service traffic uses HTTP or HTTPS, you must apply for an ICP number for the service domain name. For more information, see Manage domain names.

Assign Bandwidth

Maximum Bandwidth

Specify the maximum bandwidth for the acceleration region. Each acceleration region supports a bandwidth range of 2 to 10,000 Mbit/s.

The maximum bandwidth is used for bandwidth throttling. The data transfer fees are managed by CDT.

In this example, the default value 200 Mbit/s is used.

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.

IP Protocol

Select the IP version that is used to connect to Global Accelerator.

In this example, IPv4 is selected.

ISP Line Type

Select an ISP line type for the Global Accelerator instance.

BGP (Multi-ISP) is selected in this example.

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 listeners 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

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 client affinity is enabled, 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.

Click to view 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 endpoint groups and endpoints

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

    Parameter

    Description

    Region

    Select the region in which 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: In this example, Custom IP is selected.

    • Backend Service: Enter the public IP address of the backend service that you want to accelerate.

    • Weight: Enter the weight of the endpoint. Valid values: 0 to 255. GA distributes network traffic to endpoints based on the configured weights. 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 for HTTPS listeners. 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 different from the port over which the endpoint provides services, you must configure this parameter.

    • Listener Port: Enter the listener port.

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

    If the listener port and the port that is used by the endpoint to provide services are the same, you do not need to add a port mapping. Global Accelerator 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.

    After the GA instance is created, the Transmission Network Type is BGP (Multi-ISP) Pro by default. You can accelerate content delivery between regions in the Chinese mainland and regions outside the Chinese mainland, including China (Hong Kong), China (Macao), and China (Taiwan). No additional configuration is required. For more information, see Pay-by-data-transfer.

  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 you create a GA instance, you can click the instance ID on the Instances page to view the configurations of the instance. On the instance details page, you can click tabs, such as Instance Information, Listeners, and Acceleration Areas, to view more details.

Step 5: Configure a CNAME record

To enable the acceleration service based on the CNAME assigned to your Global Accelerator 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 Global Accelerator.

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 Renewal.

  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 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 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 Global Accelerator.

    You can find the CNAME assigned by Global Accelerator 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 the resolver retains the information in the cache for 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 varies 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 Global Accelerator, you can verify the acceleration performance of Global Accelerator by using UDPing. For more information, see Verify the acceleration performance of a UDP listener.

  1. Open the CLI on a client in the acceleration region. In this example, a client in the China (Shenzhen) region is used.

  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 Global Accelerator, 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>"

    Take note of the following 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 amount 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 the time when the client sends a request to the time 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 Global Accelerator 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 Global Accelerator varies based on the actual workloads.