Canary-test using Spring Cloud Gateway

Canary-test definition

In software testing, a canary is a push of programming code changes to a small group of end users who are unaware that they are receiving new code. Because the canary is only distributed to a small number of users, its impact is relatively small and changes can be reversed quickly should the new code prove to be buggy.

How to implement Canary-test in Spring Cloud Gateway

This can be implemented using the WeightRoutePredicateFactory introduced in Spring Cloud Finchley.M9. The idea is very simple, we just give diffrent weights to different routes, And Spring Cloud Gateway will dispatch the request to diffrent uris according the weights in the same group.

a sample application

Here is a simple sample application in github, where the Spring Cloud Gateway will dispatch 95% of the requests to version 1 and 5% of the traffic to version 2 of a specified service, as shown by the following figure.

The routes configuration in application.yaml is as follows.

      - id: service1_v1
        uri: http://localhost:8081/v1
        - Path=/s
        - Weight=service1, 95

      - id: service1_v2
        uri: http://localhost:8081/v2
        - Path=/s
        - Weight=service1, 5


1.What is canary?
2.The Spring Cloud Gateway issue of Allow Rolling Deployments