Micro-service gray level publishing method and device

文档序号:1963494 发布日期:2021-12-14 浏览:22次 中文

阅读说明:本技术 微服务灰度发布方法及装置 (Micro-service gray level publishing method and device ) 是由 秦小飞 郭剑霓 曾琳铖曦 吴海英 蒋宁 于 2021-09-17 设计创作,主要内容包括:本申请公开一种微服务灰度发布方法及装置,涉及互联网技术领域。本申请的方法包括:接收目标客户端发送的微服务使用请求,其中,所述微服务使用请求中包含所述目标客户端对应的客户端信息;根据预置规则和所述客户端信息确定所述微服务使用请求对应的目标请求标签;根据所述目标请求标签确定所述微服务使用请求对应的目标实例标签,并根据所述目标实例标签确定所述微服务使用请求对应的目标服务器;将所述微服务使用请求转发至所述目标服务器。(The application discloses a micro-service gray scale publishing method and device, and relates to the technical field of internet. The method of the present application comprises: receiving a micro-service using request sent by a target client, wherein the micro-service using request comprises client information corresponding to the target client; determining a target request label corresponding to the micro-service use request according to a preset rule and the client information; determining a target instance label corresponding to the micro-service using request according to the target request label, and determining a target server corresponding to the micro-service using request according to the target instance label; forwarding the micro-service usage request to the target server.)

1. A micro-service gray scale publishing method is characterized by comprising the following steps:

receiving a micro-service using request sent by a target client, wherein the micro-service using request comprises client information corresponding to the target client;

determining a target request label corresponding to the micro-service use request according to a preset rule and the client information;

determining a target instance label corresponding to the micro-service using request according to the target request label, and determining a target server corresponding to the micro-service using request according to the target instance label;

forwarding the micro-service usage request to the target server.

2. The method of claim 1, wherein prior to said receiving the request for microservice usage sent by the target client, the method comprises:

setting an instance tag corresponding to each version micro-service instance, and setting a request tag corresponding to each instance tag;

storing the mapping relation between each instance label and the corresponding request label into a local storage space;

the determining a target instance tag corresponding to the micro-service application request according to the target request tag includes:

and determining a target instance label corresponding to the micro-service application request according to the mapping relation and the target request label.

3. The method of claim 1, wherein the determining a target server corresponding to the microservice usage request according to the target instance tag comprises:

obtaining server information corresponding to each server in a server cluster at a micro-service registry, wherein the server information comprises: metadata corresponding to the server;

determining the micro-service instance operated by each server according to the metadata corresponding to each server;

and selecting the target server from the plurality of servers according to the target instance label and the micro-service instance operated by each server.

4. The method of claim 3, wherein the server information corresponding to the server further comprises: the IP address and the port number corresponding to the server; the forwarding the micro-service usage request to the target server, comprising:

and forwarding the micro-service using request to the target server according to the IP address and the port number corresponding to the target server.

5. The method of claim 2, wherein the client information is: the preset rule is specifically that the unique identity corresponding to the target client is as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the N-th digit of the unique identity, wherein N is a positive integer less than or equal to the number of digits contained in the unique identity.

6. The method of claim 2, wherein the client information is: the preset rule of the IP address corresponding to the target client is specifically as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the Mth digit of the IP address, wherein M is a positive integer less than or equal to the number of digits contained in the IP address.

7. The method of claim 2, wherein the client information is: the preset rule is specifically that the user name corresponding to the target client is: and determining a target request label corresponding to the micro-service application request according to the number of the characters contained in the request labels and the user name.

8. A microservice grayscale issuing apparatus, the apparatus comprising:

the system comprises a receiving unit, a sending unit and a receiving unit, wherein the receiving unit is used for receiving a micro-service using request sent by a target client, and the micro-service using request comprises client information corresponding to the target client;

the first determining unit is used for determining a target request label corresponding to the micro-service using request according to a preset rule and the client information;

a second determining unit, configured to determine, according to the target request tag, a target instance tag corresponding to the micro-service usage request;

a third determining unit, configured to determine, according to the target instance tag, a target server corresponding to the micro-service usage request;

a forwarding unit, configured to forward the micro-service usage request to the target server.

9. A storage medium, characterized in that the storage medium comprises a stored program, wherein when the program runs, a device where the storage medium is located is controlled to execute the micro-service gray scale publishing method according to any one of claims 1 to 7.

10. A micro-service grayscale publication apparatus, characterized in that the apparatus comprises a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions when executed perform the micro-service grayscale publication method of any one of claims 1 to 7.

Technical Field

