When users access resources stored in Object Storage Service (OSS) buckets, the speed of data transfer is limited by the downstream bandwidth of OSS and the region where the OSS buckets are deployed. Global Accelerator (GA) allows clients to connect to the nearest access point of the Alibaba Cloud global transmission network. You can use GA to accelerate data transfer and improve user experience. This topic describes how to use GA to accelerate OSS buckets.

Scenarios

The following scenario is used as an example in this topic. The headquarters of a company is located in the US (Silicon Valley) region. The headquarters stores a large number of files in OSS. When users from the office in the China (Hong Kong) region access the resources stored in OSS in the US (Silicon Valley) region over the Internet, the network condition is unstable. Issues such as network latency, network jitter, and packet loss may occur. Accelerate OSS Buckets

You can deploy a GA instance and specify the OSS endpoint as a backend service. GA uses high-bandwidth Border Gateway Protocol (BGP) lines and the global transmission network of Alibaba Cloud. This way, data transfer is accelerated when clients in the China (Hong Kong) region access the resources stored in OSS in the US (Silicon Valley) region.

Prerequisites

OSS is activated in the US (Silicon Valley) region. Resources are stored in an OSS bucket that you create.

Procedure

Procedure

Step 1: Purchase a GA service bundle

You can enter the information about the web service in the GA console. After you enter the information, the system generates a list of recommended services. The list includes a GA instance and a basic bandwidth plan.

  1. Log on to the Global Accelerator console.
  2. In the upper-right corner of the Instances page, click Purchase Guide.
    Note If this is the first time that you use the GA service, skip this step.
    Purchase Guide
  3. In the Enter the required information to generate a list of recommended services section, enter the required information and click Generate Service List.
    Parameter Description
    Acceleration Area Select the region that requires acceleration.

    In this example, China (Hong Kong) is selected.

    Service Region Select the region where the backend servers are deployed.

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

    ICP Filing Specify whether you have applied for an Internet Content Provider (ICP) number for the OSS bucket in which the resources are stored.
    In this example, No is selected.
    Note All OSS buckets must obtain an ICP number before they are permitted to provide services to users in the Chinese mainland. In this case, you must select Yes.
    • If you want to use a custom domain name to access OSS buckets, you must obtain an ICP number first. For more information, see What is an ICP filing?.
    • If you do not have a custom domain name and use the OSS endpoint provided by Alibaba Cloud to access OSS buckets, you do not need to obtain an ICP number. By default, Alibaba Cloud obtains an ICP number for the OSS endpoint.
    Server Area Specify whether the backend service is deployed on Alibaba Cloud.

    In this example, On Alibaba Cloud is selected.

    Peak Bandwidth Range Enter the bandwidth required during peak hours. Unit: Mbit/s.

    In this example, 2 is entered.

    Maximum Concurrent Connections The maximum number of concurrent connections that a GA instance supports. When the number of existing concurrent connections reaches the upper limit, new connection requests are dropped.

    In this example, 5 Thousand is selected.

  4. In the Recommended Service List section, click Generate Service List after you confirm the information.
    Generate Service List
  5. On the buy page, set the following parameters and click Buy Now to complete the payment.
    Parameter Description
    Term Select a subscription duration.
    Type Select the type of the GA instance.

    In this example, Standard is selected.

    Specification Select a specification for the GA instance.

    In this example, Small I (Specification Unit) is selected.

    Bandwidth Type Select a bandwidth type for the basic bandwidth plan.

    In this example, Premium is selected.

    Peak Bandwidth Select the bandwidth limit of the basic bandwidth plan.

    In this example, 2 Mbit/s is selected.

Step 2: Add an acceleration area

After you purchase a GA instance, you can add an acceleration area, specify the region where users are located, and then allocate bandwidth resources to the region.

  1. On the Instances page, find the GA instance and click its ID.
  2. Click the Acceleration Areas tab and then click Add Region on the Asia Pacific tab.
  3. In the Add Acceleration Area dialog box, set the following parameters and click OK.
    Parameter Description
    Regions Select the region where the users are located.

    In this example, China (Hong Kong) is selected.

    Bandwidth Specify a bandwidth value for the acceleration region.

    In this example, 2 Mbit/s is entered.

    Internet Protocol Select the IP address version used to access GA.

    In this example, IPv4 is selected.

    After you add the region, the system assigns an accelerated IP address to the region that is added to the GA instance. This accelerated IP address is used to accelerate data transfer from users in the specified region to the specified backend servers through GA. Accelerated IP address

Step 3: Add a listener and an endpoint group

