This topic describes methods to connect an Elastic Compute Service (ECS) instance to an ApsaraDB for Redis instance when they are deployed in different types of networks. For example, when an ECS instance is configured in the classic network and an ApsaraDB for Redis instance resides in a virtual private cloud (VPC), you can connect them by using the methods described in this topic.

Prerequisites

The ECS instance and the ApsaraDB for Redis instance are deployed in the same region. For more information about ECS instances, see What is ECS?

Network types

Network type Description
VPC (recommended) A VPC is a private network dedicated to your Alibaba Cloud account. VPCs are logically isolated from each other at Layer 2 to provide higher security and performance. If a Redis client is deployed on an ECS instance, you can connect the client to an ApsaraDB for Redis instance over a VPC for higher security and lower network latency.
Classic network Cloud services on the classic network are not isolated. Unauthorized access can be blocked only by using security groups or whitelists.

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

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

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

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. In the top navigation bar, select the region in which the instance is deployed.
  4. On the Instances page, click the ID of the ECS instance that you want to use.
  5. In the Network Information section, obtain the ID of the VPC 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 Change the network type from classic network to VPC.
    Note The network type can be switched from classic network to VPC but not from VPC to classic network.

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

  1. Log on to the ApsaraDB for Redis console and go to the Instances page. In the top navigation bar, select the region in which the instance is deployed. Then, find the instance and click the instance ID.
  2. In the Basic Information section, obtain the ID of the VPC to which the ApsaraDB for Redis instance belongs.
  3. Select one of the following methods to achieve network interconnection based on your business requirements:
    • Migrate Switch the ECS instance to the VPC to which the ApsaraDB for Redis instance belongs. We recommend that you use this method. For more information, see Migrate an ECS instance from a classic network to a VPC.
    • Use ClassicLink to connect the ECS instance to the VPC to which the ApsaraDB for Redis instance belongs. For more information about ClassicLink, see Overview. For more information about the method procedure, 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 migrate the ECS and ApsaraDB for Redis instances to the same VPC.

What to do next

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