When using DSW instances in Chinese mainland regions, you might face connection issues when creating instances from overseas container images (e.g., from docker.io) or pulling models from overseas repositories like huggingface.co. To resolve this, you can create a Global Accelerator (GA) instance to enable cross-border network access for your DSW instances.
Choosing a solution
Before configuring Global Accelerator (GA), consider these alternatives:
|
Solution |
Use case |
Cost |
|
Use a domestic mirror site |
Download popular models and datasets from Hugging Face. |
Free |
|
Switch to a non-Chinese mainland region |
For frequent access to overseas resources. |
DSW instance fees only |
|
Download locally and then upload |
For one-time downloads of a few resources. |
Free |
|
Global Accelerator (GA) (this tutorial's solution) |
For stable, high-speed cross-border network access. |
GA instance fee + data transfer fee |
If these alternatives are unsuitable—for example, if you need to access resources unavailable on domestic mirror sites or require a stable cross-border connection—follow these steps to configure GA.
Important
Access to websites with illegal content is prohibited.
Billing
Global Accelerator (GA) is a separate cloud product and is billed separately. Charges include instance fees, capacity unit (CU) fees, and the data transfer fee. For details, see Global Accelerator Billing.
Procedure
The following steps use Hugging Face and Docker as examples to show how to accelerate access. You can adapt this configuration for other services.
|
Resource |
Domains |
|
Hugging Face |
|
|
Docker |
|
Step 1: Create a standard Global Accelerator instance
This section highlights key parameters. For a full list of parameters, see Create and manage standard Global Accelerator instances.
-
Create a standard instance. Activate Global Accelerator, log on to the console, and click Create standard pay-as-you-go instance. Configure basic information, such as the instance name, and click Next.
-
Configure the acceleration area. For acceleration area, select the region where your DSW instance is located. Set the bandwidth based on your business needs, and then click Next.
In the bandwidth allocation table, IP Address Protocol defaults to IPv4, and ISP Type defaults to BGP (Multi-ISP). If the acceleration region includes Chinese mainland regions, make sure the domain name has completed ICP filing.
-
Configure the listener. Enter a listener name. For protocol, select TCP. Set Port to
80,443. -
Configure the endpoint.
-
Region: Select an overseas region. We recommend US (Silicon Valley).
-
endpoint configuration: Configure the domain you want to accelerate. This step configures only one domain. To configure multiple domains, you can add virtual endpoint groups later.
-
Backend service type: Select Custom domain.
-
backend service: Enter the domain to accelerate, such as
huggingface.co. -
weight: Keep the default value.
-
-
-
Review the configuration. Confirm the settings and then click Submit.
Step 2: Add endpoint groups and forwarding rules
-
In the left-side navigation pane, click Standard instances > Instances. Click the name of the instance you just created, and then click the Listeners tab to go to the listener configuration page.
-
Use virtual endpoint groups to accelerate additional domains. Click the listener name to open its configuration page, then click the Endpoint group tab. The default endpoint group for the domain
huggingface.cothat you configured in Step 1 is already listed.Add a separate virtual endpoint group for each additional domain. For this example, you need to add the following domains:
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 to accelerate.
-
weight: Keep the default value.
Configuration example: Set Endpoint Group Name to
cdn-lfs_hf_co, set Region to US (Silicon Valley), set Preserve Client Source IP to Do Not Preserve, and then click Create.Repeat this process to add the other domains that you want to accelerate. After you finish, four new virtual endpoint groups are created.
-
-
Configure listener forwarding rules. On the listener configuration page, click the Forwarding rule tab. For each of the five domains, Add forwarding rule.
-
domain matching rule: Select Exact match and wildcard.
-
Forwarding domain: Enter the domain to accelerate.
-
Forward to: Select the endpoint group type and endpoint group that corresponds to the domain.
After the configuration is complete, you will have five forwarding rules:
Domain
auth.docker.ioforwards to virtual endpoint groupauth_docker_ioDomain
registry-1.docker.ioforwards to virtual endpoint groupregistry-1_docker_ioDomain
docker.ioforwards to virtual endpoint groupdocker_ioDomain
cdn-lfs.hf.coforwards to virtual endpoint groupcdn-lfs_hf_coDomain
huggingface.coforwards to the default endpoint group
-
Step 3: Use Global Accelerator in DSW
|
Acceleration method |
Method 1: Accelerate access by modifying the hosts file of the DSW instance |
|
|
Use case |
To retrieve overseas models or other resources in an existing DSW instance. |
To create a DSW instance from an overseas container image or retrieve overseas resources. |
|
DSW VPC, security group, and vSwitch configuration |
Optional |
Required |
|
DSW dedicated gateway and SNAT configuration |
Optional. If the network speed is insufficient for downloading large files, you can use a dedicated gateway to improve public network access speed. |
|
Method 1: Modify the DSW hosts file
-
Get an accelerated IP address. In the Global Accelerator console, click your instance name. On the Acceleration area tab, copy an accelerated IP address.
-
Modify the hosts file in the DSW instance. In the DSW instance, open a terminal and run the command
vim /etc/hosts. Add the accelerated IP address and the domains you want to accelerate to the file. Then, save the file and exit. The following example shows the format:120.27.23xxx0 huggingface.co 120.27.238.xxx cdn-lfs.hf.co
Method 2: Use PrivateZone
-
Get the CNAME of the GA instance. In the Global Accelerator console, click the name of your instance. On the Instance information tab, copy the CNAME.
-
Get the VPC information for your DSW instance. For an existing instance, click the instance name and find the VPC information on the Instance Settings page.
-
Add a zone and DNS records in PrivateZone. Log on to the Alibaba Cloud DNS console. On the PrivateZone User domains page, click Add zone.
For example, to accelerate access to
huggingface.coandcdn-lfs.hf.co, first configure the built-in authoritative domainco. In the Effective in VPCs section, select the VPC used by your DSW instance that you found in step 2. Click OK.If you have not created the DSW instance yet, select this same VPC when you create it.
Then, click the name of the built-in authoritative domain
coto open its configuration page and click Add record. Becausehuggingface.coandcdn-lfs.hf.couse the same authoritative domainco, add a DNS record for each domain.-
record type: Select CNAME.
-
hostname: Enter the part of the domain that precedes the authoritative domain, such as
huggingfaceorcdn-lfs.hf. -
record value: Enter the GA CNAME that you copied in step 1.
Use the same method to configure
docker.io,registry-1.docker.io, andauth.docker.io. When you are finished, you will have two built-in authoritative domains. -
Related documents
-
If network access is too slow, you can use a dedicated gateway to improve public network access speed.
-
For more network access and configuration scenarios for DSW, see Network configurations.