A listener checks for connection requests and then distributes the requests to backend servers based on the specified protocol and ports. 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, traffic is distributed to the optimal endpoint in the associated endpoint group.

  1. On the instance details page, click the Listeners tab and then click Add Listener.
  2. On the Configure Listener & Protocol wizard page, specify the following listener information and click Next.
    Listener
    Parameter Description
    Listener Name Enter a name for the listener.

    The name must be 2 to 128 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The name must start with a letter.

    Protocol Select the protocol of the listener.
    In this example, TCP is selected.
    Note
    • By default, OSS buckets can be accessed over both HTTP and HTTPS. To access small-sized files stored in OSS buckets, you can use HTTP or HTTPS listeners. This is applicable only when you use custom domain names to access OSS buckets. If you want to access large-sized files stored in OSS buckets, you can use HTTP, HTTPS, and TCP listeners.
    • The HTTP and HTTPS protocols transfer data based on TCP connections. Therefore, you can use TCP listeners.
    Port Number Specify a listener port. The port is used to receive and forward requests to endpoints. Valid values: 1 to 65499.

    You can specify at most 30 listener ports for each listener. Separate multiple listener ports with commas (,). Example: 80,90,8080. If you want to specify a port range, you can use a tilde (~). Example: 80~85.

    In this example, 80,443 is entered.

    Note In most cases, port 80 is used for HTTP and port 443 is used for HTTPS.
    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.

  3. On the Configure Endpoint Group wizard page, specify the following endpoint group information and click Next.
    Endpoint group
    Parameter Description
    Endpoint Group Name Enter a name for the endpoint group.

    The name must be 2 to 128 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The name must start with a letter.

    Region Select the region where you want to create the endpoint group. The servers that the clients want to access must be deployed in the specified region.

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

    Backend Service Specify whether the backend service is deployed on Alibaba Cloud.

    In this example, On Alibaba Cloud is selected.

    Preserve Client IP Specify whether to enable Preserve Client IP. After you enable this feature, backend servers can retrieve client IP addresses.

    In this example, Preserve Client IP is disabled.

    Endpoint Endpoints are destinations of client requests. To add an endpoint, specify the following parameters:
    • Backend Service Type: Select OSS.
    • Backend Service: Select the OSS bucket that requires acceleration.
    • Weight: Enter a weight for the endpoint. Valid values: 0 to 255. GA distributes network traffic to endpoints based on their weights.
      Notice If the weight of an endpoint is set to 0, GA stops distributing network traffic to the endpoint. Proceed with caution.
  4. On the Confirm wizard page, confirm the configurations of the listener and endpoint, and then click Submit.

Step 4: Configure the hosts file or DNS settings

If you use the OSS endpoint provided by Alibaba Cloud to access the backend OSS bucket, you must modify the hosts file on your on-premises machine. If you use a custom domain name to access the backend OSS bucket, you must configure Domain Name System (DNS) settings. After you configure the hosts file or DNS settings, requests that are destined for the backend OSS bucket are routed to GA for acceleration.

Configure the hosts file

You must configure the hosts file and map the OSS endpoint to the accelerated IP address allocated by GA. For more information about the format of OSS endpoints, see OSS domain names.

Note The CentOS 8 operating system is used in this example. 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.
  1. Open the command prompt on a client in the China (Hong Kong) region.
  2. Configure the hosts file.
    1. Run the following command to open the /etc/hosts file:
      vim /etc/hosts
    2. Press I to enter the edit mode and add the following information to the file:
      <the accelerated IP address> <the name of the source OSS bucket>.<the endpoint of the source OSS bucket> 

      After you modify the hosts file, press Esc, enter :wq!, and press Enter to save the modified file and exit the edit mode.

  3. Run the following command to restart the network service:
    systemctl restart NetworkManager
    After you modify the file, run the following command to view the /etc/hosts file:
    cat /etc/hosts

    The result shows that the OSS endpoint is mapped to the accelerated IP address in the /etc/hosts file.

    View Hosts File

Configure DNS settings

You must configure DNS settings to route requests destined for the OSS bucket to GA. Select one of the following methods to configure DNS settings:
  • Add an A record that maps the endpoint of the OSS bucket to the IPv4 address allocated by GA.
  • Add a CNAME record that maps the endpoint of the OSS bucket to the CNAME allocated by GA.
