The tag-based routing feature allows you to allocate one or more application instances to the same group by using tags. This way, you can forward traffic to application instances in specific groups. The tag-based routing feature is suitable for blue-green releases and canary releases.

Background information

The tag-based routing feature is available only for applications that are deployed on Elastic Compute Service (ECS) clusters.

Scenarios

  • Multi-version development and testing

    If multiple versions are developed at the same time, you must prepare a development environment for each version. The costs of development environments are high. To reduce costs, you can use tag-based routing to implement end-to-end throttling.

    End-to-end throttling is implemented based on the tag-based routing feature. End-to-end throttling allows you to route specific traffic to a specific development environment. For example, if only Application B and Application D are modified in Development Environment 1, you can create Tag 1 for the versions of the two applications in Development Environment 1, and create a tag-based routing rule. This way, when Application A calls Application B, the system checks whether the traffic meets the conditions of the tag-based routing rule. If yes, the traffic is routed to Application B V1.1 in Development Environment 1. If no, the traffic is routed to Application B V1 in the baseline environment. When Application C calls Application D, the traffic is routed to Application D V1 or Application D V1.1 based on the tag-based routing rule.

  • Throttling for a multi-version application

    If multiple versions of an application run online at the same time and are deployed in different environments, you can use the tag-based routing feature to isolate the traffic that is destined for different versions in different environments. For example, you can route the traffic of flash sale orders or the traffic of orders from different channels to the special environment, and route common traffic to the common environment. This way, the traffic destined for the special environment is not routed to the common environment even if exceptions in the special environment occur, and the common environment is not affected.

  • A/B Testing

    Multiple versions of an application run online at the same time. To perform A/B testing on the different versions, you can use end-to-end throttling to route the traffic that is initiated from Region A, for example, the China (Hangzhou) region, to Application V1, and route the traffic that is initiated from Region B, for example, the China (Shanghai) region, to Application V1.1. Then, you can verify the different versions. This helps reduce risks when you publish new products or features and facilitate product innovation.

Procedure

In this example, Application A is deployed on ECS instances. Application A has a default group, and the group contains three application instances.

The following steps describe how to configure tag-based routing:

  1. Create tags. Create Group 1 and Group 2 for Application A, allocate one application instance in the default group to Group 1 and one application instance to Group 2, and create tags for Group 1 and Group 2.
  2. Create tag-based routing rules. Create tag-based routing rules based on the tags of Group 1 and Group 2.

After tag-based routing is configured, when Application B calls Application A, traffic is routed to Group 1 and Group 2 based on the tag-based routing rules. Other traffic that does not meet the conditions of the tag-based routing rules is routed to the default group.

Create a tag

Create a group for an application and add an instance to the group. Then, select JVM from the Group Settings drop-down list to create a tag.

  1. Log on to the EDAS console.
  2. Create a group for an application. For more information, see Create a group.
  3. Add an application instance to the new group. You can allocate an application instance of the default group to the new group, or purchase a new instance. For more information, see Add an instance.
    Notice After the application instance of the default group is allocated to the new group, you must restart the application instance. Otherwise, the system does not identify the tag. If you purchase a new instance for the new group, you do not need to restart the instance.
  4. In the upper-right corner of the new group page, select JVM from the Group Settings drop-down list.
    Grouping Settings - JVM
  5. In the Group Settings dialog box, click Custom. In the Custom section, turn on the switch in the Custom column. In the Configuration Body field, specify a tag for the group and click Configure JVM Parameters.

    You must specify a tag in the Dalicloud.service.tag=tag1 format. tag1 indicates the tag name. Specify the tag name based on your business requirements.

    Group Settings- JVM - Custom

Create a tag-based routing rule

When a tag is created, you can create a tag-based routing rules based on the tag.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservices Governance > Dubbo.
  3. In the navigation tree of Dubbo, click Tag-based Routing.
  4. On the Label routing page, click Create label routing.
  5. In the Create label routing panel, configure the parameters and click OK.
    Create label routing

    The following table describes the parameters.

    Parameter Description
    Namespace Select a region and a namespace based on your business requirements.
    Route Name Enter the name of the tag-based routing rule. For example, you can enter test-springcloud.
    Description Enter the description of the tag-based routing rule.
    Application Select an application from the drop-down list. Select the tag from the drop-down list. The tag is the value that you specify for the -Dalicloud.service.tag parameter. After you select the tag, the Application instance section displays the IP address and port of the application instance.
    Link Delivery Turn on Link Delivery if you want to use end-to-end throttling.
    Note The end-to-end throttling feature is in canary release, If you want to use end-to-end throttling, join the DingTalk group numbered 23335402 to contact technical support.
    Traffic rules
    Frame type Select Spring Cloud or Dubbo based on your business requirements.
    • Spring Cloud: You can specify only a URL, such as /getIp.
    • Dubbo: You can select a specific service and an interface.
    Conditional mode Select At the same time meet the following conditions or Meet any of the following conditions based on your business requirements.
    Condition list Specify the Condition and Value parameters based on the Parameters and Parameter value get expression parameters in this section.

Verify the result

This topic provides an example on how to create a tag-based route for an application. You can configure a tag-based route for the application by referring to the example, and then verify the route based on your business requirements.