When you create a DSW instance by using an overseas container image (such as one from docker.io) or pull an overseas model (such as one from huggingface.co) in a mainland China region, cross-region network access may fail. You can create a Global Accelerator (GA) instance to provide cross-region network access for DSW.
Solution recommendations
Before you use Global Accelerator (GA), try the following alternatives based on your actual requirements:
|
Solution |
Applicable scenario |
Cost |
|
Use a domestic mirror site |
Download popular models and datasets from Hugging Face |
Free |
|
Switch to a region outside mainland China |
Frequent access to overseas resources is required |
DSW instance fees only |
|
Download locally and upload |
One-time download of a small amount of resources |
Free |
|
Global Accelerator (GA) (solution in this topic) |
Stable, high-speed cross-region network access is required |
GA instance fees + bandwidth fees |
If none of the alternatives meet your needs (for example, you need to access resources that are not available on mirror sites or require stable cross-region network connectivity), follow the GA configuration steps below.
Important notice
Please comply with laws and regulations when accessing the internet. Websites that contain illegal content cannot be accessed.
Billing
Global Accelerator (GA) is a separate cloud service that incurs additional charges, including instance fees, Capacity Unit (CU) fees, and data transfer bandwidth fees. For details, see Global Accelerator pricing.
Procedure
The following steps use Hugging Face and Docker as examples. You can configure acceleration as needed. The domains to be accelerated are listed below:
|
Resource to accelerate |
Domain to accelerate |
|
Hugging Face |
|
|
Docker |
|
Step 1: Create a standard GA instance
The following describes only the key parameters. For details about all parameters, see Create and manage Standard GA instances.
Create a standard instance. Activate Global Accelerator, and log on to the console. Click Create Standard Pay-as-you-go Instance, configure basic settings such as the instance name, and click Next.
-
Configure the acceleration region. For Acceleration Region, select the region where the DSW instance resides. Set the bandwidth based on your business requirements, and click Next.
In the bandwidth allocation table, IP Address Protocol is set to IPv4 by default, and Network Type is set to BGP (Multi-ISP) by default. If the acceleration region includes mainland China, make sure that the domain name has obtained an ICP filing.
Configure the listener. Enter a listener name, set Protocol to TCP, and set the Port to
80,443. You can also configure the listener based on your actual business requirements.-
Configure endpoint groups.
Region: Select an overseas region. We recommend that you select China (Hong Kong).
-
Endpoint Configuration: Configure the domain name that you want to accelerate. Configure one domain name here. If you need to configure multiple domain names, add virtual endpoint groups later.
Backend Service Type: Select Custom Domain.
Backend Service: Enter the domain name to be accelerated, such as
huggingface.co.Weight: Use the default value.
Review the configuration. Confirm the settings, and then Submit.
Step 2: Add virtual endpoint groups and configure forwarding policies
In the left-side navigation pane, click Standard Instances > Instance List. Click the name of the instance that you just created, and then click Listener to go to the listener configuration page.
-
Add other domain names to be accelerated by using virtual endpoint groups. Click the name of the existing listener to go to the listener configuration page, and click Endpoint Group. The default endpoint group for the
huggingface.codomain configured in Step 1 already exists.Add a separate virtual endpoint group for each additional domain name to be accelerated. In this topic, you must also add
cdn-lfs.hf.co,docker.io,registry-1.docker.io, andauth.docker.io. Click Add Virtual Endpoint Group.Backend Service Type: Select Custom Domain.
Backend Service: Enter the domain name to be accelerated.
Weight: Use the default value.
Example: For Endpoint Group Name, enter
cdn-lfs_hf_co. For Region, select China (Hong Kong). Set Preserve Client Source IP to No, and then click Create.Add the other domain names to be accelerated in the same way. After the configuration is complete, you have four virtual endpoint groups.
-
Configure listener forwarding policies. On the listener configuration page, click Forwarding Policies. Insert a new policy for each of the five domain names to be accelerated.
Domain Name Matching Rule: Select Exact and wildcard match.
Forwarding Domain Name: Enter the domain name to be accelerated.
Forward To: Select the endpoint group type and endpoint group that correspond to the domain name configuration.
After the configuration is complete, you have five forwarding policies:
Domain
auth.docker.iois forwarded to virtual endpoint groupauth_docker_ioDomain
registry-1.docker.iois forwarded to virtual endpoint groupregistry-1_docker_ioDomain
docker.iois forwarded to virtual endpoint groupdocker_ioDomain
cdn-lfs.hf.cois forwarded to virtual endpoint groupcdn-lfs_hf_coDomain
huggingface.cois forwarded to the default endpoint group
Step 3: Use Global Accelerator in DSW
|
Acceleration method |
Method 1: Modify the hosts file of the DSW instance to accelerate access |
|
|
Applicable scenario |
Obtain overseas models or other resources in an existing DSW instance. |
Create a DSW instance by using an overseas image, and obtain overseas models or other resources in the DSW instance. |
|
Does DSW require VPC, security group, and vSwitch configurations? |
Optional |
Required |
|
Does DSW require NAT Gateway and SNAT configurations? |
Optional. When you download large files, the network speed may be insufficient. You can Improve internet access with a private gateway. |
|
Method 1: Modify the hosts file of the DSW instance to accelerate access
Obtain the acceleration IP. In the Global Accelerator console, click the name of the created instance > Acceleration Region, and select any Acceleration IP.
-
Modify the hosts file of the DSW instance. Open the DSW instance, run
vim /etc/hostsin the Terminal, add the acceleration IP and the domain name to be accelerated to the file, and then save and exit. Example:120.27.23xxx0 huggingface.co 120.27.238.xxx cdn-lfs.hf.co
Method 2: Use PrivateZone to accelerate access
Obtain the CNAME acceleration domain name of the Global Accelerator instance. In the Global Accelerator console, click the name of the created instance, and obtain CNAME on the Instance Information tab.
Obtain the VPC information of the DSW instance. For an existing instance, click the instance name and view the VPC information on the Instance Settings page.
-
Add domain names and resolution records in PrivateZone. Log on to the Alibaba Cloud DNS console. On the PrivateZone User Domains page, click Add Domain Name.
Use
huggingface.coandcdn-lfs.hf.coas examples. First, configure the built-in authoritative domain nameco. Select the VPC used by the DSW instance obtained in Step 2 for Effective in Alibaba Cloud VPC, and click OK.If you have not created a DSW instance, select the same VPC as the PrivateZone when you create the instance later.
Then, click the name of the built-in authoritative domain name
coto go to the configuration page, and click Add Record. Becausehuggingface.coandcdn-lfs.hf.couse the same authoritative domain nameco, add them to the resolution records one by one.Record Type: Select CNAME.
Host Record: Enter the part of the domain name excluding the authoritative domain name, such as
huggingfaceorcdn-lfs.hf.Record Value: Enter the Global Accelerator CNAME obtained in Step 1.
Configure
docker.io,registry-1.docker.io, andauth.docker.ioin the same way. You will end up with two built-in authoritative domain names.
Related documentation
If network access speed does not meet your requirements, you can Improve internet access with a private gateway.
For more DSW network access and configuration scenarios, see Network configuration.