Before you configure DNS settings, make sure that you have associated a custom domain name with the OSS bucket where the resources are stored. Otherwise, you cannot pass the domain name verification for OSS. For more information, see Map custom domain names.
Note If you use the DNS resolution service that is provided by a third-party service provider, log on to the platform of the service provider and modify the DNS record for your OSS bucket.
  1. Log on to the Alibaba Cloud DNS console.
  2. On the Manage DNS page, find the domain name and click Configure in the Actions column to go to the DNS Settings page.
  3. Select one of the following methods to configure DNS records based on your requirements:
    • If you do not add a CNAME record when you associate a custom domain name with the OSS bucket in which the resources are stored, click Add Record and add a CNAME record that maps the custom domain name to the public endpoint of the OSS bucket.
    • If you add a CNAME record when you associate a custom domain name with the OSS bucket in which the resources are stored, find the CNAME record and click Edit in the Actions column. Then, modify the CNAME record to map the custom domain name to the public endpoint of the OSS bucket.
  4. In the Add Record or Edit Record panel, set the following parameters and click Confirm.
    • A record
      Parameter Description
      Type Select A from the drop-down list.

      The A record is used to map the endpoint of the OSS bucket to the IPv4 address allocated by GA.

      Host Enter the prefix of the accelerated domain name.
      • If the domain name is www.aliyun.com, set the prefix to www.
      • If the domain name is aliyun.com, set the prefix to @.
      • If the domain name is *.aliyun.com, set the prefix to *.
      • If the domain name is mail.aliyun.com, set the prefix to mail.
      ISP Line Select Default from the drop-down list.
      Value Enter the accelerated IP address allocated by GA.
      TTL Select 10 minute(s) from the drop-down list.

      The time-to-live (TTL) period of the DNS record on the DNS server.

    • CNAME record
      Parameter Description
      Type CNAME is selected in this example.

      The CNAME record is used to map the endpoint of the OSS bucket to the CNAME allocated by GA.

      Host Enter the prefix of the accelerated domain name.
      • If the domain name is www.aliyun.com, set the prefix to www.
      • If the domain name is aliyun.com, set the prefix to @.
      • If the domain name is *.aliyun.com, set the prefix to *.
      • If the domain name is mail.aliyun.com, set the prefix to mail.
      ISP Line Select Default from the drop-down list.
      Value Enter the CNAME that is allocated by GA.

      You can find the CNAME on the Instances page.

      TTL Select 10 minute(s) from the drop-down list.

      The TTL period of the DNS record on the DNS server.

      Note
      • New CNAME records immediately take effect. If you modify the CNAME record, the record takes effect within 72 hours after it is modified.
      • After you add a CNAME record, it requires about 10 minutes for the system to update the status in the console. The message "You must add the CNAME record" may appear on the Domain Names page.
    After you configure DNS settings, run the following command to check whether the DNS settings take effect:
    ping <the custom domain name>

    The result shows that the request is routed to the endpoint of the OSS bucket after you ping the custom domain name. This indicates that the DNS settings take effect.

    Verify DNS Configurations

Step 5: Verify the acceleration performance

Perform the following operations to verify that data transfer is accelerated when clients in the China (Hong Kong) region access the OSS bucket in the US (Silicon Valley) region.

In this example, ossutil provided by OSS is used to replicate the files stored in the OSS bucket in the US (Silicon Valley) to a client in the China (Hong Kong) region. For more information about how to install ossutil, see Download and installation.

  1. Open the command prompt on a client in the China (Hong Kong) region.
  2. Run the following command to replicate the files that are stored in the OSS bucket in the US (Silicon Valley) to the client in the China (Hong Kong) region.
    • Before GA is used:
      ./ossutil64 --retry-times 10 -e <the endpoint of the source OSS bucket> -k <the AccessKey secret of the account> -i <the AccessKey ID of the account> -f cp oss://<the name of the source OSS bucket>/<the source file> ./
      Note Before GA is used, the domain name that you access is > ./the name of the source OSS bucket>.<the endpoint of the source OSS bucket>. Example: testBucketName.oss-us-west-1.aliyuncs.com.
      Figure 1. Network latency before acceleration
      GA Not Used
    • After GA is used, the commands used to replicate files vary based on whether a custom domain name is used.
      • Run the following command if you do not use a custom domain name:
        ./ossutil64 --retry-times 10 -e <the endpoint of the source OSS bucket> -k <the AccessKey secret of the account> -i <the AccessKey ID of the account> -f cp oss://<the name of the source OSS bucket>/<the source file> ./
        Note
        • The domain name that is accessed and the command are the same as those before GA is used. However, you must modify the hosts file and map the endpoint to the accelerated IP address allocated by GA. For more information, see Step 4: Configure the hosts file or DNS settings.
        • If you do not use a custom domain name to replicate files, the domain name that you access is <the name of the source OSS bucket>.<the endpoint of the source OSS bucket>. Example: testBucketName.oss-us-west-1.aliyuncs.com.
        Figure 2. Network latency when no custom domain name is used
        Custom Domain Name Not Used
      • Run the following command if you use a custom domain name:
        ./ossutil64 --retry-times 10 -e <the custom domain name> -k <the AccessKey secret of the account> -i <the AccessKey ID of the account> -f cp oss://<the name of the source OSS bucket>/<the source file> ./
        Note
        • Make sure that you configure DNS settings that map the custom domain name to GA. For more information, see Step 4: Configure the hosts file or DNS settings.
        • If you use a custom domain name to replicate files, the domain name that you access is <the name of the source OSS bucket>.<the custom domain name>. Example: testBucketName.example.com.
        Figure 3. Network latency when a custom domain name is used
        Custom Domain Name Used
    The test result shows that GA reduces the network latency when the client in the China (Hong Kong) region accesses the OSS bucket in the US (Silicon Valley) region.
    Note When you use GA to accelerate OSS buckets in the US (Silicon Valley) region for clients in the China (Hong Kong) region, the acceleration performance varies based on your workloads.