This topic describes methods to connect Elastic Compute Service (ECS) instances to ApsaraDB for Redis instances when they are deployed in different types of networks. For example, an ECS instance is configured in a classic network, but an ApsaraDB for Redis instance resides in a virtual private cloud (VPC).

Prerequisites

The ECS instance and the ApsaraDB for Redis instance must be deployed in the same region.

Network types

Network type Description
VPC (recommended) A VPC is a private network dedicated to your Alibaba Cloud account. VPCs are logically isolated from one another at Layer 2 to provide higher security and performance. When a Redis client is deployed on an ECS instance, you can connect to an ApsaraDB for Redis instance through a VPC to gain better security performance and reduce network latency.
Classic network Cloud services in a classic network are not isolated. Unauthorized access to cloud services is blocked only by the security groups or whitelist policies.

For more information about internal network types, see Network types.

Note In addition to connections over an internal network, the ApsaraDB for Redis instance also supports connections over the Internet. For more information, see Use a public endpoint to connect to an ApsaraDB for Redis instance.

Connect an ECS instance in a VPC to an ApsaraDB for Redis instance in a classic network

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. On the top of the page, select the region where the instance is deployed.
  4. On the Instances page, click the instance ID of the specific ECS instance.
  5. In the Network Information section, obtain the VPC ID to which the ECS instance belongs.
    Figure 1. Obtain the VPC ID of the ECS instance
    Obtain the VPC ID of the ECS instance
  6. Switch the ApsaraDB for Redis instance to the VPC to which the ECS instance belongs. For more information, see Switch to VPC network.
    Note You can switch the network type from classic network to VPC, but cannot switch the network type from VPC to classic network.

Connect an ECS instance in a classic network to an ApsaraDB for Redis instance in a VPC

  1. Log on to the ApsaraDB for Redis console.
  2. On the top of the page, select the region where the instance is deployed.
  3. On the Instance List page, click the Instance ID of the instance.
  4. In the Basic Information section, obtain the VPC ID to which the Redis instance belongs.
    Figure 2. Obtain the VPC ID of the ApsaraDB for Redis instance.
    Obtain the VPC ID of the ApsaraDB for Redis instance.
  5. Select one of the following methods to achieve network interconnection based on your business requirements:
    • (Recommended) migrate ECS instances to the VPC to which the ApsaraDB for Redis instance belongs. For more information, see Migrate ECS instances.
    • Use ClassicLink to connect to the VPC to which the ApsaraDB for Redis instance belongs. For more information, see Connect a classic network to a VPC.
      Note
      • When you configure security group rules of ClassicLink, you must set the protocol to custom TCP. The port range is 6379/6379.
      • The ClassicLink-based interconnection is a temporary solution. To achieve high-speed connection in the production environment, we recommend that you create the ECS and ApsaraDB for Redis instances in the same VPC.

What to do next

Select one of the following connection methods based on your business requirements: