When users access resources that are 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 access to OSS buckets.
Scenario
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 volume of files in OSS. When users from the office in the China (Hong Kong) region access the resources that are 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 occur.
You can deploy a GA instance and specify the OSS bucket as an endpoint. GA uses high-bandwidth Border Gateway Protocol (BGP) lines and the global transmission network of Alibaba Cloud. This accelerates data transfer when clients in the China (Hong Kong) region access the resources that are 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
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.
Log on to the GA console.
In the upper-right corner of the Instances page, click Purchase Guide.
NoteIf this is the first time that you use the GA service, skip this step.
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 Region
Select the region that requires acceleration.
In this example, China (Hong Kong) is selected.
Service Region
Select the region where the destination server is deployed.
In this example, US (Silicon Valley) is selected.
ICP Filing
Specify whether you applied for an Internet Content Provider (ICP) number for the OSS bucket in which the resources are stored.
In this example, No is selected.
NoteIf you want to accelerate access to OSS buckets that are deployed in the Chinese mainland, you must obtain an ICP number. In this case, you must select Yes.
Before you use a custom domain name to access OSS buckets, you must obtain an ICP number. For more information, see What is an ICP filing?
If you do not have a custom domain name and you use the OSS endpoint that is 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
Select the maximum number of concurrent connections that are supported by the GA instance. When the number of concurrent connections reaches the upper limit, new connection requests are dropped.
In this example, 5 Thousand is selected.
In the Recommended Service List section, click Generate Service List after you confirm the information.
On the buy page, configure the parameters and click Buy Now to complete the payment. The following table describes the parameters.
Parameter
Description
Term
Select a subscription duration.
Instance Type
Select the type of the GA instance.
In this example, Standard is selected.
Specifications
Select a specification for the GA instance.
In this example, Small I (Specifications 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 to the region.
To accelerate content delivery between the Chinese mainland and regions outside the Chinese mainland by using a basic bandwidth plan whose bandwidth type is Premium, you must specify China (Hong Kong) as the acceleration region.
On the Instances page, find the GA instance that you created and click its ID.
On the page that appears, click the Acceleration Areas tab. Then, click Add Acceleration Area.
In the Add Acceleration Area dialog box, set the parameters and click OK. The following table describes the parameters.
Parameter
Description
Select Acceleration Region
Select the region that requires acceleration and click Add.
In this example, China (Hong Kong) is selected.
Assign Bandwidth
Specify the bandwidth that you want to allocate to the region.
In this example, 2 Mbit/s of bandwidth is allocated.
IP Protocol
Select the protocol that is used by the users to connect to GA.
In this example, IPv4 is selected.
After you add a 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 content delivery from users in the specified region to the specified backend servers through GA.
Step 3: Add a listener and an endpoint group
A listener listens for connection requests and distributes the requests to endpoints based on the port and 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 endpoints in the endpoint group.
On the instance details page, click the Listeners tab and then click Add Listener.
On the Configure Listener & Protocol wizard page, configure the parameters and click Next. The following table describes the parameters.
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 a protocol for the listener.
In this example, TCP is selected.
NoteBy default, OSS buckets can be accessed over both HTTP and HTTPS. To access small-sized files that are 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 that are 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
Specify a port for the listener to receive and forward requests to endpoints. Valid values: 1 to 65499.
You can specify up to 30 ports for each listener. Separate multiple listener ports with commas (,). For example, you can enter 80,90,8080.
If you want to specify a port range, use a hyphen (-). Example: 80-85.
In this example, 80,443 is entered.
NoteIn 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 is selected.
On the Configure Endpoint Group wizard page, configure the parameters and click Next. The following table describes the parameters.
This topic describes only the key parameters. For more information, see Add and manage endpoint groups of intelligent routing listeners.
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.
Select Acceleration Region
Select the region to which the endpoint group (destination servers) belongs.
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 OSS.
Backend Service: Select the OSS bucket in which the resources that you want to access are stored.
Weight: Enter a weight for the endpoint. Valid values: 0 to 255. GA distributes network traffic to endpoints based on the configured weights.
WarningIf you set the weight of an endpoint to 0, Global Accelerator stops distributing network traffic to the endpoint. Proceed with caution.
Preserve client IP addresses
Specify whether to preserve client IP addresses. If you enable the client IP address preservation feature, backend servers can obtain client IP addresses.
In this example, Preserve Client IP is disabled.
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 that is 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 that is allocated by GA. For more information about the format of OSS endpoints, see OSS domain name rules.
In this example, the CentOS 8 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.
Open the CLI on a client in the China (Hong Kong) region.
Configure the hosts file.
Run the following command to open the/etc/hosts file:
vim /etc/hosts
Press the I key to enter the edit mode and add the following content 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 the Esc key, enter
:wq!
, and then press the Enter key to save the modified file and exit the edit mode.
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.
Configure DNS settings
You must configure DNS settings to route requests that are 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 that is allocated by GA.
Before you configure DNS settings, make sure that you 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.
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.
Log on to the Alibaba Cloud DNS console.
On the Domain Name Resolution page, find the domain name and click DNS Settings in the Actions column.
Select one of the following methods to configure DNS records based on your requirements:
If you do not add a CNAME record that maps a custom domain name to the public endpoint of the OSS bucket when you associate the custom domain name with the OSS bucket, click Add DNS Record.
If you add a CNAME record that maps a custom domain name to the public endpoint of the OSS bucket when you associate the custom domain name with the OSS bucket, click Modify in the Actions column of the CNAME record.
In the Add DNS Record or Modify DNS Record panel, configure the parameters and click OK. The following table describes the parameters.
A record
Parameter
Description
Record Type
Select A from the drop-down list.
An A record is used to map a domain name to an IPv4 address.
Hostname
Enter the prefix of the accelerated domain name.
If the accelerated domain name is
www.aliyun.com
, set the prefix towww
.If the accelerated domain name is
aliyun.com
, set the prefix to@
.If the accelerated domain name is
*.aliyun.com
, set the prefix to*
.If the domain name is
mail.aliyun.com
, set the prefix tomail
.
DNS Request Source
Select Default from the drop-down list.
Record Value
Enter the accelerated IP address that is allocated by GA.
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.
CNAME record
Parameter
Description
Record Type
In this example, CNAME is selected.
The CNAME record is used to map the endpoint of the OSS bucket to the CNAME allocated by GA.
Hostname
Enter the prefix of the accelerated domain name.
If the accelerated domain name is
www.aliyun.com
, set the prefix towww
.If the accelerated domain name is
aliyun.com
, set the prefix to@
.If the accelerated domain name is
*.aliyun.com
, set the prefix to*
.If the domain name is
mail.aliyun.com
, set the prefix tomail
.
DNS Request Source
Select Default from the drop-down list.
Record Value
Enter the CNAME that is allocated by GA.
You can find the CNAME 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.
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.
Step 5: Test 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 that are 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 Install ossutil.
Open the CLI on a client in the China (Hong Kong) region.
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.
If GA is not 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> ./
NoteIf GA is not 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
.When GA is used, the commands that are used to replicate files vary based on whether a custom domain name is used.
If you do not use a custom domain name, run the following command:
./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> ./
NoteThe domain name that is accessed and the command are the same as those when GA is not used. However, you must modify the hosts file and map the endpoint to the accelerated IP address that is allocated by GA. For more information, see Step 4: Configure the hosts file or DNS settings of this topic.
If you do not use a custom domain name, 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
.
If you use a custom domain name, run the following command:
./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> ./
NoteMake 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 of this topic.
If you use a custom domain name, the domain name that you access is
<the name of the source OSS bucket>.<the custom domain name>
. Example:testBucketName.example.com
.
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.
NoteWhen you use GA to accelerate access to OSS buckets in the US (Silicon Valley) region for clients in the China (Hong Kong) region, the acceleration performance varies based on your workloads.