The application relates to the technical field of cloud computing, in particular to a micro-service gray scale publishing method and device.

Background

At present, when version updating is performed on micro-service application, a gray scale release mode is usually adopted for updating, and the specific process is as follows: part of servers in the server cluster run micro service instances of the new version (namely, grayscale micro service instances), and part of servers run micro service instances of the old version (namely, normal micro service instances); the server cluster receives a micro-service use request sent by a client, determines whether the client is allowed to use a normal micro-service application or a gray scale micro-service application, namely determines whether the received micro-service use request is forwarded to a server running a normal micro-service instance or forwards the received micro-service use request to the server running a gray scale micro-service instance.

In the process of updating the version of the microservice application by adopting a gray scale release mode, how to reasonably forward microservice use requests is crucial.

Disclosure of Invention

The embodiment of the application provides a micro-service gray scale release method and device, and mainly aims to reasonably forward a micro-service use request in the process of updating the version of a micro-service application by adopting a gray scale release mode.

In order to solve the above technical problem, an embodiment of the present application provides the following technical solutions:

in a first aspect, the present application provides a method for issuing a micro-service grayscale, including:

receiving a micro-service using request sent by a target client, wherein the micro-service using request comprises client information corresponding to the target client;

determining a target request label corresponding to the micro-service use request according to a preset rule and the client information;

determining a target instance label corresponding to the micro-service using request according to the target request label, and determining a target server corresponding to the micro-service using request according to the target instance label;

forwarding the micro-service usage request to the target server.

Optionally, before the receiving the micro-service usage request sent by the target client, the method includes:

setting an instance tag corresponding to each version micro-service instance, and setting a request tag corresponding to each instance tag;

storing the mapping relation between each instance label and the corresponding request label into a local storage space;

the determining a target instance tag corresponding to the micro-service application request according to the target request tag includes:

and determining a target instance label corresponding to the micro-service application request according to the mapping relation and the target request label.

Optionally, the determining, according to the target instance tag, a target server corresponding to the micro service usage request includes:

obtaining server information corresponding to each server in a server cluster at a micro-service registry, wherein the server information comprises: metadata corresponding to the server;

determining the micro-service instance operated by each server according to the metadata corresponding to each server;

and selecting the target server from the plurality of servers according to the target instance label and the micro-service instance operated by each server.

Optionally, the server information corresponding to the server further includes: the IP address and the port number corresponding to the server; the forwarding the micro-service usage request to the target server, comprising:

and forwarding the micro-service using request to the target server according to the IP address and the port number corresponding to the target server.

Optionally, the client information is: the preset rule is specifically that the unique identity corresponding to the target client is as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the N-th digit of the unique identity, wherein N is a positive integer less than or equal to the number of digits contained in the unique identity.

Optionally, the client information is: the preset rule of the IP address corresponding to the target client is specifically as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the Mth digit of the IP address, wherein M is a positive integer less than or equal to the number of digits contained in the IP address.

Optionally, the client information is: the preset rule is specifically that the user name corresponding to the target client is: and determining a target request label corresponding to the micro-service application request according to the number of the characters contained in the request labels and the user name.

In a second aspect, the present application further provides a micro-service gray scale publishing device, including:

the system comprises a receiving unit, a sending unit and a receiving unit, wherein the receiving unit is used for receiving a micro-service using request sent by a target client, and the micro-service using request comprises client information corresponding to the target client;

the first determining unit is used for determining a target request label corresponding to the micro-service using request according to a preset rule and the client information;

a second determining unit, configured to determine, according to the target request tag, a target instance tag corresponding to the micro-service usage request;

a third determining unit, configured to determine, according to the target instance tag, a target server corresponding to the micro-service usage request;

a forwarding unit, configured to forward the micro-service usage request to the target server.

Optionally, the apparatus further comprises:

the setting unit is used for setting an instance label corresponding to each version micro-service instance and setting a request label corresponding to each instance label before the receiving unit receives the micro-service using request sent by the target client;

the storage unit is used for storing the mapping relation between each instance label and the corresponding request label into a local storage space;

the second determining unit is specifically configured to determine, according to the mapping relationship and the target request tag, a target instance tag corresponding to the micro-service usage request.

Optionally, the third determining unit includes:

an obtaining module, configured to obtain, at a microservice registry, server information corresponding to each server in a server cluster, where the server information includes: metadata corresponding to the server;

the determining module is used for determining the micro-service instance operated by each server according to the metadata corresponding to each server;

and the selecting module is used for selecting the target server from the plurality of servers according to the target instance label and the micro-service instance operated by each server.

