WO2021051541A1 - Method and apparatus for achieving simultaneous gray release based on microservice framework, and computer device - Google Patents

Method and apparatus for achieving simultaneous gray release based on microservice framework, and computer device Download PDF

Info

Publication number
WO2021051541A1
WO2021051541A1 PCT/CN2019/117216 CN2019117216W WO2021051541A1 WO 2021051541 A1 WO2021051541 A1 WO 2021051541A1 CN 2019117216 W CN2019117216 W CN 2019117216W WO 2021051541 A1 WO2021051541 A1 WO 2021051541A1
Authority
WO
WIPO (PCT)
Prior art keywords
gray
microservice
scale
strategy
preset
Prior art date
Application number
PCT/CN2019/117216
Other languages
French (fr)
Chinese (zh)
Inventor
伍春林
杨定朝
童志刚
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021051541A1 publication Critical patent/WO2021051541A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Definitions

  • This application relates to the computer field, in particular to a grayscale method, device, computer equipment and storage medium based on a microservice framework.
  • Gray release refers to a release method in which there are different service versions within the same time period, and a smooth transition between the original version and the new version.
  • the main problems with gray-scale publishing are as follows: Generally, single-architecture services are used for gray-scale publishing. When gray-scale publishing requires multiple service instances, the cost is high and the efficiency is low; only a single service is supported for gray-scale publishing. Realize the gray release of multiple related services together; the service party must not only set the version of the service, but also set the gray release strategy. The process of setting the gray release is cumbersome and time-consuming. Therefore, the traditional gray-scale release technical solution is in urgent need of improvement.
  • the main purpose of this application is to provide a grayscale method, device, computer equipment and storage medium based on a microservice framework, aiming to improve the efficiency of grayscale publishing.
  • this application proposes a gray-scale method based on a microservice framework, which includes the following steps:
  • a call request directed to a target microservice where the call request is generated by the current microservice of the user terminal, the current microservice and the target microservice do not belong to the same microservice cluster, and the current microservice refers to the current microservice A microservice that maintains a communication connection with the user terminal;
  • the gray-scale strategy provides a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing;
  • the call request is diverted to the gray-scale service instance of the target microservice, and a signal connection channel is established, wherein one end of the signal connection channel is connected to the The other end of the user terminal is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
  • the grayscale method, device, computer equipment, and storage medium of this application based on the microservice framework receive a call request pointing to the target microservice; parse the call request to obtain the specified data; obtain the grayscale policy provided by the terminal Degree strategy; if the specified data does not fall within the preset range of the integrated gray-scale strategy, determine whether the current microservice belongs to the integrated gray-scale strategy; if the current microservice does not belong to the If the target microservice belongs to the gray-level strategy together, it is judged whether the target microservice belongs to the gray-level strategy together; if the target microservice belongs to the gray-level strategy together, the call request is diverted to the gray-level strategy of the target microservice.
  • FIG. 1 is a schematic flowchart of a grayscale method based on a microservice framework according to an embodiment of the application
  • FIG. 2 is a schematic block diagram of the structure of a grayscale device based on a microservice framework according to an embodiment of the application;
  • FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
  • an embodiment of the present application provides a grayscale method based on a microservice framework, including the following steps:
  • the call request is diverted to the gray-scale service instance of the target microservice, and a signal connection channel is established, wherein one end of the signal connection channel is connected to The other end of the user terminal is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
  • step S1 receiving a call request pointing to a target microservice, wherein the call request is generated by the current microservice of the user terminal, and the current microservice and the target microservice do not belong to the same microservice cluster
  • the current microservice refers to a microservice that currently maintains a communication connection with the user terminal.
  • the call request is generated by the current microservice of the user terminal, it means that the call request is triggered by the user terminal when the current microservice is used, and is generated by the current microservice to point to the target microservice . That is, the target microservice has an association relationship with the current microservice, and belongs to a combination of microservices that can be published together in grayscale.
  • the call request is parsed to obtain designated data, and the designated data includes the ip address, request header, or request parameter of the user terminal.
  • the request includes information such as the ip address, request header, or request parameters of the user terminal, so the specified data is obtained by parsing the request.
  • the format is, for example, a request line, a request header, a blank line, and the request content. Therefore, by calling the format of the passed protocol, the calling request is parsed to obtain the specified data.
  • the specified data is, for example, a character string in a predetermined position in the request header.
  • the specified data is used as a basis for subsequent grayscale release and distribution, that is, it is used to determine how the user terminal should distribute.
  • the request parameter refers to the parameter in the request, and the value of the request parameter may be used as a basis for dividing the user terminal, so as to determine which version of the service the user terminal should be diverted to.
  • obtaining a gray-scale strategy provides a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing.
  • the gray-level strategy is for example: judging whether the ip address of the user terminal falls within the preset address range, and if it falls within the preset address range, the user terminal is identified as a gray-level strategy user.
  • the user terminal should implement a gray-scale strategy to release at least two microservice clusters in gray-scale.
  • the gray-scale strategy adopted in this application comes from the gray-scale strategy provider terminal, so that the gray-scale strategy setting is separated from the gray-scale version mark. When the service provider performs the gray-scale release, only the version of the microservice is required. Just mark it, which overcomes the cumbersome and time-consuming defects of the traditional scheme setting gray-scale release process.
  • the specific judgment method is, for example, calculating the similarity value between the designated data and the preset character string according to a preset similarity algorithm, and judging whether the similarity value is less than a preset similarity threshold; If the similarity value is not less than the preset similarity threshold, then obtain the first key corresponding to the first version gray user, the second version gray user,..., the nth version gray user agreed in the one gray policy Word, second keyword,..., nth keyword, wherein the one grayscale strategy pre-appoints n versions of grayscale users; it is determined whether the specified data records the first keyword, second keyword, ...Or the nth keyword; if the designated data records the first keyword, the second keyword, ...
  • the designated data falls within the preset range of the same gray scale strategy And mark the user terminal as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
  • the gray release of multi-service and multi-version it is possible to further carry out the gray release of multi-service and multi-version.
  • the preset gray-scale strategy judgment method is used to determine whether the current microservice belongs to the common gray-scale strategy.
  • Grayscale strategy The preset gray-scale strategy judgment method is, for example: if the specified data does not fall within the preset range of the gray-scale strategy, obtain the version number of the current microservice; obtain the gray-scale The version number of the microservice in the policy; determine whether the version number of the current microservice is the same as the version number of the microservice in the integrated grayscale policy; if the version number of the current microservice is the same as the integrated grayscale If the version numbers of the microservices in the policies are the same, it is determined that the current microservices belong to the same gray-scale policy.
  • step S6 if the current microservice does not belong to the gray-level integration strategy, it is determined whether the target microservice belongs to the gray-level integration strategy.
  • the method used to determine whether the target microservice belongs to the gray-scale strategy can use the aforementioned gray-scale strategy judgment method, or any other method, such as judging the list of microservices recorded in the gray-scale strategy. Whether the microservice name of the target microservice is included in the.
  • step S7 if the target microservice belongs to the grayscale policy, then the call request is diverted to the grayscale service instance of the target microservice, and a signal connection channel is established, wherein the signal One end of the connection channel is connected to the user terminal, and the other end is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
  • the target microservice belongs to the gray-level strategy, it indicates that the target microservice and the microservice cluster in which the target microservice is located should perform a gray-scale operation, so the call request is diverted to all The gray-scale service instance of the target microservice, and the gray-scale publication of the microservice cluster where the target microservice is located, that is, a signal connection channel is established, wherein one end of the signal connection channel is connected to the user terminal, and the other end Connect to the gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service. Furthermore, it also includes: constructing a connection channel to enable the microservice cluster where the current microservice is located to perform grayscale publishing. In this way, multiple services (multiple microservice clusters, for example, including the microservice cluster specified in the same grayscale policy) can be published together in grayscale.
  • the designated data is a character string recorded in a pre-appointed position in the request header
  • the gray scale strategy defines a plurality of preset ranges
  • the determination of whether the designated data falls into the gray scale Step S4 within the preset range of the degree strategy includes:
  • S401 Calculate the similarity value between the designated data and the preset character string according to a preset similarity algorithm, and determine whether the similarity value is less than a preset similarity threshold;
  • S404 Determine whether the designated data records a first keyword, a second keyword, ... or an nth keyword;
  • the specified data records the first keyword, the second keyword, ... or the nth keyword, determine that the specified data falls within the preset range of the one gray scale strategy, and set all The user terminal is recorded as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
  • the preset similarity algorithm can be any algorithm, as long as the similarity value between the specified data and the preset character string can be calculated, such as a distance formula based on the law of cosine, a similarity algorithm based on a word frequency vector, and the like. If the similarity value is not less than the preset similarity threshold, it means that the corresponding designated data is similar to the preset character string, and therefore the corresponding user terminal is a gray-scale user.
  • this application uses multiple versions of grayscale, so it is also necessary to determine which version of the grayscale user the user terminal is. Therefore, this application determines whether the designated data contains the first keyword, the second keyword, ...
  • the designated data is a character string recorded in a predetermined position in the request header, for example, a character string recorded before two special symbols (such as ?) in the request header.
  • the step S401 of calculating a similarity value between the designated data and a preset character string according to a preset similarity algorithm, and determining whether the similarity value is less than a preset similarity threshold includes :
  • S4013 Determine whether the similarity value is less than the specified similarity threshold.
  • the similarity value between the designated data and the preset character string is calculated according to the preset similarity algorithm, and it is determined whether the similarity value is less than the preset similarity threshold.
  • the similarity algorithm is calculated according to the cosine similarity between the designated data and the preset character string, so as to reflect the degree of similarity between the designated data and the preset character string. When the value of similarity is closer to 1, the more similar it is; the closer to 0, the more dissimilar it is.
  • the step S4 of judging whether the specified data falls within the preset range of the one gray scale strategy includes:
  • S412 Acquire a designated parameter matrix [C1, C2, C3] corresponding to the one gray-scale strategy according to the preset corresponding relationship between the gray-scale strategy and the parameter matrix;
  • the encoding method is a method of sequentially mapping the ip address, request header, and request parameters of the user terminal to specific values, and then combining them to obtain a matrix. Therefore, this application can simultaneously integrate the ip address, request header, and request parameters of the user terminal to perform high-dimensional and accurate gray-scale release, and the division is faster and more accurate.
  • the method includes:
  • S42 Establish a communication channel.
  • One end of the communication channel is connected to the user terminal, and the other end is connected to gray-scale service instances of other micro-services in the integrated gray-scale strategy except for the target micro-service.
  • the implementation of a gray-scale strategy is achieved. If the specified data falls within the preset range of the gray-level strategy, it indicates that the user terminal needs to implement the gray-scale strategy together (and the target microservice is also in the gray-scale strategy together), and the target Microservices should also be published in grayscale. Accordingly, the call request is diverted to the gray-scale service instance of the target microservice, so as to realize the gray-scale release of the target microservice. And a communication channel is established. One end of the communication channel is connected to the user terminal, and the other end is connected to the gray-scale service instances of other micro-services in the gray-scale policy together except for the target micro-service, so as to realize the integration Grayscale release. Further, it also includes: establishing a communication channel to enable the microservice cluster where the current microservice is located to perform grayscale publishing (this is because the current microservice and the target microservice have an association relationship and can be grayscale published together).
  • the microservice has a version number, and if the specified data does not fall within the preset range of the gray-level strategy, the current gray-scale strategy determination method is used to determine the current Whether the microservice belongs to the step S5 of the gray-scale strategy includes:
  • S503 Determine whether the version number of the current microservice is the same as the version number of the microservice in the one-level strategy
  • This application adopts the microservice architecture, and the microservices have the form of version numbers, so that it is possible to publish multiple services and multiple versions at the same time grayscale release, and use the characteristics of microservices to reduce the grayscale release of multiple services and multiple versions at the same time cost. If the specified data does not fall within the preset range of the gray-scale strategy, it indicates that the request itself does not bring a gray-scale signal. Therefore, by judging whether the version number of the current microservice is the same as the version number of the microservice in the integration strategy, to determine whether the current microservice belongs to the integration strategy, and to further determine the current microservice Which version of the grayscale release of the service belongs to the one grayscale strategy.
  • the method includes:
  • the re-classification using the gray-level re-classification model is realized to further ensure the accuracy of gray-level publishing.
  • this application uses the already-trained gray-scale reclassification model based on the machine learning model to re-classify the user terminal, avoiding the inaccuracy of manually setting the gray-scale publishing, and thus can more accurately Perform gray-scale release, and then make the data information obtained by gray-scale release feedback more effective, and improve the success rate of gray-scale release.
  • the machine learning model may be any model, for example, a CHAID decision tree model.
  • the CHAID decision tree model refers to a decision tree model that uses the chi-square automatic interactive detection method CHAID.
  • the CHAID decision tree 1. Combine the group values that have no significant difference in the impact of the decision variables in the group; 2. Select the variable with the largest chi-square value as the tree classification variable; 3. Repeat the steps 1 and 2 until it fails Choose that the chi-square value is greater than a certain value or the P value is no longer less than a certain critical value, or the sample is less than a certain number.
  • the modeling standard parameters of the decision tree are for example: the maximum number of layers of the decision tree is 4-5, the significance level of the parent node can be subdivided is 0.05, the minimum number of samples contained in the parent node is 150, and the minimum sample contained in the child nodes The number is 50.
  • an embodiment of the present application provides a grayscale device based on a microservice framework, including:
  • the call request receiving unit 10 is configured to receive a call request directed to a target microservice, wherein the call request is generated by the current microservice of the user terminal, and the current microservice and the target microservice do not belong to the same microservice cluster ,
  • the current microservice refers to a microservice that currently maintains a communication connection with the user terminal;
  • the designated data obtaining unit 20 is configured to parse the call request to obtain designated data, and the designated data includes the ip address, request header, or request parameter of the user terminal;
  • a gray-level strategy obtaining unit 30 is configured to obtain a gray-scale strategy provided by the terminal to provide a gray-scale strategy together, where the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform grayscale publishing;
  • the preset range determining unit 40 is configured to determine whether the specified data falls within the preset range of the one gray scale strategy
  • the gray-scale strategy judging unit 50 is configured to determine whether the current microservice belongs to all the micro-services through a preset gray-scale strategy judgment method if the specified data does not fall within the preset range of the gray-scale strategy. Describe a gray-scale strategy
  • the target microservice determining unit 60 is configured to determine whether the target microservice belongs to the grayscale policy if the current microservice does not belong to the grayscale policy;
  • the signal connection channel establishment unit 70 is configured to, if the target microservice belongs to the gray-scale policy, then divert the call request to the gray-scale service instance of the target microservice, and establish a signal connection channel, wherein One end of the signal connection channel is connected to the user terminal, and the other end is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
  • the specified data is a character string recorded in a pre-appointed position in the request header
  • the one gray scale strategy defines a plurality of preset ranges
  • the preset range determining unit 40 includes:
  • the similarity calculation subunit is configured to calculate the similarity value between the designated data and the preset character string according to a preset similarity algorithm, and determine whether the similarity value is less than a preset similarity threshold;
  • the keyword acquisition subunit is used to acquire the first version grayscale user, the second version grayscale user,..., the first version specified in the one grayscale strategy if the similarity value is not less than the preset similarity threshold value.
  • the keyword judgment subunit is used to judge whether the specified data records the first keyword, the second keyword, ... or the nth keyword;
  • the gray scale mark division subunit is used to determine that the specified data falls into the pre-defined gray scale strategy if the specified data contains the first keyword, the second keyword, ... or the nth keyword. Set within the range, and record the user terminal as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
  • the similarity calculation subunit includes:
  • a designated similarity threshold acquisition module configured to acquire a designated similarity threshold corresponding to the preset character string according to the corresponding relationship between the character string and the similarity threshold;
  • the designated similarity threshold judgment module is used to judge whether the similarity value is less than the designated similarity threshold.
  • the preset range determining unit 40 includes:
  • the encoding subunit is used to encode the ip address, request header, and request parameters of the user terminal into a matrix [B1, B2, B3] according to a preset encoding method, where B1 is the mapping value corresponding to the ip address, B2 is the mapping value corresponding to the request header, and B3 is the mapping value corresponding to the request parameter;
  • the designated parameter matrix acquiring subunit is used to acquire the designated parameter matrix [C1, C2, C3] corresponding to the one gray strategy according to the corresponding relationship between the preset gray strategy and the parameter matrix;
  • the user terminal divides sub-units for determining that the specified data falls within the preset range of the same gray scale strategy if the reference index M falls within a plurality of preset numerical ranges, and sets all
  • the user terminal is divided into Am, where Am refers to an m-th version of gray-scale user, and the m-th version of gray-scale user corresponds to the numerical range in which the reference index M falls.
  • the device includes:
  • a call request shunting unit configured to shunt the call request to the gray service instance of the target microservice if the specified data falls within the preset range of the gray-level strategy
  • the communication channel establishment unit is configured to establish a communication channel, one end of the communication channel is connected to the user terminal, and the other end is connected to the gray level of other microservices in the same gray level strategy except the target microservice Service instance.
  • the microservice has a version number
  • the gray-scale strategy judgment unit 50 includes:
  • the current microservice version number obtaining subunit is configured to obtain the version number of the current microservice if the specified data does not fall within the preset range of the gray-scale strategy;
  • the gray-scale strategy version number obtaining subunit is used to obtain the version number of the microservice in the gray-scale strategy
  • the version number judging subunit is used to judge whether the version number of the current microservice is the same as the version number of the microservice in the same gray-scale strategy;
  • a gray-scale policy determination subunit is configured to determine that the current micro-service belongs to the gray-scale policy if the version number of the current microservice is the same as the version number of the micro-service in the gray-scale policy.
  • the device includes:
  • the output result obtaining unit is configured to, if the target microservice does not belong to the gray-level strategy, input the user terminal into the already-trained gray-level reclassification model based on the machine learning model for calculation, thereby obtaining the The output result of the gray-scale reclassification model, where the output result includes gray-scale users and non-gray-scale users;
  • a gray-scale service instance offloading unit configured to offload the call request to the gray-scale service instance of the target microservice if the output result is a gray-scale user
  • the non-gray-scale service instance distribution unit is configured to distribute the call request to the non-gray-scale service instance of the target microservice if the output result is a non-gray-scale user.
  • an embodiment of the present application also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in the figure.
  • the computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor designed by the computer is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, a computer program, and a database.
  • the memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer equipment is used to store the data used in the grayscale method based on the microservice framework.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer program is executed by the processor to realize a gray-scale method based on the microservice framework.
  • the above-mentioned processor executes the above-mentioned grayscale method based on the microservice framework, wherein the steps included in the method respectively correspond to the steps of executing the grayscale method based on the microservice framework of the foregoing embodiment one-to-one, and will not be repeated here.
  • An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored.
  • a grayscale method based on a microservice framework is implemented, wherein the steps included in the method are respectively the same as those in the execution.
  • the steps of the gray-scale method based on the microservice framework in the foregoing embodiment correspond one-to-one, and will not be repeated here.
  • the computer-readable storage medium is, for example, a non-volatile computer-readable storage medium, or a volatile computer-readable storage medium.

Abstract

A method and apparatus for achieving simultaneous gray release based on a microservice framework, a computer device, and a storage medium. The method comprises: receiving an invocation request directing to a target microservice; parsing the invocation request to obtain specified data; obtaining a simultaneous gray release strategy provided by a gray release strategy providing terminal; if the specified data does not fall within a preset range of the simultaneous gray release strategy, determining whether the current microservice belongs to the simultaneous gray release strategy; if the current microservice does not belong to the simultaneous gray release strategy, determining whether the target microservice belongs to the simultaneous gray release strategy; and if the target microservice belongs to the simultaneous gray release strategy, shunting the invocation request to a grayscale service instance of the target microservice, and establishing a signaling channel. Therefore, simultaneous gray release is achieved, and gray release efficiency is improved.

Description

基于微服务框架的一起灰度方法、装置和计算机设备Gray scale method, device and computer equipment based on microservice framework
本申请要求于2019年9月18日提交中国专利局、申请号为201910882733.5,发明名称为“基于微服务框架的一起灰度方法、装置和计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on September 18, 2019, the application number is 201910882733.5, and the invention title is "A gray-scale method, device and computer equipment based on a microservice framework", and its entire content Incorporated in this application by reference.
技术领域Technical field
本申请涉及到计算机领域,特别是涉及到一种基于微服务框架的一起灰度方法、装置、计算机设备和存储介质。This application relates to the computer field, in particular to a grayscale method, device, computer equipment and storage medium based on a microservice framework.
背景技术Background technique
灰度发布是指在同一个时间段内,存在不同的服务版本,在原始版本与新的版本间平滑过渡的一种发布方式。目前采用灰度发布主要存在下述问题:一般采用单体式架构的服务进行灰度发布,灰度发布时需要成倍增加服务实例,成本大效率低;仅支持单个服务进行灰度发布,无法实现多个关联服务一起灰度发布;服务方不仅必须设置服务的版本,还必须设置灰度发布策略,设置灰度发布的流程繁琐,耗时长等。因此传统的灰度发布的技术方案急需改善。Gray release refers to a release method in which there are different service versions within the same time period, and a smooth transition between the original version and the new version. At present, the main problems with gray-scale publishing are as follows: Generally, single-architecture services are used for gray-scale publishing. When gray-scale publishing requires multiple service instances, the cost is high and the efficiency is low; only a single service is supported for gray-scale publishing. Realize the gray release of multiple related services together; the service party must not only set the version of the service, but also set the gray release strategy. The process of setting the gray release is cumbersome and time-consuming. Therefore, the traditional gray-scale release technical solution is in urgent need of improvement.
技术问题technical problem
本申请的主要目的为提供一种基于微服务框架的一起灰度方法、装置、计算机设备和存储介质,旨在提高灰度发布的效率。The main purpose of this application is to provide a grayscale method, device, computer equipment and storage medium based on a microservice framework, aiming to improve the efficiency of grayscale publishing.
技术解决方案Technical solutions
为了实现上述发明目的,本申请提出一种基于微服务框架的一起灰度方法,包括以下步骤:In order to achieve the above-mentioned purpose of the invention, this application proposes a gray-scale method based on a microservice framework, which includes the following steps:
接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务;Receive a call request directed to a target microservice, where the call request is generated by the current microservice of the user terminal, the current microservice and the target microservice do not belong to the same microservice cluster, and the current microservice refers to the current microservice A microservice that maintains a communication connection with the user terminal;
解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip地址、请求头或者请求参数;Parsing the call request to obtain designated data, where the designated data includes the ip address, request header, or request parameter of the user terminal;
获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略;Obtaining the gray-scale strategy provides a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing;
判断所述指定数据是否落入所述一起灰度策略的预设范围之内;Judging whether the specified data falls within the preset range of the one gray scale strategy;
若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略;If the specified data does not fall within the preset range of the integrated gray-scale strategy, use a preset gray-level strategy judgment method to determine whether the current microservice belongs to the integrated gray-scale strategy;
若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;If the current microservice does not belong to the gray-scale integration strategy, determining whether the target microservice belongs to the gray-scale integration strategy;
若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。If the target microservice belongs to the gray-scale policy, then the call request is diverted to the gray-scale service instance of the target microservice, and a signal connection channel is established, wherein one end of the signal connection channel is connected to the The other end of the user terminal is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
有益效果Beneficial effect
本申请的基于微服务框架的一起灰度方法、装置、计算机设备和存储介质,接收指向目标微服务的调用请求;解析所述调用请求从而得到指定数据;获取灰度策略提供终端提供的一起灰度策略;若所述指定数据未落入所述一起灰度策略的预设范围之内,则判断所述当前微服务是否属于所述一起灰度策略;若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。从而实现一起灰度发布,提高灰度发布的效率。The grayscale method, device, computer equipment, and storage medium of this application based on the microservice framework receive a call request pointing to the target microservice; parse the call request to obtain the specified data; obtain the grayscale policy provided by the terminal Degree strategy; if the specified data does not fall within the preset range of the integrated gray-scale strategy, determine whether the current microservice belongs to the integrated gray-scale strategy; if the current microservice does not belong to the If the target microservice belongs to the gray-level strategy together, it is judged whether the target microservice belongs to the gray-level strategy together; if the target microservice belongs to the gray-level strategy together, the call request is diverted to the gray-level strategy of the target microservice. Service instance, and establish a signal connection channel, wherein one end of the signal connection channel is connected to the user terminal, and the other end is connected to the gray level of other microservices in the same gray level strategy except the target microservice. Degree service instance. So as to realize the gray-scale release together and improve the efficiency of gray-scale release.
附图说明Description of the drawings
图1为本申请一实施例的基于微服务框架的一起灰度方法的流程示意图;FIG. 1 is a schematic flowchart of a grayscale method based on a microservice framework according to an embodiment of the application;
图2为本申请一实施例的基于微服务框架的一起灰度装置的结构示意框图;2 is a schematic block diagram of the structure of a grayscale device based on a microservice framework according to an embodiment of the application;
图3为本申请一实施例的计算机设备的结构示意框图。FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics, and advantages of the purpose of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
本申请的最佳实施方式The best implementation of this application
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions, and advantages of this application clearer, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, and are not used to limit the present application.
参照图1,本申请实施例提供一种基于微服务框架的一起灰度方法,包括以下步骤:1, an embodiment of the present application provides a grayscale method based on a microservice framework, including the following steps:
S1、接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务;S1. Receive a call request pointing to a target microservice, where the call request is generated by the current microservice of the user terminal, and the current microservice and the target microservice do not belong to the same microservice cluster, and the current microservice Refers to the microservice that currently maintains a communication connection with the user terminal;
S2、解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip地址、请求头或者请求参数;S2. Parse the call request to obtain designated data, where the designated data includes the ip address, request header, or request parameter of the user terminal;
S3、获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略;S3. Obtain a gray-scale strategy. Provide a gray-scale strategy provided by the terminal, where the gray-scale strategy is a strategy for instructing at least two microservice clusters to perform gray-scale publishing;
S4、判断所述指定数据是否落入所述一起灰度策略的预设范围之内;S4. Determine whether the specified data falls within the preset range of the one gray scale strategy;
S5、若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略;S5. If the specified data does not fall within the preset range of the integrated gray-scale strategy, determine whether the current microservice belongs to the integrated gray-scale strategy through a preset gray-scale strategy judgment method;
S6、若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;S6. If the current microservice does not belong to the gray-level strategy, determine whether the target microservice belongs to the gray-scale strategy;
S7、若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一 起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。S7. If the target microservice belongs to the gray-scale strategy, the call request is diverted to the gray-scale service instance of the target microservice, and a signal connection channel is established, wherein one end of the signal connection channel is connected to The other end of the user terminal is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
如上述步骤S1所述,接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务。其中所述调用请求通过所述用户终端的当前微服务生成,是指所述调用请求是由所述用户终端在使用当前微服务时引发的,由所述当前微服务生成而指向目标微服务的。即所述目标微服务与当前微服务存在关联关系,属于可以一起进行灰度发布的微服务组合。As described in step S1 above, receiving a call request pointing to a target microservice, wherein the call request is generated by the current microservice of the user terminal, and the current microservice and the target microservice do not belong to the same microservice cluster, The current microservice refers to a microservice that currently maintains a communication connection with the user terminal. Wherein the call request is generated by the current microservice of the user terminal, it means that the call request is triggered by the user terminal when the current microservice is used, and is generated by the current microservice to point to the target microservice . That is, the target microservice has an association relationship with the current microservice, and belongs to a combination of microservices that can be published together in grayscale.
如上述步骤S2所述,解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip地址、请求头或者请求参数。其中所述请求中包括有用户终端的ip地址、请求头或者请求参数等信息,因此通过解析所述请求从而得到指定数据。例如当所述调用请求采用HTTP通信协议进行封装时,其格式例如为:请求行、请求头、空行和请求内容所构成。因此通过调用通过协议的格式,即对所述调用请求进行解析,从而获得指定数据。其中所述指定数据例如为请求头中预定位置中的字符串。所述指定数据是作为后续灰度发布分流的依据,即用于确定用户终端应如何分流。其中请求参数指所述请求中的参数,可以依据所述请求参数的值作为划分所述用户终端的依据,从而决定所述用户终端应被分流至哪些版本的服务。As described in step S2 above, the call request is parsed to obtain designated data, and the designated data includes the ip address, request header, or request parameter of the user terminal. Wherein, the request includes information such as the ip address, request header, or request parameters of the user terminal, so the specified data is obtained by parsing the request. For example, when the call request is encapsulated using the HTTP communication protocol, the format is, for example, a request line, a request header, a blank line, and the request content. Therefore, by calling the format of the passed protocol, the calling request is parsed to obtain the specified data. The specified data is, for example, a character string in a predetermined position in the request header. The specified data is used as a basis for subsequent grayscale release and distribution, that is, it is used to determine how the user terminal should distribute. The request parameter refers to the parameter in the request, and the value of the request parameter may be used as a basis for dividing the user terminal, so as to determine which version of the service the user terminal should be diverted to.
如上述步骤S3所述,获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略。所述一起灰度策略例如:判断用户终端的ip地址是否落入预设的地址范围内,若落入预设的地址范围内,则将所述用户终端认定为一起灰度策略用户,因此所述用户终端应执行一起灰度策略,从而对至少两个微服务集群进行灰度发布。本申请采用的一起灰度策略来自于灰度策略提供终端,从而使灰度策略的设置与灰度版本的标记分割开来,服务提供方在进行灰度发布时,只需对微服务的版本进行标记即可,从而克服了传统方案设置灰度发布的流程繁琐,耗时长的缺陷。As described in step S3 above, obtaining a gray-scale strategy provides a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing. The gray-level strategy is for example: judging whether the ip address of the user terminal falls within the preset address range, and if it falls within the preset address range, the user terminal is identified as a gray-level strategy user. The user terminal should implement a gray-scale strategy to release at least two microservice clusters in gray-scale. The gray-scale strategy adopted in this application comes from the gray-scale strategy provider terminal, so that the gray-scale strategy setting is separated from the gray-scale version mark. When the service provider performs the gray-scale release, only the version of the microservice is required. Just mark it, which overcomes the cumbersome and time-consuming defects of the traditional scheme setting gray-scale release process.
如上述步骤S4所述,判断所述指定数据是否落入所述一起灰度策略的预设范围之内。其中所述具体的判断方法例如为:根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值;若所述相似度值不小于预设相似度阈值,则获取所述一起灰度策略中约定的第一版本灰度用户、第二版本灰度用户、…、第n版本灰度用户对应的第一关键词、第二关键词、…、第n关键词,其中所述一起灰度策略预先约定了n个版本的灰度用户;判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词;若所述指定数据记载有第一关键词、第二关键词、…或者第n关键词,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。从而为进一步地进行了多服务的多版本的灰度发布提供了可能。As described in step S4 above, it is determined whether the specified data falls within the preset range of the one gray scale strategy. The specific judgment method is, for example, calculating the similarity value between the designated data and the preset character string according to a preset similarity algorithm, and judging whether the similarity value is less than a preset similarity threshold; If the similarity value is not less than the preset similarity threshold, then obtain the first key corresponding to the first version gray user, the second version gray user,..., the nth version gray user agreed in the one gray policy Word, second keyword,..., nth keyword, wherein the one grayscale strategy pre-appoints n versions of grayscale users; it is determined whether the specified data records the first keyword, second keyword, ...Or the nth keyword; if the designated data records the first keyword, the second keyword, ... or the nth keyword, it is determined that the designated data falls within the preset range of the same gray scale strategy And mark the user terminal as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword. Thus, it is possible to further carry out the gray release of multi-service and multi-version.
如上述步骤S5所述,若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略。其中预设的灰度策略判断方法例如 为:若所述指定数据未落入所述一起灰度策略的预设范围之内,则获取所述当前微服务的版本号;获取所述一起灰度策略中的微服务的版本号;判断所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号是否相同;若所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号相同,则判定所述当前微服务属于所述一起灰度策略。As described in the above step S5, if the specified data does not fall within the preset range of the gray-scale strategy, the preset gray-scale strategy judgment method is used to determine whether the current microservice belongs to the common gray-scale strategy. Grayscale strategy. The preset gray-scale strategy judgment method is, for example: if the specified data does not fall within the preset range of the gray-scale strategy, obtain the version number of the current microservice; obtain the gray-scale The version number of the microservice in the policy; determine whether the version number of the current microservice is the same as the version number of the microservice in the integrated grayscale policy; if the version number of the current microservice is the same as the integrated grayscale If the version numbers of the microservices in the policies are the same, it is determined that the current microservices belong to the same gray-scale policy.
如上述步骤S6所述,若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略。其中判断所述目标微服务是否属于所述一起灰度策略所采用的方法可以采用前述的灰度策略判断方法,也可以采用其他任意方法,例如判断所述一起灰度策略中记载的微服务名单中是否包括所述目标微服务的微服务名称。As described in the above step S6, if the current microservice does not belong to the gray-level integration strategy, it is determined whether the target microservice belongs to the gray-level integration strategy. The method used to determine whether the target microservice belongs to the gray-scale strategy can use the aforementioned gray-scale strategy judgment method, or any other method, such as judging the list of microservices recorded in the gray-scale strategy. Whether the microservice name of the target microservice is included in the.
如上述步骤S7所述,若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。若所述目标微服务属于所述一起灰度策略,表明所述目标微服务及所述目标微服务所处的微服务集群是应进行一起灰度操作的,因此将所述调用请求分流至所述目标微服务的灰度服务实例,并且对所述目标微服务所处的微服务集群进行灰度发布,即建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。更进一步地,还包括:构建连接通道,以使所述当前微服务所处的微服务集群进行灰度发布。从而实现多个服务(多个微服务集群,例如包括一起灰度策略中规定的微服务集群)一起灰度发布。As described in step S7 above, if the target microservice belongs to the grayscale policy, then the call request is diverted to the grayscale service instance of the target microservice, and a signal connection channel is established, wherein the signal One end of the connection channel is connected to the user terminal, and the other end is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service. If the target microservice belongs to the gray-level strategy, it indicates that the target microservice and the microservice cluster in which the target microservice is located should perform a gray-scale operation, so the call request is diverted to all The gray-scale service instance of the target microservice, and the gray-scale publication of the microservice cluster where the target microservice is located, that is, a signal connection channel is established, wherein one end of the signal connection channel is connected to the user terminal, and the other end Connect to the gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service. Furthermore, it also includes: constructing a connection channel to enable the microservice cluster where the current microservice is located to perform grayscale publishing. In this way, multiple services (multiple microservice clusters, for example, including the microservice cluster specified in the same grayscale policy) can be published together in grayscale.
在一个实施方式中,所述指定数据为请求头中预先约定位置记载的字符串,所述一起灰度策略限定了多个预设范围,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤S4,包括:In one embodiment, the designated data is a character string recorded in a pre-appointed position in the request header, the gray scale strategy defines a plurality of preset ranges, and the determination of whether the designated data falls into the gray scale Step S4 within the preset range of the degree strategy includes:
S401、根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值;S401: Calculate the similarity value between the designated data and the preset character string according to a preset similarity algorithm, and determine whether the similarity value is less than a preset similarity threshold;
S402、若所述相似度值不小于预设相似度阈值,则获取所述一起灰度策略中约定的第一版本灰度用户、第二版本灰度用户、…、第n版本灰度用户对应的第一关键词、第二关键词、…、第n关键词,其中所述一起灰度策略预先约定了n个版本的灰度用户;S402. If the similarity value is not less than the preset similarity threshold, obtain the first version grayscale user, the second version grayscale user,..., the nth version grayscale user correspondence agreed in the one grayscale strategy The first keyword, the second keyword, ..., the nth keyword of, wherein the one grayscale strategy pre-appoints n versions of grayscale users;
S404、判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词;S404: Determine whether the designated data records a first keyword, a second keyword, ... or an nth keyword;
S405、若所述指定数据记载有第一关键词、第二关键词、…或者第n关键词,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。S405. If the specified data records the first keyword, the second keyword, ... or the nth keyword, determine that the specified data falls within the preset range of the one gray scale strategy, and set all The user terminal is recorded as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
如上所述,实现了判断所述指定数据是否落入所述一起灰度策略的预设范围之内。其中预设的相似算法可以为任意算法,只要能计算所述指定数据与预设字符串的相似度值即可,例如基于余弦定理的距离公式,基于词频向量的相似度算法等。所述相似度值不小于预设相似度阈值,则表示对应的指定数据 与预设字符串相似,因此对应的用户终端是灰度用户。并且本申请采用了多版本灰度,因此还需判断所述用户终端是哪个版本的灰度用户。因此本申请通过判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词的方式,从而将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。据此,实现了基于微服务框架的多版本灰度的准确发布。其中,所述指定数据为请求头中预先约定位置记载的字符串,例如为请求头中两个特殊符号(例如??)之前记载的字符串。As described above, it is possible to determine whether the specified data falls within the preset range of the gray-scale strategy. The preset similarity algorithm can be any algorithm, as long as the similarity value between the specified data and the preset character string can be calculated, such as a distance formula based on the law of cosine, a similarity algorithm based on a word frequency vector, and the like. If the similarity value is not less than the preset similarity threshold, it means that the corresponding designated data is similar to the preset character string, and therefore the corresponding user terminal is a gray-scale user. In addition, this application uses multiple versions of grayscale, so it is also necessary to determine which version of the grayscale user the user terminal is. Therefore, this application determines whether the designated data contains the first keyword, the second keyword, ... or the nth keyword, so as to record the user terminal as being related to the first keyword and the second keyword. The version gray user corresponding to the word, ... or the nth keyword. Accordingly, the accurate release of multi-version grayscale based on the microservice framework is realized. Wherein, the designated data is a character string recorded in a predetermined position in the request header, for example, a character string recorded before two special symbols (such as ?) in the request header.
在一个实施方式中,所述根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值的步骤S401,包括:In one embodiment, the step S401 of calculating a similarity value between the designated data and a preset character string according to a preset similarity algorithm, and determining whether the similarity value is less than a preset similarity threshold, includes :
S4011、采用公式:S4011, adopt the formula:
Figure PCTCN2019117216-appb-000001
Figure PCTCN2019117216-appb-000001
计算所述指定数据与预设字符串的相似度值,其中similarity为相似度值,A为所述指定数据的字符频率向量,B为所述预设字符串的字符频率向量,Ai为所述指定数据的第i个字符出现的次数,Bi为所述预设字符串的第i个字符出现的次数;Calculate the similarity value between the specified data and the preset character string, where similarity is the similarity value, A is the character frequency vector of the specified data, B is the character frequency vector of the preset character string, and Ai is the character frequency vector of the specified data. The number of occurrences of the i-th character of the designated data, and Bi is the number of occurrences of the i-th character of the preset character string;
S4012、根据字符串与相似度阈值的对应关系,获取与所述预设字符串对应的指定相似度阈值;S4012, according to the corresponding relationship between the character string and the similarity threshold, obtain a designated similarity threshold corresponding to the preset character string;
S4013、判断所述相似度值是否小于所述指定相似度阈值。S4013: Determine whether the similarity value is less than the specified similarity threshold.
如上所述,实现了根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值。所述字符频率向量是以字符串中的各字符出现的次数(频率)作为向量的高维度数值所构成的高维向量。即A=(A1,A2,…,An),其中An为最后一个字符(共有n个字符)的出现频率(出现次数)。所述相似度算法是根据所述指定数据与预设字符串的余弦相似度进行计算得到,以反应所述指定数据与预设字符串间的相似程度。当similarity的值越接近于1,表明越相似;越接近于0,表明越不相似。As described above, it is realized that the similarity value between the designated data and the preset character string is calculated according to the preset similarity algorithm, and it is determined whether the similarity value is less than the preset similarity threshold. The character frequency vector is a high-dimensional vector composed of the number of times (frequency) of each character in the character string as the high-dimensional value of the vector. That is, A=(A1,A2,...,An), where An is the frequency (number of occurrences) of the last character (a total of n characters). The similarity algorithm is calculated according to the cosine similarity between the designated data and the preset character string, so as to reflect the degree of similarity between the designated data and the preset character string. When the value of similarity is closer to 1, the more similar it is; the closer to 0, the more dissimilar it is.
在一个实施方式中,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤S4,包括:In one embodiment, the step S4 of judging whether the specified data falls within the preset range of the one gray scale strategy includes:
S411、根据预设的编码方法,将所述用户终端的ip地址、请求头和请求参数编码为矩阵[B1,B2,B3],其中B1为所述ip地址对应的映射值、B2为所述请求头对应的映射值、B3为所述请求参数对应的映射值;S411. According to a preset encoding method, encode the ip address, request header, and request parameters of the user terminal into a matrix [B1, B2, B3], where B1 is the mapping value corresponding to the ip address, and B2 is the The mapping value corresponding to the request header, and B3 is the mapping value corresponding to the request parameter;
S412、根据预设的灰度策略与参数矩阵的对应关系,获取与所述一起灰度策略对应的指定参数矩阵[C1,C2,C3];S412: Acquire a designated parameter matrix [C1, C2, C3] corresponding to the one gray-scale strategy according to the preset corresponding relationship between the gray-scale strategy and the parameter matrix;
S413、通过公式:M=||[B1,B2,B3] T[C1,C2,C3]||,计算得到划分参考指数M; S413. Through the formula: M=||[B1,B2,B3] T [C1,C2,C3]||, the division reference index M is obtained by calculation;
S414、判断所述参考指数M是否落入预设的多个数值范围之内;S414: Determine whether the reference index M falls within multiple preset numerical ranges;
S415、若所述参考指数M落入预设的多个数值范围之内,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端划分为Am,其中Am指第m版本灰度用户,所述第m版本灰度用户对应于所述参考指数M落入的数值范围。S415. If the reference index M falls within a plurality of preset numerical ranges, determine that the specified data falls within the preset range of the same gray scale strategy, and divide the user terminal into Am , Where Am refers to a grayscale user of the mth version, and the grayscale user of the mth version corresponds to the numerical range in which the reference index M falls.
如上所述,实现了判断所述指定数据是否落入所述一起灰度策略的预设范围之内,并将所述用户终端划分为Am。传统的灰度发布方案都是采用单个因素进行低维灰度发布,而本申请采用了高维混合灰度,相较于传统技术的单维灰度方案,划分更加快捷、精准。具体地,根据预设的编码方法,将所述用户终端的ip地址、请求头和请求参数编码为矩阵[B1,B2,B3];根据预设的灰度策略与参数矩阵的对应关系,获取与所述灰度策略提供终端提供的灰度策略对应的指定参数矩阵[C1,C2,C3];通过公式:M=||[B1,B2,B3] T[C1,C2,C3]||,计算得到划分参考指数M;再根据参考指数M进行划分灰度用户。其中编码方法即是将所述用户终端的ip地址、请求头和请求参数依次映射为具体数值,再组合得到矩阵的方法。因此本申请可以同时综合用户终端的ip地址、请求头和请求参数进行高维准确地灰度发布,划分更加快捷、精准。 As described above, it is possible to determine whether the specified data falls within the preset range of the one gray scale strategy, and divide the user terminal into Am. Traditional gray-scale publishing solutions use a single factor for low-dimensional gray-scale publishing, while this application uses high-dimensional mixed grayscale, which is faster and more precise than the single-dimensional gray-scale solution of the traditional technology. Specifically, according to a preset coding method, the ip address, request header, and request parameters of the user terminal are coded into a matrix [B1, B2, B3]; according to the corresponding relationship between the preset gray level strategy and the parameter matrix, obtain The specified parameter matrix [C1, C2, C3] corresponding to the gray strategy provided by the gray strategy providing terminal; through the formula: M=||[B1,B2,B3] T [C1,C2,C3]|| , Calculate the division reference index M; then divide the gray users according to the reference index M. The encoding method is a method of sequentially mapping the ip address, request header, and request parameters of the user terminal to specific values, and then combining them to obtain a matrix. Therefore, this application can simultaneously integrate the ip address, request header, and request parameters of the user terminal to perform high-dimensional and accurate gray-scale release, and the division is faster and more accurate.
在一个实施方式中,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤S4之后,包括:In one embodiment, after the step S4 of determining whether the designated data falls within the preset range of the one gray scale strategy, the method includes:
S41、若所述指定数据落入所述一起灰度策略的预设范围之内,则将所述调用请求分流至所述目标微服务的灰度服务实例;S41. If the specified data falls within the preset range of the one gray-scale strategy, offload the call request to the gray-scale service instance of the target microservice;
S42、建立通信通道,所述通信通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。S42. Establish a communication channel. One end of the communication channel is connected to the user terminal, and the other end is connected to gray-scale service instances of other micro-services in the integrated gray-scale strategy except for the target micro-service.
如上所述,实现了执行一起灰度策略。若所述指定数据落入所述一起灰度策略的预设范围之内,表明用户终端是需要执行一起灰度策略的(并且目标微服务也是处于一起灰度策略之中),并且所述目标微服务也应进行灰度发布。据此将所述调用请求分流至所述目标微服务的灰度服务实例,以实现所述目标微服务的灰度发布。并且建立通信通道,所述通信通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例,以实现一起灰度发布。进一步地,还包括:建立通信通道,以使当前微服务所处的微服务集群进行灰度发布(这是因为当前微服务与目标微服务具有关联关系,可以进行一起灰度发布)。As described above, the implementation of a gray-scale strategy is achieved. If the specified data falls within the preset range of the gray-level strategy, it indicates that the user terminal needs to implement the gray-scale strategy together (and the target microservice is also in the gray-scale strategy together), and the target Microservices should also be published in grayscale. Accordingly, the call request is diverted to the gray-scale service instance of the target microservice, so as to realize the gray-scale release of the target microservice. And a communication channel is established. One end of the communication channel is connected to the user terminal, and the other end is connected to the gray-scale service instances of other micro-services in the gray-scale policy together except for the target micro-service, so as to realize the integration Grayscale release. Further, it also includes: establishing a communication channel to enable the microservice cluster where the current microservice is located to perform grayscale publishing (this is because the current microservice and the target microservice have an association relationship and can be grayscale published together).
在一个实施方式中,微服务具有版本号,所述若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略的步骤S5,包括:In one embodiment, the microservice has a version number, and if the specified data does not fall within the preset range of the gray-level strategy, the current gray-scale strategy determination method is used to determine the current Whether the microservice belongs to the step S5 of the gray-scale strategy includes:
S501、若所述指定数据未落入所述一起灰度策略的预设范围之内,则获取所述当前微服务的版本号;S501: If the specified data does not fall within the preset range of the gray-scale strategy, obtain the version number of the current microservice;
S502、获取所述一起灰度策略中的微服务的版本号;S502. Obtain the version number of the microservice in the gray-scale strategy.
S503、判断所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号是否相同;S503: Determine whether the version number of the current microservice is the same as the version number of the microservice in the one-level strategy;
S504、若所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号相同,则判定所述当前微服务属于所述一起灰度策略。S504: If the version number of the current microservice is the same as the version number of the microservice in the integrated grayscale strategy, determine that the current microservice belongs to the integrated grayscale strategy.
如上所述,实现了判断所述当前微服务是否属于所述一起灰度策略。本申请采用微服务架构,并且微服务具有版本号的形式,从而使多服务且多版本同时灰度发布成为了可能,并且利用微服务的特性,降低了多服务且多版本同时灰度发布的成本。其中若所述指定数据未落入所述一起灰度策略的预设范围之内,表明请求本身未带来灰度信号。因此再通过判断所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号是否相同,以确定当前微服务是否属于所述一起灰度策略,并且更进一步地确定当前微服务属于所述一起灰度策略中的哪个版本的灰度发布。As described above, it is possible to determine whether the current microservice belongs to the gray scale strategy. This application adopts the microservice architecture, and the microservices have the form of version numbers, so that it is possible to publish multiple services and multiple versions at the same time grayscale release, and use the characteristics of microservices to reduce the grayscale release of multiple services and multiple versions at the same time cost. If the specified data does not fall within the preset range of the gray-scale strategy, it indicates that the request itself does not bring a gray-scale signal. Therefore, by judging whether the version number of the current microservice is the same as the version number of the microservice in the integration strategy, to determine whether the current microservice belongs to the integration strategy, and to further determine the current microservice Which version of the grayscale release of the service belongs to the one grayscale strategy.
在一个实施方式中,所述若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略的步骤S6之后,包括:In one embodiment, after the step S6 of determining whether the target microservice belongs to the gray-level policy, if the current microservice does not belong to the gray-level policy, the method includes:
S61、若所述目标微服务不属于所述一起灰度策略,则将所述用户终端输入已经训练完成的基于机器学习模型的灰度再分类模型中运算,从而获得所述灰度再分类模型的输出结果,其中所述输出结果包括灰度用户与非灰度用户;S61. If the target microservice does not belong to the gray-level strategy, input the user terminal to the already-trained gray-level reclassification model based on the machine learning model for calculation, thereby obtaining the gray-level reclassification model The output result of, wherein the output result includes gray-scale users and non-gray-scale users;
S62、若所述输出结果为灰度用户,则将所述调用请求分流至所述目标微服务的灰度服务实例;S62. If the output result is a gray-scale user, offload the call request to the gray-scale service instance of the target microservice;
S63、若所述输出结果为非灰度用户,则将所述调用请求分流至所述目标微服务的非灰度服务实例。S63. If the output result is a non-grayscale user, then branch the call request to the non-grayscale service instance of the target microservice.
如上所述,实现了利用灰度再分类模型进行再次分类,以进一步保证灰度发布的准确性。相较于传统技术,本申请采用已经训练完成的基于机器学习模型的灰度再分类模型对所述用户终端进行再次分类,避免了人工设置灰度发布时的不准确性,因此能够更精准地进行灰度发布,进而使灰度发布反馈得到的数据信息更有效,提高灰度发布的成功率。其中所述机器学习模型可以为任意模型,例如为CHAID决策树模型。CHAID决策树模型指采用卡方自动交互检测法CHAID的决策树模型。在此简单介绍CHAID决策树的原理:1、合并组内对决策变量影响差别不显著的组值;2、选取卡方值最大的变量作为树分类变量;3、重复1、2步骤,至不能选取卡方值大于某值或P值不再小于某临界值,或样本小于某数。其中决策树的建模标准参数例如为:决策树的最大层数为4-5层、母节点可再分的显著水平为0.05、母节点包含的最小样本数为150、子节点包含的最小样本数为50。As mentioned above, the re-classification using the gray-level re-classification model is realized to further ensure the accuracy of gray-level publishing. Compared with the traditional technology, this application uses the already-trained gray-scale reclassification model based on the machine learning model to re-classify the user terminal, avoiding the inaccuracy of manually setting the gray-scale publishing, and thus can more accurately Perform gray-scale release, and then make the data information obtained by gray-scale release feedback more effective, and improve the success rate of gray-scale release. The machine learning model may be any model, for example, a CHAID decision tree model. The CHAID decision tree model refers to a decision tree model that uses the chi-square automatic interactive detection method CHAID. Here is a brief introduction to the principles of the CHAID decision tree: 1. Combine the group values that have no significant difference in the impact of the decision variables in the group; 2. Select the variable with the largest chi-square value as the tree classification variable; 3. Repeat the steps 1 and 2 until it fails Choose that the chi-square value is greater than a certain value or the P value is no longer less than a certain critical value, or the sample is less than a certain number. Among them, the modeling standard parameters of the decision tree are for example: the maximum number of layers of the decision tree is 4-5, the significance level of the parent node can be subdivided is 0.05, the minimum number of samples contained in the parent node is 150, and the minimum sample contained in the child nodes The number is 50.
参照图2,本申请实施例提供一种基于微服务框架的一起灰度装置,包括:Referring to FIG. 2, an embodiment of the present application provides a grayscale device based on a microservice framework, including:
调用请求接收单元10,用于接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务;The call request receiving unit 10 is configured to receive a call request directed to a target microservice, wherein the call request is generated by the current microservice of the user terminal, and the current microservice and the target microservice do not belong to the same microservice cluster , The current microservice refers to a microservice that currently maintains a communication connection with the user terminal;
指定数据获取单元20,用于解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip 地址、请求头或者请求参数;The designated data obtaining unit 20 is configured to parse the call request to obtain designated data, and the designated data includes the ip address, request header, or request parameter of the user terminal;
一起灰度策略获取单元30,用于获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略;A gray-level strategy obtaining unit 30 is configured to obtain a gray-scale strategy provided by the terminal to provide a gray-scale strategy together, where the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform grayscale publishing;
预设范围判断单元40,用于判断所述指定数据是否落入所述一起灰度策略的预设范围之内;The preset range determining unit 40 is configured to determine whether the specified data falls within the preset range of the one gray scale strategy;
灰度策略判断单元50,用于若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略;The gray-scale strategy judging unit 50 is configured to determine whether the current microservice belongs to all the micro-services through a preset gray-scale strategy judgment method if the specified data does not fall within the preset range of the gray-scale strategy. Describe a gray-scale strategy;
目标微服务判断单元60,用于若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;The target microservice determining unit 60 is configured to determine whether the target microservice belongs to the grayscale policy if the current microservice does not belong to the grayscale policy;
信号连接通道建立单元70,用于若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。The signal connection channel establishment unit 70 is configured to, if the target microservice belongs to the gray-scale policy, then divert the call request to the gray-scale service instance of the target microservice, and establish a signal connection channel, wherein One end of the signal connection channel is connected to the user terminal, and the other end is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
其中上述单元分别用于执行的操作与前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The operations performed by the above-mentioned units respectively correspond to the steps of the grayscale method based on the microservice framework of the foregoing embodiment one by one, and will not be repeated here.
在一个实施方式中,所述指定数据为请求头中预先约定位置记载的字符串,所述一起灰度策略限定了多个预设范围,所述预设范围判断单元40,包括:In one embodiment, the specified data is a character string recorded in a pre-appointed position in the request header, the one gray scale strategy defines a plurality of preset ranges, and the preset range determining unit 40 includes:
相似度计算子单元,用于根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值;The similarity calculation subunit is configured to calculate the similarity value between the designated data and the preset character string according to a preset similarity algorithm, and determine whether the similarity value is less than a preset similarity threshold;
关键词获取子单元,用于若所述相似度值不小于预设相似度阈值,则获取所述一起灰度策略中约定的第一版本灰度用户、第二版本灰度用户、…、第n版本灰度用户对应的第一关键词、第二关键词、…、第n关键词,其中所述一起灰度策略预先约定了n个版本的灰度用户;The keyword acquisition subunit is used to acquire the first version grayscale user, the second version grayscale user,..., the first version specified in the one grayscale strategy if the similarity value is not less than the preset similarity threshold value. The first keyword, the second keyword, ..., the nth keyword corresponding to the n-version gray-scale user, wherein the one gray-scale strategy pre-appoints n-version gray-scale users;
关键词判断子单元,用于判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词;The keyword judgment subunit is used to judge whether the specified data records the first keyword, the second keyword, ... or the nth keyword;
灰度用记划分子单元,用于若所述指定数据记载有第一关键词、第二关键词、…或者第n关键词,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。The gray scale mark division subunit is used to determine that the specified data falls into the pre-defined gray scale strategy if the specified data contains the first keyword, the second keyword, ... or the nth keyword. Set within the range, and record the user terminal as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
其中上述子单元分别用于执行的操作与前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The operations performed by the above-mentioned sub-units respectively correspond to the steps of the gray-scale method based on the microservice framework of the foregoing embodiment one-to-one, and will not be repeated here.
在一个实施方式中,所述相似度计算子单元,包括:In one embodiment, the similarity calculation subunit includes:
相似度计算模块,用于采用公式:Similarity calculation module, used to adopt formula:
Figure PCTCN2019117216-appb-000002
Figure PCTCN2019117216-appb-000002
计算所述指定数据与预设字符串的相似度值,其中similarity为相似度值,A为所述指定数据的字符频率向量,B为所述预设字符串的字符频率向量,Ai为所述指定数据的第i个字符出现的次数,Bi为所述预设字符串的第i个字符出现的次数;Calculate the similarity value between the specified data and the preset character string, where similarity is the similarity value, A is the character frequency vector of the specified data, B is the character frequency vector of the preset character string, and Ai is the character frequency vector of the specified data. The number of occurrences of the i-th character of the designated data, and Bi is the number of occurrences of the i-th character of the preset character string;
指定相似度阈值获取模块,用于根据字符串与相似度阈值的对应关系,获取与所述预设字符串对应的指定相似度阈值;A designated similarity threshold acquisition module, configured to acquire a designated similarity threshold corresponding to the preset character string according to the corresponding relationship between the character string and the similarity threshold;
指定相似度阈值判断模块,用于判断所述相似度值是否小于所述指定相似度阈值。The designated similarity threshold judgment module is used to judge whether the similarity value is less than the designated similarity threshold.
其中上述模块分别用于执行的操作与前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The operations performed by the above-mentioned modules respectively correspond to the steps of the gray-scale method based on the microservice framework of the foregoing embodiment one by one, and will not be repeated here.
在一个实施方式中,所述预设范围判断单元40,包括:In one embodiment, the preset range determining unit 40 includes:
编码子单元,用于根据预设的编码方法,将所述用户终端的ip地址、请求头和请求参数编码为矩阵[B1,B2,B3],其中B1为所述ip地址对应的映射值、B2为所述请求头对应的映射值、B3为所述请求参数对应的映射值;The encoding subunit is used to encode the ip address, request header, and request parameters of the user terminal into a matrix [B1, B2, B3] according to a preset encoding method, where B1 is the mapping value corresponding to the ip address, B2 is the mapping value corresponding to the request header, and B3 is the mapping value corresponding to the request parameter;
指定参数矩阵获取子单元,用于根据预设的灰度策略与参数矩阵的对应关系,获取与所述一起灰度策略对应的指定参数矩阵[C1,C2,C3];The designated parameter matrix acquiring subunit is used to acquire the designated parameter matrix [C1, C2, C3] corresponding to the one gray strategy according to the corresponding relationship between the preset gray strategy and the parameter matrix;
划分参考指数M获取子单元,用于通过公式:M=||[B1,B2,B3] T[C1,C2,C3]||,计算得到划分参考指数M; The division reference index M is used to obtain the subunit, which is used to calculate the division reference index M through the formula: M=||[B1,B2,B3] T [C1,C2,C3]||;
数值范围判断子单元,用于判断所述参考指数M是否落入预设的多个数值范围之内;A numerical value range judging subunit for judging whether the reference index M falls within a plurality of preset numerical ranges;
用户终端划分子单元,用于若所述参考指数M落入预设的多个数值范围之内,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端划分为Am,其中Am指第m版本灰度用户,所述第m版本灰度用户对应于所述参考指数M落入的数值范围。The user terminal divides sub-units for determining that the specified data falls within the preset range of the same gray scale strategy if the reference index M falls within a plurality of preset numerical ranges, and sets all The user terminal is divided into Am, where Am refers to an m-th version of gray-scale user, and the m-th version of gray-scale user corresponds to the numerical range in which the reference index M falls.
其中上述子单元分别用于执行的操作与前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The operations performed by the above-mentioned sub-units respectively correspond to the steps of the gray-scale method based on the microservice framework of the foregoing embodiment one-to-one, and will not be repeated here.
在一个实施方式中,所述装置,包括:In one embodiment, the device includes:
调用请求分流单元,用于若所述指定数据落入所述一起灰度策略的预设范围之内,则将所述调用请求分流至所述目标微服务的灰度服务实例;A call request shunting unit, configured to shunt the call request to the gray service instance of the target microservice if the specified data falls within the preset range of the gray-level strategy;
通信通道建立单元,用于建立通信通道,所述通信通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。The communication channel establishment unit is configured to establish a communication channel, one end of the communication channel is connected to the user terminal, and the other end is connected to the gray level of other microservices in the same gray level strategy except the target microservice Service instance.
其中上述单元分别用于执行的操作与前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The operations performed by the above-mentioned units respectively correspond to the steps of the grayscale method based on the microservice framework of the foregoing embodiment one by one, and will not be repeated here.
在一个实施方式中,微服务具有版本号,所述灰度策略判断单元50,包括:In one embodiment, the microservice has a version number, and the gray-scale strategy judgment unit 50 includes:
当前微服务版本号获取子单元,用于若所述指定数据未落入所述一起灰度策略的预设范围之内,则获取所述当前微服务的版本号;The current microservice version number obtaining subunit is configured to obtain the version number of the current microservice if the specified data does not fall within the preset range of the gray-scale strategy;
灰度策略版本号获取子单元,用于获取所述一起灰度策略中的微服务的版本号;The gray-scale strategy version number obtaining subunit is used to obtain the version number of the microservice in the gray-scale strategy;
版本号判断子单元,用于判断所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号是否相同;The version number judging subunit is used to judge whether the version number of the current microservice is the same as the version number of the microservice in the same gray-scale strategy;
一起灰度策略判定子单元,用于若所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号相同,则判定所述当前微服务属于所述一起灰度策略。A gray-scale policy determination subunit is configured to determine that the current micro-service belongs to the gray-scale policy if the version number of the current microservice is the same as the version number of the micro-service in the gray-scale policy.
其中上述子单元分别用于执行的操作与前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The operations performed by the above-mentioned sub-units respectively correspond to the steps of the gray-scale method based on the microservice framework of the foregoing embodiment one-to-one, and will not be repeated here.
在一个实施方式中,所述装置,包括:In one embodiment, the device includes:
输出结果获取单元,用于若所述目标微服务不属于所述一起灰度策略,则将所述用户终端输入已经训练完成的基于机器学习模型的灰度再分类模型中运算,从而获得所述灰度再分类模型的输出结果,其中所述输出结果包括灰度用户与非灰度用户;The output result obtaining unit is configured to, if the target microservice does not belong to the gray-level strategy, input the user terminal into the already-trained gray-level reclassification model based on the machine learning model for calculation, thereby obtaining the The output result of the gray-scale reclassification model, where the output result includes gray-scale users and non-gray-scale users;
灰度服务实例分流单元,用于若所述输出结果为灰度用户,则将所述调用请求分流至所述目标微服务的灰度服务实例;A gray-scale service instance offloading unit, configured to offload the call request to the gray-scale service instance of the target microservice if the output result is a gray-scale user;
非灰度服务实例分流单元,用于若所述输出结果为非灰度用户,则将所述调用请求分流至所述目标微服务的非灰度服务实例。The non-gray-scale service instance distribution unit is configured to distribute the call request to the non-gray-scale service instance of the target microservice if the output result is a non-gray-scale user.
其中上述单元分别用于执行的操作与前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The operations performed by the above-mentioned units respectively correspond to the steps of the grayscale method based on the microservice framework of the foregoing embodiment one by one, and will not be repeated here.
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储基于微服务框架的一起灰度方法所用数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种基于微服务框架的一起灰度方法。3, an embodiment of the present application also provides a computer device. The computer device may be a server, and its internal structure may be as shown in the figure. The computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor designed by the computer is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer equipment is used to store the data used in the grayscale method based on the microservice framework. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer program is executed by the processor to realize a gray-scale method based on the microservice framework.
上述处理器执行上述基于微服务框架的一起灰度方法,其中所述方法包括的步骤分别与执行前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。The above-mentioned processor executes the above-mentioned grayscale method based on the microservice framework, wherein the steps included in the method respectively correspond to the steps of executing the grayscale method based on the microservice framework of the foregoing embodiment one-to-one, and will not be repeated here.
本领域技术人员可以理解,图中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。Those skilled in the art can understand that the structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
本申请一实施例还提供一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现基于微服务框架的一起灰度方法,其中所述方法包括的步骤分别与执行前述实施方式的基于微服务框架的一起灰度方法的步骤一一对应,在此不再赘述。其中所述计算机可读存储介质例如为,非易失性的计算机可读存储介质,或者为易失性的计算机可读存储介质。An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, a grayscale method based on a microservice framework is implemented, wherein the steps included in the method are respectively the same as those in the execution. The steps of the gray-scale method based on the microservice framework in the foregoing embodiment correspond one-to-one, and will not be repeated here. The computer-readable storage medium is, for example, a non-volatile computer-readable storage medium, or a volatile computer-readable storage medium.

Claims (20)

  1. 一种基于微服务框架的一起灰度方法,其特征在于,包括:A gray-scale method based on a microservice framework, which is characterized in that it includes:
    接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务;Receive a call request directed to a target microservice, where the call request is generated by the current microservice of the user terminal, the current microservice and the target microservice do not belong to the same microservice cluster, and the current microservice refers to the current microservice A microservice that maintains a communication connection with the user terminal;
    解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip地址、请求头或者请求参数;Parsing the call request to obtain designated data, where the designated data includes the ip address, request header, or request parameter of the user terminal;
    获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略;Obtaining the gray-scale strategy provides a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing;
    判断所述指定数据是否落入所述一起灰度策略的预设范围之内;Judging whether the specified data falls within the preset range of the one gray scale strategy;
    若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略;If the specified data does not fall within the preset range of the integrated gray-scale strategy, use a preset gray-level strategy judgment method to determine whether the current microservice belongs to the integrated gray-scale strategy;
    若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;If the current microservice does not belong to the gray-scale integration strategy, determining whether the target microservice belongs to the gray-scale integration strategy;
    若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。If the target microservice belongs to the gray-scale policy, then the call request is diverted to the gray-scale service instance of the target microservice, and a signal connection channel is established, wherein one end of the signal connection channel is connected to the The other end of the user terminal is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
  2. 根据权利要求1所述的基于微服务框架的一起灰度方法,其特征在于,所述指定数据为请求头中预先约定位置记载的字符串,所述一起灰度策略限定了多个预设范围,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤,包括:The grayscale integration method based on the microservice framework according to claim 1, wherein the specified data is a character string recorded in a pre-appointed position in the request header, and the grayscale integration strategy defines a plurality of preset ranges , The step of judging whether the designated data falls within the preset range of the one gray scale strategy includes:
    根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值;According to a preset similarity algorithm, calculate a similarity value between the designated data and a preset character string, and determine whether the similarity value is less than a preset similarity threshold;
    若所述相似度值不小于预设相似度阈值,则获取所述一起灰度策略中约定的第一版本灰度用户、第二版本灰度用户、…、第n版本灰度用户对应的第一关键词、第二关键词、…、第n关键词,其中所述一起灰度策略预先约定了n个版本的灰度用户;If the similarity value is not less than the preset similarity threshold, then obtain the first version gray user, the second version gray user,..., the first version gray user corresponding to the nth version gray user agreed in the one gray policy. A keyword, a second keyword, ..., an nth keyword, in which the one grayscale strategy pre-appoints n versions of grayscale users;
    判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词;Determine whether the designated data records the first keyword, the second keyword, ... or the nth keyword;
    若所述指定数据记载有第一关键词、第二关键词、…或者第n关键词,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。If the specified data records the first keyword, the second keyword, ... or the nth keyword, it is determined that the specified data falls within the preset range of the gray-scale strategy, and the user The terminal is recorded as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
  3. 根据权利要求2所述的基于微服务框架的一起灰度方法,其特征在于,所述根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值的步骤,包括:The grayscale method based on the microservice framework according to claim 2, wherein the similarity value between the designated data and the preset character string is calculated according to a preset similarity algorithm, and the The steps of whether the similarity value is less than the preset similarity threshold include:
    采用公式:Use the formula:
    Figure PCTCN2019117216-appb-100001
    Figure PCTCN2019117216-appb-100001
    计算所述指定数据与预设字符串的相似度值,其中similarity为相似度值,A为所述指定数据的字符频率向量,B为所述预设字符串的字符频率向量,Ai为所述指定数据的第i个字符出现的次数,Bi为所述预设字符串的第i个字符出现的次数;Calculate the similarity value between the specified data and the preset character string, where similarity is the similarity value, A is the character frequency vector of the specified data, B is the character frequency vector of the preset character string, and Ai is the character frequency vector of the specified data. The number of occurrences of the i-th character of the designated data, and Bi is the number of occurrences of the i-th character of the preset character string;
    根据字符串与相似度阈值的对应关系,获取与所述预设字符串对应的指定相似度阈值;Obtaining the designated similarity threshold corresponding to the preset character string according to the correspondence between the character string and the similarity threshold;
    判断所述相似度值是否小于所述指定相似度阈值。It is determined whether the similarity value is less than the specified similarity threshold.
  4. 根据权利要求1所述的基于微服务框架的一起灰度方法,其特征在于,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤,包括:The grayscale integration method based on the microservice framework of claim 1, wherein the step of judging whether the specified data falls within the preset range of the grayscale integration strategy comprises:
    根据预设的编码方法,将所述用户终端的ip地址、请求头和请求参数编码为矩阵[B1,B2,B3],其中B1为所述ip地址对应的映射值、B2为所述请求头对应的映射值、B3为所述请求参数对应的映射值;According to a preset encoding method, encode the ip address, request header, and request parameters of the user terminal into a matrix [B1, B2, B3], where B1 is the mapping value corresponding to the ip address, and B2 is the request header The corresponding mapping value, B3 is the mapping value corresponding to the request parameter;
    根据预设的灰度策略与参数矩阵的对应关系,获取与所述一起灰度策略对应的指定参数矩阵[C1,C2,C3];According to the preset corresponding relationship between the gray level strategy and the parameter matrix, obtain the designated parameter matrix [C1, C2, C3] corresponding to the one gray level strategy;
    通过公式:M=||[B1,B2,B3] T[C1,C2,C3]||,计算得到划分参考指数M; Through the formula: M=||[B1,B2,B3] T [C1,C2,C3]||, the division reference index M is calculated;
    判断所述参考指数M是否落入预设的多个数值范围之内;Judging whether the reference index M falls within a plurality of preset numerical ranges;
    若所述参考指数M落入预设的多个数值范围之内,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端划分为Am,其中Am指第m版本灰度用户,所述第m版本灰度用户对应于所述参考指数M落入的数值范围。If the reference index M falls within a plurality of preset numerical ranges, it is determined that the specified data falls within the preset range of the one gray scale strategy, and the user terminal is divided into Am, where Am refers to a grayscale user of the mth version, and the grayscale user of the mth version corresponds to the numerical range in which the reference index M falls.
  5. 根据权利要求1所述的基于微服务框架的一起灰度方法,其特征在于,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤之后,包括:The grayscale method based on the microservice framework according to claim 1, wherein after the step of determining whether the specified data falls within the preset range of the grayscale strategy, the method comprises:
    若所述指定数据落入所述一起灰度策略的预设范围之内,则将所述调用请求分流至所述目标微服务的灰度服务实例;If the specified data falls within the preset range of the one gray-scale strategy, diverting the call request to the gray-scale service instance of the target microservice;
    建立通信通道,所述通信通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。A communication channel is established, one end of the communication channel is connected to the user terminal, and the other end is connected to a gray-scale service instance of other micro-services in the same gray-scale strategy except for the target micro-service.
  6. 根据权利要求1所述的基于微服务框架的一起灰度方法,其特征在于,微服务具有版本号,所述若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略的步骤,包括:The grayscale integration method based on the microservice framework according to claim 1, wherein the microservice has a version number, and if the specified data does not fall within the preset range of the grayscale integration strategy, Then, the step of judging whether the current microservice belongs to the same gray-scale strategy through a preset gray-scale strategy judgment method includes:
    若所述指定数据未落入所述一起灰度策略的预设范围之内,则获取所述当前微服务的版本号;If the specified data does not fall within the preset range of the one gray-scale strategy, obtain the version number of the current microservice;
    获取所述一起灰度策略中的微服务的版本号;Obtain the version number of the microservice in the one gray-scale strategy;
    判断所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号是否相同;Judging whether the version number of the current microservice is the same as the version number of the microservice in the same gray-scale strategy;
    若所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号相同,则判定所述当前微服务属于所述一起灰度策略。If the version number of the current microservice is the same as the version number of the microservice in the integrated grayscale strategy, it is determined that the current microservice belongs to the integrated grayscale strategy.
  7. 根据权利要求1所述的基于微服务框架的一起灰度方法,其特征在于,所述若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略的步骤之后,包括:The gray-scale integration method based on the microservice framework according to claim 1, wherein if the current micro-service does not belong to the gray-scale integration strategy, then it is determined whether the target microservice belongs to the gray-scale integration strategy. After the steps of the grayscale strategy, include:
    若所述目标微服务不属于所述一起灰度策略,则将所述用户终端输入已经训练完成的基于机器学习模型的灰度再分类模型中运算,从而获得所述灰度再分类模型的输出结果,其中所述输出结果包括灰度用户与非灰度用户;If the target microservice does not belong to the gray-level strategy, the user terminal is input to the already-trained gray-level reclassification model based on the machine learning model for operation, so as to obtain the output of the gray-level reclassification model As a result, the output result includes gray-scale users and non-gray-scale users;
    若所述输出结果为灰度用户,则将所述调用请求分流至所述目标微服务的灰度服务实例;If the output result is a gray-scale user, diverting the call request to the gray-scale service instance of the target microservice;
    若所述输出结果为非灰度用户,则将所述调用请求分流至所述目标微服务的非灰度服务实例。If the output result is a non-grayscale user, the call request is diverted to the non-grayscale service instance of the target microservice.
  8. 一种基于微服务框架的一起灰度装置,其特征在于,包括:A gray-scale device based on a microservice framework, which is characterized in that it includes:
    调用请求接收单元,用于接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务;A call request receiving unit for receiving a call request directed to a target microservice, wherein the call request is generated by the current microservice of the user terminal, and the current microservice and the target microservice do not belong to the same microservice cluster, The current microservice refers to a microservice that currently maintains a communication connection with the user terminal;
    指定数据获取单元,用于解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip地址、请求头或者请求参数;A designated data acquisition unit, configured to parse the call request to obtain designated data, the designated data including the ip address, request header, or request parameter of the user terminal;
    一起灰度策略获取单元,用于获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略;A gray-level strategy acquisition unit for acquiring a gray-scale strategy to provide a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing;
    预设范围判断单元,用于判断所述指定数据是否落入所述一起灰度策略的预设范围之内;A preset range judging unit, configured to judge whether the specified data falls within the preset range of the one gray scale strategy;
    灰度策略判断单元,用于若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略;The gray-scale strategy judgment unit is configured to determine whether the current microservice belongs to the preset gray-scale strategy judgment method if the specified data does not fall within the preset range of the gray-scale strategy. Together gray strategy;
    目标微服务判断单元,用于若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;A target microservice judging unit, configured to determine whether the target microservice belongs to the grayscale policy if the current microservice does not belong to the grayscale policy;
    信号连接通道建立单元,用于若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。The signal connection channel establishment unit is configured to, if the target microservice belongs to the gray-scale policy, offload the call request to the gray-scale service instance of the target microservice, and establish a signal connection channel, wherein One end of the signal connection channel is connected to the user terminal, and the other end is connected to the gray-scale service instance of other micro-services in the same gray-scale strategy except for the target micro-service.
  9. 根据权利要求8所述的基于微服务框架的一起灰度装置,其特征在于,所述指定数据为请求头中预先约定位置记载的字符串,所述一起灰度策略限定了多个预设范围,所述预设范围判断单元40,包括:The micro-service framework-based grayscale device according to claim 8, wherein the specified data is a character string recorded in a pre-appointed position in the request header, and the grayscale strategy defines a plurality of preset ranges , The preset range determining unit 40 includes:
    相似度计算子单元,用于根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值;The similarity calculation subunit is configured to calculate the similarity value between the designated data and the preset character string according to a preset similarity algorithm, and determine whether the similarity value is less than a preset similarity threshold;
    关键词获取子单元,用于若所述相似度值不小于预设相似度阈值,则获取所述一起灰度策略中约定的第一版本灰度用户、第二版本灰度用户、…、第n版本灰度用户对应的第一关键词、第二关键词、…、第n关键词,其中所述一起灰度策略预先约定了n个版本的灰度用户;The keyword acquisition subunit is used to acquire the first version grayscale user, the second version grayscale user,..., the first version specified in the one grayscale strategy if the similarity value is not less than the preset similarity threshold value. The first keyword, the second keyword, ..., the nth keyword corresponding to the n-version gray-scale user, wherein the one gray-scale strategy pre-appoints n-version gray-scale users;
    关键词判断子单元,用于判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词;The keyword judgment subunit is used to judge whether the specified data records the first keyword, the second keyword, ... or the nth keyword;
    灰度用记划分子单元,用于若所述指定数据记载有第一关键词、第二关键词、…或者第n关键词,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。The gray scale mark division subunit is used to determine that the specified data falls into the pre-defined gray scale strategy if the specified data contains the first keyword, the second keyword, ... or the nth keyword. Set within the range, and record the user terminal as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
  10. 根据权利要求9所述的基于微服务框架的一起灰度装置,其特征在于,所述相似度计算子单元,包括:The grayscale device based on the microservice framework according to claim 9, wherein the similarity calculation subunit comprises:
    相似度计算模块,用于采用公式:Similarity calculation module, used to adopt formula:
    Figure PCTCN2019117216-appb-100002
    Figure PCTCN2019117216-appb-100002
    计算所述指定数据与预设字符串的相似度值,其中similarity为相似度值,A为所述指定数据的字符频率向量,B为所述预设字符串的字符频率向量,Ai为所述指定数据的第i个字符出现的次数,Bi为所述预设字符串的第i个字符出现的次数;Calculate the similarity value between the specified data and the preset character string, where similarity is the similarity value, A is the character frequency vector of the specified data, B is the character frequency vector of the preset character string, and Ai is the character frequency vector of the specified data. The number of occurrences of the i-th character of the designated data, and Bi is the number of occurrences of the i-th character of the preset character string;
    指定相似度阈值获取模块,用于根据字符串与相似度阈值的对应关系,获取与所述预设字符串对应的指定相似度阈值;A designated similarity threshold acquisition module, configured to acquire a designated similarity threshold corresponding to the preset character string according to the corresponding relationship between the character string and the similarity threshold;
    指定相似度阈值判断模块,用于判断所述相似度值是否小于所述指定相似度阈值。The designated similarity threshold judgment module is used to judge whether the similarity value is less than the designated similarity threshold.
  11. 根据权利要求8所述的基于微服务框架的一起灰度装置,其特征在于,所述预设范围判断单元40,包括:The grayscale device based on the microservice framework according to claim 8, wherein the preset range determining unit 40 comprises:
    编码子单元,用于根据预设的编码方法,将所述用户终端的ip地址、请求头和请求参数编码为矩阵[B1,B2,B3],其中B1为所述ip地址对应的映射值、B2为所述请求头对应的映射值、B3为所述请求参数对应的映射值;The encoding subunit is used to encode the ip address, request header, and request parameters of the user terminal into a matrix [B1, B2, B3] according to a preset encoding method, where B1 is the mapping value corresponding to the ip address, B2 is the mapping value corresponding to the request header, and B3 is the mapping value corresponding to the request parameter;
    指定参数矩阵获取子单元,用于根据预设的灰度策略与参数矩阵的对应关系,获取与所述一起灰度策略对应的指定参数矩阵[C1,C2,C3];The designated parameter matrix acquiring subunit is used to acquire the designated parameter matrix [C1, C2, C3] corresponding to the one gray strategy according to the corresponding relationship between the preset gray strategy and the parameter matrix;
    划分参考指数M获取子单元,用于通过公式:M=||[B1,B2,B3] T[C1,C2,C3]||,计算得到划分参考指数M; The division reference index M is used to obtain the subunit, which is used to calculate the division reference index M through the formula: M=||[B1,B2,B3] T [C1,C2,C3]||;
    数值范围判断子单元,用于判断所述参考指数M是否落入预设的多个数值范围之内;A numerical value range judging subunit for judging whether the reference index M falls within a plurality of preset numerical ranges;
    用户终端划分子单元,用于若所述参考指数M落入预设的多个数值范围之内,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端划分为Am,其中Am指第m版本灰度用户,所述第m版本灰度用户对应于所述参考指数M落入的数值范围。The user terminal divides sub-units for determining that the specified data falls within the preset range of the same gray scale strategy if the reference index M falls within a plurality of preset numerical ranges, and sets all The user terminal is divided into Am, where Am refers to an m-th version of gray-scale user, and the m-th version of gray-scale user corresponds to the numerical range in which the reference index M falls.
  12. 根据权利要求8所述的基于微服务框架的一起灰度装置,其特征在于,所述装置,包括:The grayscale device based on the microservice framework of claim 8, wherein the device comprises:
    调用请求分流单元,用于若所述指定数据落入所述一起灰度策略的预设范围之内,则将所述调用请求分流至所述目标微服务的灰度服务实例;A call request shunting unit, configured to shunt the call request to the gray service instance of the target microservice if the specified data falls within the preset range of the gray-level strategy;
    通信通道建立单元,用于建立通信通道,所述通信通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。The communication channel establishment unit is configured to establish a communication channel, one end of the communication channel is connected to the user terminal, and the other end is connected to the gray level of other microservices in the same gray level strategy except the target microservice Service instance.
  13. 根据权利要求8所述的基于微服务框架的一起灰度装置,其特征在于,微服务具有版本号,所述灰度策略判断单元50,包括:The grayscale device based on the microservice framework according to claim 8, wherein the microservice has a version number, and the grayscale strategy judgment unit 50 includes:
    当前微服务版本号获取子单元,用于若所述指定数据未落入所述一起灰度策略的预设范围之内,则获取所述当前微服务的版本号;The current microservice version number obtaining subunit is configured to obtain the version number of the current microservice if the specified data does not fall within the preset range of the gray-scale strategy;
    灰度策略版本号获取子单元,用于获取所述一起灰度策略中的微服务的版本号;The gray-scale strategy version number obtaining subunit is used to obtain the version number of the microservice in the gray-scale strategy;
    版本号判断子单元,用于判断所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号是否相同;The version number judging subunit is used to judge whether the version number of the current microservice is the same as the version number of the microservice in the same gray-scale strategy;
    一起灰度策略判定子单元,用于若所述当前微服务的版本号与所述一起灰度策略中的微服务的版本号相同,则判定所述当前微服务属于所述一起灰度策略。A gray-scale policy determination subunit is configured to determine that the current micro-service belongs to the gray-scale policy if the version number of the current microservice is the same as the version number of the micro-service in the gray-scale policy.
  14. 根据权利要求8所述的基于微服务框架的一起灰度装置,其特征在于,所述装置,包括:The grayscale device based on the microservice framework of claim 8, wherein the device comprises:
    输出结果获取单元,用于若所述目标微服务不属于所述一起灰度策略,则将所述用户终端输入已经训练完成的基于机器学习模型的灰度再分类模型中运算,从而获得所述灰度再分类模型的输出结果,其中所述输出结果包括灰度用户与非灰度用户;The output result obtaining unit is configured to, if the target microservice does not belong to the gray-level strategy, input the user terminal into the already-trained gray-level reclassification model based on the machine learning model for calculation, thereby obtaining the The output result of the gray-scale reclassification model, where the output result includes gray-scale users and non-gray-scale users;
    灰度服务实例分流单元,用于若所述输出结果为灰度用户,则将所述调用请求分流至所述目标微服务的灰度服务实例;A gray-scale service instance offloading unit, configured to offload the call request to the gray-scale service instance of the target microservice if the output result is a gray-scale user;
    非灰度服务实例分流单元,用于若所述输出结果为非灰度用户,则将所述调用请求分流至所述目标微服务的非灰度服务实例。The non-gray-scale service instance distribution unit is configured to distribute the call request to the non-gray-scale service instance of the target microservice if the output result is a non-gray-scale user.
  15. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,其特征在于,所述处理器执行所述计算机程序时实现基于微服务框架的一起灰度方法,所述基于微服务框架的一起灰度方法,包括:A computer device includes a memory and a processor, the memory stores a computer program, and is characterized in that, when the processor executes the computer program, a grayscale method based on a microservice framework is implemented, and the microservice framework is based on a grayscale method. The gray-scale methods include:
    接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务;Receive a call request directed to a target microservice, where the call request is generated by the current microservice of the user terminal, the current microservice and the target microservice do not belong to the same microservice cluster, and the current microservice refers to the current microservice A microservice that maintains a communication connection with the user terminal;
    解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip地址、请求头或者请求参数;Parsing the call request to obtain designated data, where the designated data includes the ip address, request header, or request parameter of the user terminal;
    获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略;Obtaining the gray-scale strategy provides a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing;
    判断所述指定数据是否落入所述一起灰度策略的预设范围之内;Judging whether the specified data falls within the preset range of the one gray scale strategy;
    若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略;If the specified data does not fall within the preset range of the integrated gray-scale strategy, use a preset gray-level strategy judgment method to determine whether the current microservice belongs to the integrated gray-scale strategy;
    若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;If the current microservice does not belong to the gray-scale integration strategy, determining whether the target microservice belongs to the gray-scale integration strategy;
    若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。If the target microservice belongs to the gray-scale policy, then the call request is diverted to the gray-scale service instance of the target microservice, and a signal connection channel is established, wherein one end of the signal connection channel is connected to the The other end of the user terminal is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
  16. 根据权利要求15所述的计算机设备,其特征在于,所述指定数据为请求头中预先约定位置记载的字符串,所述一起灰度策略限定了多个预设范围,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤,包括:The computer device according to claim 15, wherein the specified data is a character string recorded in a pre-appointed position in the request header, the one gray scale strategy defines a plurality of preset ranges, and the judgment of the specified The steps of whether the data falls within the preset range of the one gray-scale strategy include:
    根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值;According to a preset similarity algorithm, calculate a similarity value between the designated data and a preset character string, and determine whether the similarity value is less than a preset similarity threshold;
    若所述相似度值不小于预设相似度阈值,则获取所述一起灰度策略中约定的第一版本灰度用户、第二版本灰度用户、…、第n版本灰度用户对应的第一关键词、第二关键词、…、第n关键词,其中所述一起灰度策略预先约定了n个版本的灰度用户;If the similarity value is not less than the preset similarity threshold, then obtain the first version gray user, the second version gray user,..., the first version gray user corresponding to the nth version gray user agreed in the one gray policy. A keyword, a second keyword, ..., an nth keyword, in which the one grayscale strategy pre-appoints n versions of grayscale users;
    判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词;Determine whether the designated data records the first keyword, the second keyword, ... or the nth keyword;
    若所述指定数据记载有第一关键词、第二关键词、…或者第n关键词,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。If the specified data records the first keyword, the second keyword, ... or the nth keyword, it is determined that the specified data falls within the preset range of the gray-scale strategy, and the user The terminal is recorded as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
  17. 根据权利要求16所述的计算机设备,其特征在于,所述根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值的步骤,包括:The computer device according to claim 16, wherein the similarity value between the designated data and a preset character string is calculated according to a preset similarity algorithm, and it is determined whether the similarity value is less than a preset The steps of similarity threshold include:
    采用公式:Use the formula:
    Figure PCTCN2019117216-appb-100003
    Figure PCTCN2019117216-appb-100003
    计算所述指定数据与预设字符串的相似度值,其中similarity为相似度值,A为所述指定数据的字符频率向量,B为所述预设字符串的字符频率向量,Ai为所述指定数据的第i个字符出现的次数,Bi为所 述预设字符串的第i个字符出现的次数;Calculate the similarity value between the specified data and the preset character string, where similarity is the similarity value, A is the character frequency vector of the specified data, B is the character frequency vector of the preset character string, and Ai is the character frequency vector of the specified data. The number of occurrences of the i-th character of the designated data, and Bi is the number of occurrences of the i-th character of the preset character string;
    根据字符串与相似度阈值的对应关系,获取与所述预设字符串对应的指定相似度阈值;Obtaining the designated similarity threshold corresponding to the preset character string according to the correspondence between the character string and the similarity threshold;
    判断所述相似度值是否小于所述指定相似度阈值。It is determined whether the similarity value is less than the specified similarity threshold.
  18. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现基于微服务框架的一起灰度方法,所述基于微服务框架的一起灰度方法,包括:A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements a grayscale method based on a microservice framework when the computer program is executed by a processor, the grayscale method based on a microservice framework ,include:
    接收指向目标微服务的调用请求,其中所述调用请求通过所述用户终端的当前微服务生成,所述当前微服务与所述目标微服务不属于同一微服务集群,所述当前微服务指当前与所述用户终端保持通信连接的微服务;Receive a call request directed to a target microservice, where the call request is generated by the current microservice of the user terminal, the current microservice and the target microservice do not belong to the same microservice cluster, and the current microservice refers to the current microservice A microservice that maintains a communication connection with the user terminal;
    解析所述调用请求从而得到指定数据,所述指定数据包括用户终端的ip地址、请求头或者请求参数;Parsing the call request to obtain designated data, where the designated data includes the ip address, request header, or request parameter of the user terminal;
    获取灰度策略提供终端提供的一起灰度策略,所述一起灰度策略为指示至少两个微服务集群进行灰度发布的策略;Obtaining the gray-scale strategy provides a gray-scale strategy provided by the terminal, and the gray-scale strategy is a strategy that instructs at least two microservice clusters to perform gray-scale publishing;
    判断所述指定数据是否落入所述一起灰度策略的预设范围之内;Judging whether the specified data falls within the preset range of the one gray scale strategy;
    若所述指定数据未落入所述一起灰度策略的预设范围之内,则通过预设的灰度策略判断方法,判断所述当前微服务是否属于所述一起灰度策略;If the specified data does not fall within the preset range of the integrated gray-scale strategy, use a preset gray-level strategy judgment method to determine whether the current microservice belongs to the integrated gray-scale strategy;
    若所述当前微服务不属于所述一起灰度策略,则判断所述目标微服务是否属于所述一起灰度策略;If the current microservice does not belong to the gray-scale integration strategy, determining whether the target microservice belongs to the gray-scale integration strategy;
    若所述目标微服务属于所述一起灰度策略,则将所述调用请求分流至所述目标微服务的灰度服务实例,并且建立信号连接通道,其中所述信号连接通道一端连接至所述用户终端,另一端连接至所述一起灰度策略中的除所述目标微服务之外的其他微服务的灰度服务实例。If the target microservice belongs to the gray-scale policy, then the call request is diverted to the gray-scale service instance of the target microservice, and a signal connection channel is established, wherein one end of the signal connection channel is connected to the The other end of the user terminal is connected to gray-scale service instances of other micro-services in the same gray-scale strategy except for the target micro-service.
  19. 根据权利要求18所述的计算机可读存储介质,其特征在于,所述指定数据为请求头中预先约定位置记载的字符串,所述一起灰度策略限定了多个预设范围,所述判断所述指定数据是否落入所述一起灰度策略的预设范围之内的步骤,包括:The computer-readable storage medium according to claim 18, wherein the specified data is a character string recorded in a pre-appointed position in the request header, the one gray scale strategy defines a plurality of preset ranges, and the judgment The step of whether the specified data falls within the preset range of the one gray scale strategy includes:
    根据预设的相似度算法,计算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值;According to a preset similarity algorithm, calculate a similarity value between the designated data and a preset character string, and determine whether the similarity value is less than a preset similarity threshold;
    若所述相似度值不小于预设相似度阈值,则获取所述一起灰度策略中约定的第一版本灰度用户、第二版本灰度用户、…、第n版本灰度用户对应的第一关键词、第二关键词、…、第n关键词,其中所述一起灰度策略预先约定了n个版本的灰度用户;If the similarity value is not less than the preset similarity threshold, then obtain the first version gray user, the second version gray user,..., the first version gray user corresponding to the nth version gray user agreed in the one gray policy. A keyword, a second keyword, ..., an nth keyword, in which the one grayscale strategy pre-appoints n versions of grayscale users;
    判断所述指定数据是否记载有第一关键词、第二关键词、…或者第n关键词;Determine whether the designated data records the first keyword, the second keyword, ... or the nth keyword;
    若所述指定数据记载有第一关键词、第二关键词、…或者第n关键词,则判定所述指定数据落入所述一起灰度策略的预设范围之内,并将所述用户终端记为与所述第一关键词、第二关键词、…或者第n关键词对应的版本灰度用户。If the designated data records the first keyword, the second keyword, ... or the nth keyword, it is determined that the designated data falls within the preset range of the gray-scale strategy, and the user The terminal is recorded as a version gray user corresponding to the first keyword, the second keyword, ... or the nth keyword.
  20. 根据权利要求19所述的计算机可读存储介质,其特征在于,所述根据预设的相似度算法,计 算所述指定数据与预设字符串的相似度值,并判断所述相似度值是否小于预设相似度阈值的步骤,包括:The computer-readable storage medium according to claim 19, wherein the similarity value between the designated data and the preset character string is calculated according to a preset similarity algorithm, and it is determined whether the similarity value is Steps that are less than the preset similarity threshold include:
    采用公式:Use the formula:
    Figure PCTCN2019117216-appb-100004
    Figure PCTCN2019117216-appb-100004
    计算所述指定数据与预设字符串的相似度值,其中similarity为相似度值,A为所述指定数据的字符频率向量,B为所述预设字符串的字符频率向量,Ai为所述指定数据的第i个字符出现的次数,Bi为所述预设字符串的第i个字符出现的次数;Calculate the similarity value between the specified data and the preset character string, where similarity is the similarity value, A is the character frequency vector of the specified data, B is the character frequency vector of the preset character string, and Ai is the character frequency vector of the specified data. The number of occurrences of the i-th character of the designated data, and Bi is the number of occurrences of the i-th character of the preset character string;
    根据字符串与相似度阈值的对应关系,获取与所述预设字符串对应的指定相似度阈值;Obtaining the designated similarity threshold corresponding to the preset character string according to the correspondence between the character string and the similarity threshold;
    判断所述相似度值是否小于所述指定相似度阈值。It is determined whether the similarity value is less than the specified similarity threshold.
