Route Management Rules

Scenario

Through route management, you can perform dark launch to smoothly upgrade versions.

Precautions

  1. You need to access microservices to the configuration center before using the dark launch function.
  2. You can customize dark launch rules by setting the microservice.yaml file. Example:
    servicecomb:
        routeRule:  
          provider: | #Service name.
          - precedence: 2 #Priority.
              match:        #Matching policy.
                headers:          #Header matching.
                  region:            
                    regex: 'regoin[0-9]*'
                    caseInsensitive: false # Whether the value is case-sensitive. The default value is false, indicating that the value is case-sensitive.
                  type:         
                    exact: gray
            route: #Routing rule.
                - weight: 100 #Weight value.
                  tags:
                    version: {version1}
                    app: {appId}
            - precedence: 1
              route:
                - weight: 20
                  tags:
                    version: 0.01
                    tags: tag
                - weight: 80
                  tags:
                    version: 0.02
    

Rule Description

  • match specifies the requests to be matched. The matching condition is header.
  • header supports regular expressions for accurate matching.
  • If match is not defined, any request can be matched.
  • The forwarding weight is defined in routeRule.{targetServiceName}.route and is configured by weight. The value of weight indicates the percentage. The sum of the values must be equal to 100. If the sum is smaller than 100, the value in the latest version is calculated.
  • tags specifies a service group and is defined in routeRule.{targetServiceName}.route. The configuration content includes version and app.
  • caseInsensitive determines whether a value is case-sensitive. false (default): indicates that the condition is case-sensitive. true: indicates that the value is not case-insensitive.
  • A larger priority value indicates a higher priority.

Matching Process

In the preceding example, all requests for accessing the provider service are first matched with the rule with the priority of 2. If the header contains the key which is region, implement case-sensitive matching based on the regular expression rule. If the header contains the key which is type, implement accurate matching based on the string. If the matching succeeds, 100% traffic is allocated to the instances corresponding to the versions and tags based on the route configuration. If the matching fails, the rule with the priority of 1 is used. Different rules cannot have the same priority.

Troubleshooting

If rule configurations are incorrect or no rule is matched, dark launch rules are skipped. In this case, it can be regarded that no dark launch configuration exists.

If a rule is matched but no instance can be found based on versions or tags, remaining traffic is automatically forwarded to the latest version.

Load Balancing Algorithm

Like Nginx, the smooth weighted round robin algorithm is used to evenly distribute traffic to service instances.

Instance Tags Configuration

For microservice instances, you can specify tags by setting the microservice.yaml file or through APIs of the service center.

instance_description:
  properties:
    tags:
      tag_key: tag_value