Optionally, the server information corresponding to the server further includes: the IP address and the port number corresponding to the server;

the forwarding unit is specifically configured to forward the micro-service usage request to the target server according to the IP address and the port number corresponding to the target server.

Optionally, the client information is: the preset rule is specifically that the unique identity corresponding to the target client is as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the N-th digit of the unique identity, wherein N is a positive integer less than or equal to the number of digits contained in the unique identity.

Optionally, the client information is: the preset rule of the IP address corresponding to the target client is specifically as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the Mth digit of the IP address, wherein M is a positive integer less than or equal to the number of digits contained in the IP address.

Optionally, the client information is: the preset rule is specifically that the user name corresponding to the target client is: and determining a target request label corresponding to the micro-service application request according to the number of the characters contained in the request labels and the user name.

In a third aspect, an embodiment of the present application provides a storage medium, where the storage medium includes a stored program, and when the program runs, a device in which the storage medium is located is controlled to execute the micro-service grayscale publishing method according to the first aspect.

In a fourth aspect, embodiments of the present application provide a micro-service grayscale publication apparatus, including a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions execute the method for issuing grayscale of micro-service according to the first aspect when running.

By means of the technical scheme, the technical scheme provided by the application at least has the following advantages:

the application provides a method and a device for releasing micro-service gray scale, which can determine a target request label corresponding to a micro-service use request according to a preset rule and client information which is contained in the micro-service use request and corresponds to a target client after receiving the micro-service use request sent by the target client; determining a target instance label corresponding to the micro-service use request according to a target request label corresponding to the micro-service use request and a mapping relation between each instance label and the corresponding request label, which is recorded in advance, and determining a server running the micro-service instance corresponding to the target instance label as a target server; finally, the micro-service usage request is forwarded to the target server so that the target client can use the micro-service instance running in the target server. According to the method and the device, the request label can be reasonably distributed to the micro-service using request sent by the target client according to the preset rule and the client information corresponding to the target client, and the micro-service using request is forwarded to the corresponding server based on the request label distributed to the micro-service using request, so that the micro-service using request can be reasonably forwarded in the process of updating the version of the micro-service application in a gray scale publishing mode.

The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.

Drawings

The above and other objects, features and advantages of exemplary embodiments of the present application will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present application are illustrated by way of example and not by way of limitation in the figures of the accompanying drawings and in which like reference numerals refer to similar or corresponding parts and in which:

fig. 1 shows a flowchart of a method for publishing a micro-service gray scale according to an embodiment of the present application;

FIG. 2 is a flowchart illustrating another method for issuing a grayscale for microservice according to an embodiment of the present disclosure;

fig. 3 is a schematic diagram illustrating an architecture of a server cluster according to an embodiment of the present application;

fig. 4 is a flowchart illustrating an ALB program forwarding a micro-service usage request according to an embodiment of the present application;

fig. 5 is a block diagram illustrating a micro-service grayscale publishing device provided by an embodiment of the present application;

fig. 6 shows a block diagram of another microservice grayscale issuing device provided in the embodiment of the present application.

Detailed Description

Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

It is to be noted that, unless otherwise specified, technical or scientific terms used herein shall have the ordinary meaning as understood by those skilled in the art to which this application belongs.

In the related art, when a micro-service application is version-updated by means of gray-scale publishing, how to forward a micro-service usage request of a client is generally determined by the following two ways: (1) deploying a section of code in a client in advance, and determining whether a micro-service use request sent by the client is forwarded to a server running a normal micro-service instance or a server running a gray micro-service instance according to the section of code; (2) and determining whether the received micro-service use request is forwarded to a server running a normal micro-service instance or a server running a gray micro-service instance by a gateway of the server cluster.

However, (1) the code is deployed in the client, so that the original service code of the client is intrusive, and the complexity of the code of the client is improved; (2) the gateway of the server cluster controls and forwards the control granularity of the micro-service use request, and the forwarding flexibility is low.

In view of the problems existing in two ways of forwarding requests for micro-services in the related art, an embodiment of the present application provides a method for issuing grayscale for micro-services, as shown in fig. 1, where the method includes:

101. and receiving a micro-service use request sent by a target client.

The target client is a client that needs to use the microservice application, the microservice application request sent by the target client includes client information corresponding to the target client, and the client information corresponding to the target client may include, but is not limited to: any one of information such as unique identity, IP address and user name corresponding to the target client; in the embodiment of the present invention, an execution subject in each step is an ALB (Application Load Balancer) program, and the ALB program has a network forwarding function.

In the embodiment of the application, when the target client needs to use the micro-service application, the micro-service application request containing the client information of the target client is sent to the ALB program, and at the moment, the ALB program can receive and obtain the micro-service application request sent by the target client.

102. And determining a target request label corresponding to the micro-service use request according to a preset rule and the client information.

The target request tag corresponding to the micro-service application request sent by the target client is used for uniquely identifying the micro-service application request, and the preset rule is specifically determined according to the number of the instances version corresponding to the micro-service application, for example, the micro-service application includes three versions of instances: the method comprises the following steps that a normal micro-service instance, a gray scale micro-service instance A and a gray scale micro-service instance B are set, an instance label corresponding to each micro-service instance is set, namely the instance label corresponding to the normal micro-service instance is set as an instance label a, the instance label corresponding to the gray scale micro-service instance A is set as an instance label B, the instance label corresponding to the gray scale micro-service instance B is set as an instance label c, and then a request label corresponding to each instance label is set, namely the request label corresponding to the instance label a is set as a request label a, the request label corresponding to the instance label B is set as a request label B, and the request label corresponding to the instance label c is set as a request label c; when the client information included in the micro-service usage request is the unique identity corresponding to the target client, the preset rule may specifically be set as: when the last bit of the unique identity corresponding to the target client is greater than or equal to 0 and less than 3, the request tag a is determined as a target request tag corresponding to the micro-service use request, when the last bit of the unique identity corresponding to the target client is greater than or equal to 3 and less than 6, the request tag b is determined as a target request tag corresponding to the micro-service use request, and when the last bit of the unique identity corresponding to the target client is greater than or equal to 6 and less than or equal to 9, the request tag c is determined as a target request tag corresponding to the micro-service use request.

In the embodiment of the application, after receiving and obtaining the micro-service use request sent by the target client, the ALB program may determine the target request tag corresponding to the micro-service use request according to the preset rule and the client information corresponding to the target client.

103. And determining a target instance label corresponding to the micro-service using request according to the target request label, and determining a target server corresponding to the micro-service using request according to the target instance label.

In the embodiment of the application, because the ALB program sets the instance tag corresponding to each version of the microservice instance of the microservice application first, and then sets the request tag corresponding to each instance tag, the ALB program records the mapping relationship between each instance tag and the corresponding request tag, so that after the target request tag corresponding to the microservice use request is determined, the target instance tag corresponding to the microservice use request can be determined according to the target request tag corresponding to the microservice use request and the recorded mapping relationship, wherein the plurality of request tags are respectively used for uniquely identifying the microservice use request containing different client information, and the instance tag corresponding to any version microservice instance is used for uniquely identifying the version microservice instance; moreover, because the instance tag is used for identifying the micro-service instance, according to the target instance tag corresponding to the micro-service usage request, the target server corresponding to the micro-service usage request can be determined, that is, the server running the micro-service instance corresponding to the target instance tag is determined as the target server.

104. The microservice usage request is forwarded to the target server.

In the embodiment of the application, after determining the target server corresponding to the micro-service use request, the ALB program can forward the micro-service use request to the target server, so that the target client can use the micro-service instance running in the target server.

The embodiment of the application provides a micro-service gray scale release method, and the method can determine a target request label corresponding to a micro-service use request according to a preset rule and client information which is contained in the micro-service use request and corresponds to a target client by an ALB program after the ALB program receives the micro-service use request sent by the target client; determining a target instance label corresponding to the micro-service use request according to a target request label corresponding to the micro-service use request and a mapping relation between each instance label and the corresponding request label, which is recorded in advance, and determining a server running the micro-service instance corresponding to the target instance label as a target server; finally, the micro-service usage request is forwarded to the target server so that the target client can use the micro-service instance running in the target server. In the embodiment of the application, the ALB program can reasonably allocate the request tag to the micro-service usage request sent by the target client according to the preset rule and the client information corresponding to the target client, and forward the micro-service usage request to the corresponding server based on the request tag allocated to the micro-service usage request, so that the ALB program can reasonably forward the micro-service usage request in the process of updating the version of the micro-service application by adopting a gray-scale publishing manner.

To explain in more detail below, an embodiment of the present application provides another method for publishing a microservice grayscale, specifically as shown in fig. 2, where the method includes:

201. setting an instance tag corresponding to each version micro-service instance, setting a request tag corresponding to each instance tag, and storing the mapping relation between each instance tag and the corresponding request tag in a local storage space.

