1. principle of grayscale Publishing
The research and development of Internet business advocates “small step, fast run and fast iteration”. This requires that the service can be upgraded with high frequency on the premise of 7*24-hour uninterrupted service, which puts forward the demand for “gray publishing”.
Gray release (also known as Canary release) refers to a release method that can smoothly transition between black and white (from Baidu Encyclopedia).
From the perspective of traffic forwarding, the principle of gray-scale publishing is shown in Figure 1. User traffic is forwarded to the service by the load balancer. Service deployment is divided into formal service and test service. The load balancer executes the gray-scale publishing policy and forwards the qualified gray-scale traffic to the test service.
Figure 1 principle of grayscale Publishing
There may be two types of grayscale strategies:
- according toCertain flow characteristicsTo select grayscale traffic. Features that may be used as traffic selection include: user origin, special request tags, etc.
- according toCertain flow ratioTo select grayscale traffic. For example, you can control to select 1% of the traffic as the grayscale traffic.
2. BFE supports grayscale Publishing
BFE pairBased on flow characteristicsandBased on flow ratioBoth of these grayscale strategies provide support.
2.1 gray level policy support based on traffic characteristics
The feature-based gray-scale strategy can be realized by using the routing forwarding table of BFE.
In BFE, it can be set independently for each tenantBasic reprint、Advanced forwarding tableandDefault forwarding rule。 Fig. 2 and Fig. 3 show an example of implementing a feature-based grayscale strategy using an advanced forwarding table.
In this example, there are five services: A, B, C, D and E. The four services a, B, C and d use the configuration in the basic forwarding table to complete the matching, and the e service is the default service (as shown in Figure 2).
Figure 2 Forwarding configuration before gray Publishing
Service d was originally configured only in the basic forwarding table. Later, because of the gray scale test, the target cluster corresponding to www.c.c.com is set as the reserved word “advanced_mode” in the basic forwarding table (meaning that the data is transmitted to the advanced forwarding table for further processing); At the same time, two rules (describing the matching conditions based on the BFE condition expression) are added to the advanced forwarding table to forward the requests whose key is deviceid and whose value is prefixed with “X” in the cookie to D1, the gray-scale test cluster, and forward other traffic whose host is www.c.com to cluster D (as shown in Figure 3).
Figure 3 implementation of feature-based grayscale Publishing
In addition to using cookies, information in headers and queries is often used to distinguish test traffic. For these fields, there are also special condition primitives in BFE to describe relevant features. You can view the BFE supported condition primitives in the following link.
2.2 gray scale policy support based on traffic ratio
Using the intranet traffic scheduling mechanism provided by BFE, the gray scale policy based on traffic proportion can be realized.
Figure 4 gray scale strategy based on traffic ratio
In order to cooperate with scale-based gray-scale publishing, two sub clusters D1 and D2 can be normally prepared. In BFE, set the shunting ratio of the two sub clusters to 1% and 99%.
When launching new functions, the new version of the program is first launched in the D1 sub cluster. Use 1% of the traffic. After a period of verification, put the new version of the program online to the D2 sub cluster.
You can view the method of setting shunting weights for sub clusters in the following link
3. operation based on BFE control surface
at presentBFE control surface components have been released open source。 After the BFE control surface components are installed, both the gray-scale publishing based on flow characteristics and the gray-scale publishing based on flow proportion can be operated directly by logging in to the BFE dashboard, or by calling the interface provided by the BFE API.
For instructions on operating on the BFE dashboard, see the following link:
For the configuration of routing forwarding rules:
For the configuration of sub cluster diversion ratio:
Figure 5 configuring routing forwarding rules using BFE dashboard
For the interface description of BFE API, see the following link:
“Gray publishing” is an important capability required for Internet business research and development. BFE supports two methods of gray-scale publishing (gray-scale publishing based on traffic characteristics and gray-scale publishing based on traffic proportion). Combined with the open source BFE control surface components, you can use the BFE dashboard or BFE API to complete the relevant configuration of gray-scale publishing.
Welcome to follow the wechat official account of “BFE open source project” to get more updates of this project. thank you!