CN-121792606-B - API-based two-way routing gateway gray level release micro-service method and system
Abstract
The invention relates to the technical field of gray release, in particular to a gateway gray release micro-service method and system based on API (application program interface) double-route, which are characterized by firstly collecting a recent log of a stable system as a sample, adopting a sliding window algorithm to obtain a gray release window alternative list and a traffic migration weight based on the sample, formulating a gray release gateway routing rule, entering a release window, combining dynamic adjustment of a load equalizer traffic weight and an online Http request buffer zone to complete traffic migration between double gateways, dynamically updating the gateway routing rule when the gateway traffic drops to zero, adopting a transition routing rule in a smooth transition stage and starting a rollback event monitoring, immediately rollback to the stable service once the rollback event occurs, and formally releasing the gray routing rule if the rollback event does not occur after the smooth transition stage is ended, wherein the gray release is successful. The gray level publishing method and the gray level publishing device have the advantages that the gray level publishing process is high in automation degree, simple, convenient, safe and reliable, users do not feel in the publishing process, and user experience is improved.
Inventors
- ZHU YUNJIE
Assignees
- 中博信息技术研究院有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260309
Claims (8)
- 1. An API-based two-way routing gateway gray scale distribution micro-service method, comprising: 1) Based on the collected API call log sample data, calculating a gray release window sequence and a flow migration weight; 2) Entering a gray level release window, dynamically adjusting the flow weight to realize the migration of the flow between the gateway A and the gateway B, dynamically updating a gateway routing rule when the flow on the gateway is zero, dynamically updating the gateway A to a gray level transition routing rule AB, updating the gateway B to a stable level transition routing rule AB, and entering a gray level release smooth transition stage; 3) After the smooth transition of gray level release starts, entering a gray level release window according to a window selection strategy, transferring the flow from a stable service to a gray level service by dynamically adjusting the flow weight, starting a rollback event monitoring, and entering a gray level release rollback stage if the rollback event is monitored; 4) The gray level release smooth transition period is ended, no rollback event is monitored, and a gray level release formal stage is entered; In the gray level release rollback stage, the gray level release window is not entered, the dynamic flow migration is immediately carried out, the flow on the gateway A is completely transferred to the gateway B, the client requests to be completely routed to the stable service, and meanwhile, the routing rule of the gateway A is dynamically updated to the stable version; selecting and waiting to enter a gray level release window according to a time priority strategy, and after dynamic flow migration again, completely migrating the gateway B flow to the gateway A, dynamically updating the gateway B routing rule to a stable version, and finally carrying out dynamic flow migration to realize flow balance on the gateway A and the gateway B; calculating traffic migration weights, comprising: Acquiring the maximum throughput Qps_max, and if Qps_max is larger than the traffic migration weight, then the traffic migration weight=Qps_max; in all window calculation units for acquiring success rate succ _rate=1, gateway a maximum throughput Qpsa _max, if Qpsa _max is greater than gateway a window maximum safe throughput, gateway a window maximum safe throughput= Qpsa _max; In all window calculation units for acquiring success rate succ _rate=1, gateway B maximum throughput Qpsb _max, if Qpsb _max is greater than gateway B window maximum safe throughput, gateway B window maximum safe throughput= Qpsb _max; Traversing a gray level release window sequence, and setting a window with total throughput Qps not larger than the maximum safety throughput of the gateway A and the gateway B as a safety release window; Traffic migration weight = traffic migration weight + integer such that the traffic migration weight is the smallest integer that is an even multiple of gray release smoothness.
- 2. The API-based two-way routing gateway gray scale distribution microservice method of claim 1, wherein calculating a sequence of gray scale distribution windows comprises: Inquiring API call log sample data, obtaining a response state code meeting the Http of 200 and a URI of a service A or B, obtaining a response time length maximum value Tresp_max_ms by rounding, and taking a minimum integer meeting the condition that the minimum integer is greater than or equal to Tresp_max_s and can be divided by 24 x 3600 as a release window width Twindow; Defining a release window calculation unit, namely, a start time start_time, a stop time end_time and an average response time rt, wherein the total throughput Qps=gateway A throughput Qpsa +gateway B throughput Qpsb, the reject throughput Qps_block=gateway A reject throughput Qpsa _block+gateway B reject throughput Qpsb _block through throughput Qpsb _pass through throughput Qpsz _pass=gateway A throughput abnormal throughput Qpsb _ exception, the successful throughput Qps_ succ =gateway A successful throughput Qpsa _ succ +gateway B successful throughput Qpsb _ succ, the abnormal throughput Qps_ exception =gateway A abnormal throughput Qpsa _ exception +gateway B abnormal throughput Qpsb _ exception, and the success rate succ _rate=Qps_ succ/Qps; Defining a release window unit, namely starting time, ending time, average response time and whether to release a window safely; based on API call log sample data, positioning a window according to a sliding step length and a release window width from a zero point, calculating each throughput in a unit time period by using a statistics window, and further calculating the success rate and the average response time length; And adding the window computing unit with the highest success rate into the gray level release window sequence every time priority factor time_priority_factor window computing unit is completed.
- 3. The method for distributing micro services based on the gray scale of the API dual-routing gateway as recited in claim 2, wherein the window selection strategy comprises time priority and security priority; traversing a gray level release window sequence, and selecting a window with the starting time larger than the current time and the average response time length of the window plus the window with the smallest distance from the current time; And (3) a security priority strategy, namely traversing the gray release window sequence, and selecting a window with the minimum distance from the current time and marked as security release, wherein the window starting time is larger than the current time.
- 4. The API-based dual-routing gateway gray scale distribution micro-service method as claimed in claim 3, wherein after the dynamic traffic migration, the gateway B traffic is completely migrated to the gateway a, comprising: Editing a load equalizer configuration file, setting the weight of a gateway A as a traffic migration weight, setting the weight of a gateway B as 1, and then dynamically loading the file; The API gateway defines an online Http request global filter, monitors a Redis online Http request buffer, stores a new Http request into the online Http request buffer when the new Http request reaches the API gateway, deletes the online Http request from the online Http request buffer when the Http response returns, and completes the whole migration of the traffic from the gateway B to the gateway A when the online Http request buffer is empty.
- 5. The API-based two-way routing gateway gray scale distribution micro-service method as claimed in claim 4, wherein said gateway routing rules are divided into: The method is applicable to the stable version routing rule A and the gray version routing rule A of the gateway A, the stable version routing rule B and the gray version routing rule B of the gateway B, and the transition routing rules of the gateway A and the gateway B, including the stable version transition routing rule AB and the gray version transition routing rule AB; And the gateway routing rule is loaded to the Redis cache area before the gray level release service is started.
- 6. The method for dynamically updating gateway routing rules according to claim 5, wherein the method comprises the steps of storing the routing rules in a database routing rule table after configuration of the routing rules, wherein the main fields comprise a gateway name, a service ID, a URI, an assertion, a filter, a version number and a version state, sending an update routing rule message to an API gateway through a message mechanism according to the gray level release stage, and dynamically updating the routing rules to an API gateway memory according to the routing rule version number and the routing rule type in the message.
- 7. The method for gateway gray scale distribution micro-service based on API dual-route of claim 6, wherein the step of entering a gray scale distribution smooth transition stage and smoothly transiting the stable service to the gray scale service according to the gray scale distribution smoothness parameter comprises the steps of setting a current flow weight of gateway A to be an initial value of 1 and a current flow weight of gateway B to be a flow migration weight when entering the gray scale distribution smooth transition stage, dynamically updating the flow weights of gateway A and gateway B on a load balancing component every time a gray scale distribution smooth transition period passes, wherein the current flow weight of gateway B=gateway B current flow weight-gray scale distribution smoothness, the current flow weight of gateway A=flow migration weight-gateway B current flow weight, and setting the current flow weight of gateway B=1 and the current flow weight of gateway A=flow migration weight when the current flow weight of gateway B=0.
- 8. The system adopting the gateway gray release micro-service method based on the API dual-route according to claim 1 is characterized by comprising a gateway A, a gateway B, a load equalizer, a memory buffer area Redis, a micro-service monitoring component, a gray release configuration management module and a gray release module, wherein the gateway A and the gateway B are both API gateways; the flow migration between the gateway A and the gateway B is realized by dynamically adjusting the flow weight of the load equalizer; The micro-service monitoring component is used for carrying out flow control, service degradation and hot spot rule configuration on the API gateway and storing the configuration rules and monitoring data generated during operation into a database in a lasting manner; the memory buffer area Redis is used for dynamically updating the route of the gateway, the gray release configuration buffer area is used for a gray release module, the on-line request monitoring buffer area is used for flow migration, and the log buffer area is used for rollback event monitoring and batch warehousing; the gray level release configuration management module is used for configuring the routing rule and the operating parameters of the gray level release module; And the gray level release module is used for completing four stages of gray level release together based on Redis cache and through cooperation of a message mechanism and the rest modules, namely a release preparation stage, a smooth transition stage, a release rollback stage and a formal release stage.
Description
API-based two-way routing gateway gray level release micro-service method and system Technical Field The invention relates to the technical field of gray level release, in particular to a gateway gray level release micro-service method and system based on API (application program interface) dual-route. Background In the architecture of a micro service system, a redundant hot backup technology is generally adopted to deploy system services for critical basic services with huge traffic, in view of the requirements of high availability and stability. Version upgrade of system service is an essential important link for system maintenance work, in this system architecture, gray level release usually introduces an intermediate API gateway, and after finishing route rule upgrade on it, the API gateway in the existing stable system is replaced by modifying reverse proxy and traffic weight in the nginnx configuration. However, this technique has the following risks in the gray scale distribution process: (1) The traffic migration is carried out in the service peak period, all loads are applied to the main service or the standby service during the service peak period, the service capacity of the system is reduced by half, and the risk that the user requests respond slowly and even go down due to overload exists in the system; (2) In the gray level release process, the risk of abnormal interruption of an online Http request is caused by dynamically updating the reverse proxy API gateway IP or port and the API gateway routing rule in the Nginx configuration; (3) Configuration files such as properties, yaml are manually written, the routing rules of the API gateway are configured, errors are easy to occur, and the restarting of the API gateway is long in time and low in efficiency; (4) There is a waste of resources and the intermediate API gateway is only used when the grey scale is published. Disclosure of Invention Aiming at the above requirements and the defects existing in the technology, the invention provides a gray release micro-service method and a system based on an API dual-route gateway, which do not need to introduce an intermediate API gateway or restart the API gateway, provide a gray release window calculation method, tightly combine window parameters with flow migration parameters, adopt a dynamic flow migration and dynamic gateway routing rule updating technology to avoid abnormal interruption, and further reduce gray release risks through rollback event monitoring. In order to achieve the aim of the invention, the technical scheme adopted is that the gateway gray level release micro-service method based on API double-route comprises the following steps: 1) Based on the collected API call log sample data, calculating a gray release window sequence and a flow migration weight; 2) Entering a gray level release window, dynamically adjusting the flow weight to realize the migration of the flow between the gateway A and the gateway B, dynamically updating a gateway routing rule when the flow on the gateway is zero, dynamically updating the gateway A to a gray level transition routing rule AB, updating the gateway B to a stable level transition routing rule AB, and entering a gray level release smooth transition stage; 3) After the smooth transition of gray level release starts, entering a gray level release window according to a window selection strategy, transferring the flow from a stable service to a gray level service by dynamically adjusting the flow weight, starting a rollback event monitoring, and entering a gray level release rollback stage if the rollback event is monitored; 4) And (3) ending the gray level release smooth transition period, and entering a gray level release formal stage without monitoring a rollback event. In the gray level release rollback stage, dynamic flow migration is immediately carried out, all flows on a gateway A are transferred to a gateway B, all the flows are requested to be routed to stable service by a client, meanwhile, the routing rules of the gateway A are dynamically updated to the stable version, the gateway B is dynamically updated to the stable version after the dynamic flow migration again after being selected and waiting to enter the gray level release window according to a time priority strategy, finally, the dynamic flow migration is carried out, flow balance is realized on the gateway A and the gateway B, the routing rule configuration of the gateway is updated, the rollback event log is recorded, and the gray level release failure is recorded. As an optimization scheme of the present invention, calculating a gray scale release window sequence includes: Inquiring API call log sample data, obtaining a response state code meeting the Http of 200 and a URI of a service A or B, obtaining a response time length maximum value Tresp_max_ms by rounding, and taking a minimum integer meeting the condition that the minimum integer is greater than or equal to Tresp_max