In this embodiment of the application, the AL B program needs to preset an instance tag corresponding to each version of the microservice instance of the microservice application, then set a request tag corresponding to each instance tag, and store a mapping relationship between each instance tag and its corresponding request tag in a local storage space, so that after receiving a microservice usage request sent by a target client, a request tag is allocated to the microservice usage request according to a preset rule, and then according to the stored mapping relationship, an instance tag corresponding to the microservice usage request is determined, that is, which version of the microservice instance can be used by the target client is determined.

202. And receiving a micro-service use request sent by a target client.

For step 202, the description of the corresponding part in fig. 1 may be referred to for receiving the micro-service usage request sent by the target client, and details of the embodiment of the present invention will not be described here.

203. And determining a target request label corresponding to the micro-service use request according to a preset rule and the client information.

In the embodiment of the application, after receiving and obtaining the micro-service use request sent by the target client, the ALB program may determine the target request tag corresponding to the micro-service use request according to the preset rule and the client information corresponding to the target client.

When the client information contained in the micro-service use request is the unique identity corresponding to the target client, the preset rule is specifically as follows: determining a target request label corresponding to the microservice using request according to a plurality of preset request labels and the Nth digit of the unique identity corresponding to the target client, wherein N is a positive integer less than or equal to the number of digits contained in the unique identity; when the client information contained in the micro-service use request is the IP address corresponding to the target client, the preset rule is specifically as follows: determining a target request label corresponding to the micro-service use request according to a plurality of preset request labels and the Mth digit of the IP address corresponding to the target client, wherein M is a positive integer less than or equal to the number of digits contained in the IP address; when the client information contained in the micro-service use request is the user name corresponding to the target client, the preset rule is specifically as follows: and determining a target request label corresponding to the micro-service use request according to a plurality of preset request labels and the number of characters contained in the user name corresponding to the target client.

For example, a microservice application contains four versions of instances: setting an example label corresponding to each micro service example, namely setting the example label corresponding to the normal micro service example as an example label a, setting the example label corresponding to the gray micro service example A as an example label B, setting the example label corresponding to the gray micro service example B as an example label C, setting the example label corresponding to the gray micro service example C as an example label d, and then setting a request label corresponding to each example label, namely setting the request label corresponding to the example label a as a request label a, setting the request label corresponding to the example label B as a request label B, setting the request label corresponding to the example label C as a request label C, and setting the request label corresponding to the example label d as a request label d;

when the client information included in the micro-service usage request is the unique identity corresponding to the target client, the preset rule may be set as: when the last bit of the unique identifier corresponding to the target client is greater than or equal to 0 and less than 2, determining the request tag a as a target request tag corresponding to the microservice usage request, when the last bit of the unique identifier corresponding to the target client is greater than or equal to 2 and less than 5, determining the request tag b as a target request tag corresponding to the microservice usage request, when the last bit of the unique identifier corresponding to the target client is greater than or equal to 5 and less than 7, determining the request tag c as a target request tag corresponding to the microservice usage request, and when the last bit of the unique identifier corresponding to the target client is greater than or equal to 7 and less than or equal to 9, determining the request tag d as a target request tag corresponding to the microservice usage request, the preset rule may also be set as: when the third bit of the unique identity corresponding to the target client is greater than or equal to 0 and less than 2, determining the request tag a as a target request tag corresponding to the micro-service use request, when the third bit of the unique identity corresponding to the target client is greater than or equal to 2 and less than 5, determining the request tag b as a target request tag corresponding to the micro-service use request, when the third bit of the unique identity corresponding to the target client is greater than or equal to 5 and less than 7, determining the request tag c as a target request tag corresponding to the micro-service use request, and when the third bit of the unique identity corresponding to the target client is greater than or equal to 7 and less than or equal to 9, determining the request tag d as a target request tag corresponding to the micro-service use request;

when the client information included in the micro-service use request is the IP address corresponding to the target client, the preset rule may be set as: when the last bit of the IP address corresponding to the target client is greater than or equal to 0 and less than 2, determining the request tag a as a target request tag corresponding to the microservice usage request, when the last bit of the IP address corresponding to the target client is greater than or equal to 2 and less than 5, determining the request tag b as a target request tag corresponding to the microservice usage request, when the last bit of the IP address corresponding to the target client is greater than or equal to 5 and less than 7, determining the request tag c as a target request tag corresponding to the microservice usage request, and when the last bit of the IP address corresponding to the target client is greater than or equal to 7 and less than or equal to 9, determining the request tag d as a target request tag corresponding to the microservice usage request, the preset rule may be further set as: when the fifth bit of the IP address corresponding to the target client is greater than or equal to 0 and less than 2, determining the request tag a as a target request tag corresponding to the micro service use request, when the fifth bit of the IP address corresponding to the target client is greater than or equal to 2 and less than 5, determining the request tag b as a target request tag corresponding to the micro service use request, when the fifth bit of the IP address corresponding to the target client is greater than or equal to 5 and less than 7, determining the request tag c as a target request tag corresponding to the micro service use request, and when the fifth bit of the IP address corresponding to the target client is greater than or equal to 7 and less than or equal to 9, determining the request tag d as a target request tag corresponding to the micro service use request;

