当前位置:网站首页>How do we do full link grayscale on the database?
How do we do full link grayscale on the database?
2022-07-28 22:31:00 【Alibaba cloud native】
author : Ten sleep
What is full link gray scale ?
In microservice Architecture , The dependencies between services are complex , Sometimes a function release relies on multiple services to upgrade and go online at the same time . We hope that the new versions of these services can be verified with small traffic at the same time , This is the unique full link grayscale scenario in the microservice architecture , Gray scale verification of multiple different versions of services is carried out by building environmental isolation from the gateway to the whole back-end services .
Click on the link below , Check out the live tutorial :
In the process of release , We just need to deploy the grayscale version of the service , When the traffic flows on the call link , By the gateway that flows through 、 Each middleware and each micro service to identify gray traffic , And dynamically forward to the gray version of the corresponding service . Here's the picture :
The above figure can well show the effect of this scheme , We use different colors to represent different versions of gray traffic , It can be seen that both the microservice gateway and the microservice itself need to identify traffic , Make dynamic decisions according to governance rules . When the service version changes , The forwarding of this call link will also change in real time . Compared with the gray environment built by machine , This scheme can not only save a lot of machine costs and operation and maintenance manpower , Moreover, it can help developers to carry out fine full link control of online traffic in real time and quickly .
OpenSergo[1] Traffic routing standard
Q:OpenSergo What is it? ?
A:OpenSergo It's a set of openness 、 General purpose 、 Distributed service oriented architecture 、 Service governance standards covering the whole link isomerization ecosystem , Form a general standard for service governance based on the service governance scenarios and practices in the industry .OpenSergo The most important feature of the game is With a unified set of configurations /DSL/ The agreement defines the service governance rules , Multilingual isomerization oriented architecture , Achieve full link ecological coverage . No matter the language of microservices is Java, Go, Node.js Or other languages , Whether it's standard microservices or Mesh Access , From gateway to microservice , From database to cache , From service registration discovery to configuration , Developers can use the same OpenSergo CRD The standard configuration provides unified governance and control for each layer , Instead of focusing on the frameworks 、 Differences in language , Reduce isomerization 、 The complexity of full link service governance and control
Q: Why do you introduce to me before you know the grayscale of the full link OpenSergo? A:OpenSergo Defines a unified YAML Configuration mode to regulate the full link service governance for the distributed architecture , While introducing specifications and Standards , We can understand the implementation of the technical details , At the same time, we can also integrate new components with OpenSergo The standard of .
Traffic routing , As the name suggests, it refers to the traffic with certain attribute characteristics , Route to the specified destination . Traffic routing is an important part of traffic management , Developers can implement various scenarios based on traffic routing Standards , Such as grayscale Publishing 、 Release of canary 、 Disaster tolerant routing 、 Label routing, etc .
Full link grayscale example :
Traffic routing rules (v1alpha1) It is divided into three parts :
- Workload Labeling rules (WorkloadLabelRule): Put a group workload Label it accordingly , This part can be understood as the database load for the application or the corresponding storage layer ( database 、 surface ) Label it accordingly
- Flow label rules (TrafficLabelRule): Traffic with certain attribute characteristics , Label it accordingly
- according to Workload Tag and traffic tag to do matching routing , Route the traffic with the specified label to the matching workload in
Mark the flow :
The traffic with certain attribute characteristics needs to be , Label it accordingly .
Suppose you need to gray the users in Shenzhen to the new homepage , Test user location=cn-shenzhen,cn-shenzhen be located location header in :
apiVersion: traffic.opensergo.io/v1alpha1
kind: TrafficLabelRule
metadata:
name: my-traffic-label-rule
labels:
app: spring-cloud-zuul
spec:
selector:
app: spring-cloud-zuul
trafficLabel: gray
match:
- condition: "==" # Match expression
type: header # Match attribute types
key: 'location' # Parameter name
value: cn-shenzhen # Parameter values
Copy code Through the above configuration ,location header by cn-shenzhen Of HTTP Traffic , In the play gray mark , It means that this traffic is gray traffic .
to Workload tagging :
In the use of Nacos In the business system as service discovery , Generally, the business needs to determine the marking method according to the micro service framework it uses . If Java Applied Spring Cloud Microservice development framework , We can add corresponding environment variables to the business container to complete the tag adding operation . For example, we want to add version gray scale to the node , Then add... To the business container traffic.opensergo.io/label: gray , So the frame goes to Nacos When registering this node, a gray label .
For some complex workload Marking scene ( Such as database instance 、 Cache instance tags ), We can use WorkloadLabelRule CRD To mark . Example :
apiVersion: traffic.opensergo.io/v1alpha1
kind: WorkloadLabelRule
metadata:
name: gray-sts-label-rule
spec:
workloadLabels: ['gray']
selector:
db: mse-demo
table: mse_demo_table_gray
Copy code Common solutions of full link grayscale in database
Scheme 1 : Shadow vault
Each individual maintains a separate set of libraries , Suppose the name of the library of the baseline environment is mse-demo, that gray The traffic of the environment can be mapped to mse-demo-gray Library , We build a shadow database corresponding to the environmental traffic on the same instance , We maintain the connection pool of each library connection in our business , Select the connection of the corresponding shadow library to access according to different traffic indicators , So as to achieve the effect of data isolation from the baseline environment library , Thus, the pollution of the baseline environment database caused by the data generated by the gray-scale environmental flow is avoided .
Option two : Shadow table
Similar to the shadow library scheme , For shadow table scheme , It is to establish the corresponding shadow table on the same database on the same instance . We're executing SQL In the process of , For gray traffic SQL Analyze and modify , Achieve different environmental traffic SQL Access the corresponding tables respectively , Suppose the name of the table of the baseline environment is mse_demo_table, that gray The traffic of the environment can be mapped to mse_demo_table_gray In the table of . So as to achieve the effect of isolation between gray data and baseline environment data table .
MSE[2] Database full link grayscale capability
MSE It provides a scheme of data isolation , You can do this without modifying any business code , Realize the full link grayscale at the database level . Let's introduce MSE be based on Mysql Data storage through the shadow table scheme to achieve the ability of full link gray .
Prerequisite
- Application access MSE
- Deploy Demo application
Deploy in Alibaba cloud container service A、B、C Three applications , Each application is deployed separately ⼀ individual base Version and ⼀ individual gray edition ; And deploy ⼀ individual Nacos Server application , For service discovery . For details, please refer to the tutorial to complete the application deployment : Deploy Demo Applications [3] .
Demo Application Introduction , Ben Demo Medium C The application will execute the following statement to the database :
CREATE TABLE `mse_demo_table` (
`id` int NOT NULL AUTO_INCREMENT,
`location` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3
Copy code The database table building statements involved :
CREATE TABLE `mse_demo_table` (
`id` int NOT NULL AUTO_INCREMENT,
`location` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3
Copy code - Create shadow tables , We Demo The database tables involved are mse_demo_table, Because we need to create grayscale gray Environmental Science , So we need to create... In advance mse_demo_table_gray surface .
CREATE TABLE `mse_demo_table_gray` (
`id` int NOT NULL AUTO_INCREMENT,
`location` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3
;
Copy code First step : Configure full link grayscale rules
You need to complete the configuration MSE Full link release of , Please refer to the tutorial for specific operation details : Configure full link grayscale [4] .
Create the following swimlane rules :
The second step : Configure database full link grayscale
- We need to configure the following environment variables to enable additional / Configure the full link grayscale capability of the database
The third step : The results verify that
We initiate a grayscale request , It is found that all traffic requests access the gray environment :
curl -H "location: cn-shenzhen" http://106.14.XX.XX/a
Agray[172.18.XX.XX] -> Bgray[172.18.XX.XX] -> Cgray[172.18.XX.XX]%
Copy code We have adopted the following SQL Query shadow table :
SELECT * FROM `mse_demo_table_gray`
Copy code The data found in the gray environment is inserted into the shadow table .
Not just full link grayscale
So far, MSE The service governance full link grayscale capability has supported cloud native gateways 、ALB、APISIX、Apache Dubbo、Spring Cloud、RocketMQ And database . At the database level, we realize traffic isolation at the data level by means of shadow tables , In the next step, we will further commercialize this capability , Full link grayscale will also support cache level capabilities .
Service governance is the only way for micro service transformation to go deep into a certain stage , In this process, we continue to have new problems .
- In addition to full link grayscale , Are there other capabilities of service governance ?
- Is there a standard definition of service governance capability , What are the service governance capabilities ?
- In a multilingual setting , Is there a best practice or standard for full link ?
- How can heterogeneous microservices be managed uniformly ?
When we are exploring service governance , When we connect with other micro Services , We find that the problems caused by different governance systems are huge , The cost of getting through two or even more sets of governance systems is also huge . So we put forward OpenSergo project .OpenSergo What we need to solve is different frameworks 、 The concept of microservice governance in different languages is fragmented 、 Unable to communicate with each other .
OpenSergo The community is also uniting various communities for further cooperation , Communities come together to discuss and define unified service governance standards . The current community is also uniting bilibili、 ByteDance and other enterprises jointly build Standards , Also welcome interested developers 、 Communities and businesses join OpenSergo Service governance standards are under construction . Welcome aboard OpenSergo Community communication group ( Nail group ) Have a discussion :34826335
Reference link :
[1] OpenSergo:
[2] MSE Microservice engine :
[3] Deploy Demo Applications :
[4] Configure full link grayscale :
MSE First purchase of professional edition of registration configuration center 9 A discount ,MSE Full specification of cloud native gateway prepaid 9 A discount . Click on here , Enjoy the discount !
边栏推荐
- [Ruiji takeout] day05 package management business development
- Ordinary practice of JS DOM programming
- How to install WiFi correctly
- Jianzhi offer II 062. implement prefix tree (medium design dictionary tree prefix tree string)
- HCIP(8)
- 静态成员static详解
- mysql8.0无法给用户授权或提示You are not allowed to create a user with GRANT的问题
- internet的基本服务中文件传输命令是哪个
- MySQL built-in functions
- HCIP第七次实验
猜你喜欢

Summary of common error types in JS
![[CS231N]Lecture_ 2:Image Classification pipelin](/img/4f/de56b071560ada746c587a9dbc5f02.jpg)
[CS231N]Lecture_ 2:Image Classification pipelin

HCIP(11)

Soft exam network engineer
![[CS231N]Lecture_2:Image Classification pipelin](/img/4f/de56b071560ada746c587a9dbc5f02.jpg)
[CS231N]Lecture_2:Image Classification pipelin

mysql create语句能不能用来建立表结构并追加新的记录

Mysql内置函数

Day3 classification management of Ruiji takeout project

98. Verify binary search tree (medium binary search tree DFS)

Changes in the history of oscilloscope development
随机推荐
HCIP第七次实验
NPM switch Taobao source (NPM source)
Common commands of NPM
Wechat applet uses canvas drawing, round avatar, network background, text, dotted line, straight line
JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
Leetcode integer exercises integer inversion
2022年一级建造师考试什么时候才能报名?
Kali source solution software cannot be installed correctly
删除容器镜像报错解决image is referenced in multiple repositories
Win11 how to open software notification
Closure, prototype and original link
容器化配置启动redis集群 单机6节点 3主3从
HCIP(9)
Ordinary practice of JS DOM programming
lotus 1.16.0 延长扇区过期时间
LCR测试仪最为主要的功能和用途都是什么
gprs网络指的是什么
DOM programming + events
6K6w5LiA5qyh5pS75Ye75YiG5p6Q
Ecmasript 5/6 notes