PCT/CN2019/117216 2019-09-18 2019-11-11 Method and apparatus for achieving simultaneous gray release based on microservice framework, and computer device WO2021051541A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910882733.5A CN110753031B (en) 2019-09-18 2019-09-18 Micro-service-framework-based gray level combining method and device and computer equipment
CN201910882733.5 2019-09-18

Publications (1)

Publication Number Publication Date
WO2021051541A1 true WO2021051541A1 (en) 2021-03-25

Family

ID=69276695

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/117216 WO2021051541A1 (en) 2019-09-18 2019-11-11 Method and apparatus for achieving simultaneous gray release based on microservice framework, and computer device

Country Status (2)

Country Link
CN (1) CN110753031B (en)
WO (1) WO2021051541A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113010438A (en) * 2021-04-27 2021-06-22 口碑(上海)信息技术有限公司 Request message processing system, method and device and electronic equipment
CN113676549A (en) * 2021-09-02 2021-11-19 京东科技信息技术有限公司 Application request distribution method, application gateway, electronic device and storage medium
CN113918237A (en) * 2021-09-23 2022-01-11 广州品唯软件有限公司 Gray scale publishing method, device, equipment and computer readable medium

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111371840B (en) * 2020-02-14 2021-05-11 平安科技(深圳)有限公司 Micro-service deployment method, device, computer equipment and storage medium
CN111371684B (en) * 2020-03-02 2022-08-09 中国邮政储蓄银行股份有限公司 Routing processing method and device and double-activity data center system
CN111580846B (en) * 2020-05-15 2021-02-26 厦门靠谱云股份有限公司 Micro-service gray scale publishing method based on mixed framework
CN111897571A (en) * 2020-08-04 2020-11-06 上海非码网络科技有限公司 Gray scale publishing method and system based on Spring Cloud
CN112202929B (en) * 2020-12-01 2021-03-26 湖南新云网科技有限公司 Service access method, device and equipment in micro-service architecture

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8738746B2 (en) * 2007-11-16 2014-05-27 Oracle International Corporation Configuration management for real-time server
CN108319468A (en) * 2017-01-16 2018-07-24 北京京东尚科信息技术有限公司 Gray scale dissemination method, device, system and electronic equipment
CN109241704A (en) * 2018-07-12 2019-01-18 阿里巴巴集团控股有限公司 The gray scale dissemination method and device of new script
CN109445811A (en) * 2018-09-07 2019-03-08 平安科技(深圳)有限公司 Gray scale dissemination method, device, computer equipment and computer storage medium
CN110046083A (en) * 2018-01-17 2019-07-23 北京京东尚科信息技术有限公司 Automate gray scale dissemination method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070112574A1 (en) * 2003-08-05 2007-05-17 Greene William S System and method for use of mobile policy agents and local services, within a geographically distributed service grid, to provide greater security via local intelligence and life-cycle management for RFlD tagged items
CN1972186B (en) * 2005-11-24 2011-11-09 中国科学院自动化研究所 A mobile identity authentication system and its authentication method
DE102011006151B4 (en) * 2011-03-25 2014-04-30 Siemens Aktiengesellschaft Determining an RF pulse length of a magnetic resonance system optimized with regard to an RF energy parameter

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8738746B2 (en) * 2007-11-16 2014-05-27 Oracle International Corporation Configuration management for real-time server
CN108319468A (en) * 2017-01-16 2018-07-24 北京京东尚科信息技术有限公司 Gray scale dissemination method, device, system and electronic equipment
CN110046083A (en) * 2018-01-17 2019-07-23 北京京东尚科信息技术有限公司 Automate gray scale dissemination method and device
CN109241704A (en) * 2018-07-12 2019-01-18 阿里巴巴集团控股有限公司 The gray scale dissemination method and device of new script
CN109445811A (en) * 2018-09-07 2019-03-08 平安科技(深圳)有限公司 Gray scale dissemination method, device, computer equipment and computer storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113010438A (en) * 2021-04-27 2021-06-22 口碑(上海)信息技术有限公司 Request message processing system, method and device and electronic equipment
CN113676549A (en) * 2021-09-02 2021-11-19 京东科技信息技术有限公司 Application request distribution method, application gateway, electronic device and storage medium
CN113918237A (en) * 2021-09-23 2022-01-11 广州品唯软件有限公司 Gray scale publishing method, device, equipment and computer readable medium