when the client information included in the micro-service use request is the user name corresponding to the target client, the preset rule may be set as: when the user name corresponding to the target client contains characters, the request label a is determined as a target request label corresponding to the micro-service use request, when the user name corresponding to the target client contains characters, the number of the characters is more than 2 and less than or equal to 5, the request label b is determined as a target request label corresponding to the micro-service use request, when the user name corresponding to the target client contains characters, the number of the characters is more than 5 and less than or equal to 7, the request label c is determined as a target request label corresponding to the micro-service use request, and when the user name corresponding to the target client contains characters, the number of the characters is more than 7, the request label d is determined as a target request label corresponding to the micro-service use request.

204. And determining a target instance label corresponding to the micro-service use request according to the mapping relation and the target request label.

In the embodiment of the present application, after determining the target request tag corresponding to the microservice usage request, the ALB program may determine the target instance tag corresponding to the microservice usage request according to the target request tag corresponding to the microservice usage request and the mapping relationship stored in the local storage space in step 201.

205. And determining a target server corresponding to the micro-service use request according to the target instance label.

In the embodiment of the application, after determining the target instance tag corresponding to the microservice usage request, the ALB program may determine the target server corresponding to the microservice usage request according to the target instance tag corresponding to the microservice usage request.

Specifically, in this step, the ALB program may determine the target server corresponding to the microservice usage request according to the target instance tag corresponding to the microservice usage request in the following manner:

first, Server information corresponding to each Server in a Server cluster is acquired at a micro service registry (ES, Eureka Server), wherein the Server information corresponding to the Server includes: the metadata corresponding to the server is recorded with the version information of the micro service instance operated by the server, and the version information of the micro service instance operated by the server can be determined according to the version information of the micro service instance operated by the server;

secondly, determining the micro-service instance operated by each server according to the metadata corresponding to each server, namely determining the micro-service instance operated by each server according to the version information recorded in the metadata corresponding to each server;

finally, according to the target instance tag corresponding to the micro-service application request and the micro-service instance operated by each server, selecting the target server from the plurality of servers, namely determining the server operating the micro-service instance corresponding to the target instance tag as the target server, for example, the micro-service application comprises three versions of instances: the method comprises the steps of setting an instance label corresponding to a normal micro-service instance as an instance label a, an instance label corresponding to a gray micro-service instance A as an instance label B, and an instance label corresponding to a gray micro-service instance B as an instance label c in advance, determining a target instance label corresponding to a micro-service use request as an instance label a according to the steps, and determining that a server 1-a server 10 in a server cluster operates the normal micro-service instance, a server 11-a server 20 operates the gray micro-service instance A, and a server 21-a server 30 in the server cluster operates the gray micro-service instance B, so that any one of the servers 1-the server 10 can be determined as a target server.

In the actual application process, when there are multiple servers running micro service instances corresponding to target instance tags, any one of the servers may be determined as a target server, or a server with the lowest load may be determined as a target server according to the load condition of each server, but the present invention is not limited thereto.

206. The microservice usage request is forwarded to the target server.

Because, in the process of determining the target server corresponding to the microservice usage request according to the target instance tag in step 205, the server information obtained by the ALB program at the microservice registry further includes: therefore, in the embodiment of the application, after determining the target server corresponding to the micro-service use request, the ALB program can forward the micro-service use request to the target server according to the IP address and the port number corresponding to the target server, so that the target client can use the micro-service instance running in the target server.

Illustratively, as shown in fig. 3, a server cluster includes a plurality of servers running a plurality of versions of microservice instances, and an ALB program includes a request forwarding unit; after receiving a micro-service request sent by a certain client, the request forwarding unit in the ALB program may determine a server corresponding to the micro-service request according to the method described in step 203 and 205, and forward the micro-service request to the determined server, where the ALB program may obtain server information corresponding to each server in the server cluster at the micro-service registration center, such as metadata, an IP address, and a port number corresponding to the server.

Illustratively, as shown in FIG. 4, the microservice application contains three versions of instances: the method comprises the following steps of setting an example label corresponding to a normal micro service example as an example label a, an example label corresponding to a gray micro service example A as an example label B, an example label corresponding to a gray micro service example B as an example label c, setting a request label corresponding to the example label a as a request label a, a request label corresponding to the example label B as a request label B, and a request label corresponding to the example label c as a request label c; the preset rules are set as follows: when the last bit of the unique identity corresponding to the target client is greater than or equal to 0 and less than 3, the request tag a is determined as a target request tag corresponding to the micro-service use request, when the last bit of the unique identity corresponding to the target client is greater than or equal to 3 and less than 6, the request tag b is determined as a target request tag corresponding to the micro-service use request, and when the last bit of the unique identity corresponding to the target client is greater than or equal to 6 and less than or equal to 9, the request tag c is determined as a target request tag corresponding to the micro-service use request. After receiving and obtaining a micro-service use request sent by a target client, an ALB program firstly extracts client information corresponding to the target client, namely a unique identity corresponding to the target client, from the micro-service use request; secondly, judging whether the last bit of the unique identity corresponding to the target client is more than or equal to 0 and less than 3, if so, determining the request label a as a target request label corresponding to the micro-service use request, determining the example label a as a target example label corresponding to the micro-service use request, forwarding the micro-service use request to a target server (namely, a server running a normal micro-service example), if not, judging whether the last bit of the unique identity corresponding to the target client is more than or equal to 3 and less than 6, if so, determining the request label b as a target request label corresponding to the micro-service use request, determining the example label b as a target example label corresponding to the micro-service use request, and forwarding the micro-service use request to the target server (namely, a server running a gray scale micro-service example A), if not, determining the request label c as a target request label corresponding to the micro-service use request, determining the instance label c as a target instance label corresponding to the micro-service use request, and forwarding the micro-service use request X to a target server (namely, a server running the gray scale micro-service instance B).

In order to achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a storage medium, where the storage medium includes a stored program, and when the program runs, a device on which the storage medium is located is controlled to execute the above-mentioned micro-service grayscale publishing method.

In order to achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a micro-service grayscale issuing device, which includes a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; and when the program instruction runs, the micro-service gray scale issuing method is executed.

Further, as an implementation of the method shown in fig. 1 and fig. 2, another embodiment of the present application further provides a micro-service grayscale issuing apparatus. The embodiment of the apparatus corresponds to the embodiment of the method, and for convenience of reading, details in the embodiment of the apparatus are not repeated one by one, but it should be clear that the apparatus in the embodiment can correspondingly implement all the contents in the embodiment of the method. The device is applied to reasonably forwarding the micro-service use request in the process of updating the version of the micro-service application by adopting a gray scale release mode, and specifically as shown in fig. 5, the device comprises:

a receiving unit 31, configured to receive a micro-service usage request sent by a target client, where the micro-service usage request includes client information corresponding to the target client;

a first determining unit 32, configured to determine, according to a preset rule and the client information, a target request tag corresponding to the microservice usage request;

a second determining unit 33, configured to determine, according to the target request tag, a target instance tag corresponding to the micro-service usage request;

a third determining unit 34, configured to determine, according to the target instance tag, a target server corresponding to the micro service usage request;

a forwarding unit 35, configured to forward the micro-service usage request to the target server.

Further, as shown in fig. 6, the apparatus further includes:

a setting unit 36, configured to set an instance tag corresponding to each version microservice instance and set a request tag corresponding to each instance tag before the receiving unit 31 receives the microservice usage request sent by the target client;

a storage unit 37, configured to store a mapping relationship between each instance tag and its corresponding request tag in a local storage space;

the second determining unit 33 is specifically configured to determine, according to the mapping relationship and the target request tag, a target instance tag corresponding to the micro-service usage request.

Further, as shown in fig. 6, the third determination unit 34 includes:

an obtaining module 341, configured to obtain, at a micro service registry, server information corresponding to each server in a server cluster, where the server information includes: metadata corresponding to the server;

a determining module 342, configured to determine, according to the metadata corresponding to each server, a micro-service instance executed by each server;

a selecting module 343, configured to select, according to the target instance tag and the micro-service instance executed by each server, the target server from the servers.

Further, as shown in fig. 6, the server information corresponding to the server further includes: the IP address and the port number corresponding to the server;

the forwarding unit 35 is specifically configured to forward the micro-service usage request to the target server according to the IP address and the port number corresponding to the target server.

Further, as shown in fig. 6, the client information is: the preset rule is specifically that the unique identity corresponding to the target client is as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the N-th digit of the unique identity, wherein N is a positive integer less than or equal to the number of digits contained in the unique identity.

Further, as shown in fig. 6, the client information is: the preset rule of the IP address corresponding to the target client is specifically as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the Mth digit of the IP address, wherein M is a positive integer less than or equal to the number of digits contained in the IP address.