Also Published As

Publication number Publication date
CN110753031B (en) 2022-03-18
CN110753031A (en) 2020-02-04

Similar Documents

Publication Publication Date Title
WO2021051541A1 (en) Method and apparatus for achieving simultaneous gray release based on microservice framework, and computer device
CN111695697B (en) Multiparty joint decision tree construction method, equipment and readable storage medium
CN109582793B (en) Model training method, customer service system, data labeling system and readable storage medium
CN110798502B (en) Grayscale publishing method and device based on micro-service framework and computer equipment
CN111046035B (en) Data automation processing method, system, computer equipment and readable storage medium
CN111917878B (en) Message processing method, device, equipment and storage medium
WO2022227388A1 (en) Log anomaly detection model training method, apparatus and device
ZA200100687B (en) Transaction recognition and prediction using regular expressions.
US11876909B2 (en) Verification system and method for chaining data
CN110717088A (en) Electronic document-based device management method, apparatus, device and storage medium
CN114676444B (en) Storage system based on block chain
CN113746679A (en) Cross-subdomain communication operation and maintenance method, total operation and maintenance server and medium
CN111475562B (en) Data format optimization method applied to business processing system and business server
CN110472109B (en) Dynamic data quality analysis method and platform system
CN114006928B (en) Internet of things data processing method based on multi-protocol real-time communication
CN108595330A (en) A kind of application testing method and device
CN114265957A (en) Multiple data source combined query method and system based on graph database
CN112069377A (en) Session information data processing method and device, computer equipment and storage medium
CN111026972B (en) Subscription data pushing method, device, equipment and storage medium in Internet of things
CN1567829A (en) General purpose data file conversion method
CN112445902A (en) Method for identifying user intention in multi-turn conversation and related equipment
CN113256133B (en) Conference summary management method, device, computer equipment and storage medium
CN112511352A (en) User management method and system
CN111382285A (en) Digital library data management system and management method thereof
CN115484560B (en) Intelligent short message processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19945735

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19945735

Country of ref document: EP

Kind code of ref document: A1