Further, as shown in fig. 6, the client information is: the preset rule is specifically that the user name corresponding to the target client is: and determining a target request label corresponding to the micro-service application request according to the number of the characters contained in the request labels and the user name.

The embodiment of the application provides a method and a device for releasing micro-service gray scale, and the method and the device can determine a target request label corresponding to a micro-service use request according to a preset rule and client information which is contained in the micro-service use request and corresponds to a target client by an ALB program after the ALB program receives the micro-service use request sent by the target client; determining a target instance label corresponding to the micro-service use request according to a target request label corresponding to the micro-service use request and a mapping relation between each instance label and the corresponding request label, which is recorded in advance, and determining a server running the micro-service instance corresponding to the target instance label as a target server; finally, the micro-service usage request is forwarded to the target server so that the target client can use the micro-service instance running in the target server. In the embodiment of the application, the ALB program can reasonably allocate the request tag to the micro-service usage request sent by the target client according to the preset rule and the client information corresponding to the target client, and forward the micro-service usage request to the corresponding server based on the request tag allocated to the micro-service usage request, so that the ALB program can reasonably forward the micro-service usage request in the process of updating the version of the micro-service application by adopting a gray-scale publishing manner.

The micro-service gray scale release device comprises a processor and a memory, wherein the receiving unit, the first determining unit, the second determining unit, the third determining unit, the forwarding unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.

The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the micro-service use request is reasonably forwarded in the process of updating the version of the micro-service application in a gray release mode by adjusting the kernel parameters.

The embodiment of the application provides a storage medium, which comprises a stored program, wherein when the program runs, a device where the storage medium is located is controlled to execute the micro-service gray scale publishing method.

The storage medium may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.

The embodiment of the application also provides a micro-service gray scale publishing device, which comprises a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; and when the program instruction runs, the micro-service gray scale issuing method is executed.

The embodiment of the application provides equipment, the equipment comprises a processor, a memory and a program which is stored on the memory and can run on the processor, and the following steps are realized when the processor executes the program:

receiving a micro-service using request sent by a target client, wherein the micro-service using request comprises client information corresponding to the target client;

determining a target request label corresponding to the micro-service use request according to a preset rule and the client information;

determining a target instance label corresponding to the micro-service using request according to the target request label, and determining a target server corresponding to the micro-service using request according to the target instance label;

forwarding the micro-service usage request to the target server.

Further, before the receiving of the micro-service usage request sent by the target client, the method includes:

setting an instance tag corresponding to each version micro-service instance, and setting a request tag corresponding to each instance tag;

storing the mapping relation between each instance label and the corresponding request label into a local storage space;

the determining a target instance tag corresponding to the micro-service application request according to the target request tag includes:

and determining a target instance label corresponding to the micro-service application request according to the mapping relation and the target request label.

Further, the determining a target server corresponding to the micro-service usage request according to the target instance tag includes:

obtaining server information corresponding to each server in a server cluster at a micro-service registry, wherein the server information comprises: metadata corresponding to the server;

determining the micro-service instance operated by each server according to the metadata corresponding to each server;

and selecting the target server from the plurality of servers according to the target instance label and the micro-service instance operated by each server.

Further, the server information corresponding to the server further includes: the IP address and the port number corresponding to the server; the forwarding the micro-service usage request to the target server, comprising:

and forwarding the micro-service using request to the target server according to the IP address and the port number corresponding to the target server.

Further, the client information is: the preset rule is specifically that the unique identity corresponding to the target client is as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the N-th digit of the unique identity, wherein N is a positive integer less than or equal to the number of digits contained in the unique identity.

Further, the client information is: the preset rule of the IP address corresponding to the target client is specifically as follows: and determining a target request label corresponding to the micro-service use request according to the plurality of request labels and the Mth digit of the IP address, wherein M is a positive integer less than or equal to the number of digits contained in the IP address.

Further, the client information is: the preset rule is specifically that the user name corresponding to the target client is: and determining a target request label corresponding to the micro-service application request according to the number of the characters contained in the request labels and the user name.

The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device: receiving a micro-service using request sent by a target client, wherein the micro-service using request comprises client information corresponding to the target client; determining a target request label corresponding to the micro-service use request according to a preset rule and the client information; determining a target instance label corresponding to the micro-service using request according to the target request label, and determining a target server corresponding to the micro-service using request according to the target instance label; forwarding the micro-service usage request to the target server.

As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.

The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.

The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.

Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.

It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.

As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.

The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种终端用远程升级方法、系统及介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!