CN111651274A - Business distribution method based on micro-service architecture and related device - Google Patents

Business distribution method based on micro-service architecture and related device Download PDF

Info

Publication number
CN111651274A
CN111651274A CN202010499407.9A CN202010499407A CN111651274A CN 111651274 A CN111651274 A CN 111651274A CN 202010499407 A CN202010499407 A CN 202010499407A CN 111651274 A CN111651274 A CN 111651274A
Authority
CN
China
Prior art keywords
load
service
sub
value
level
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202010499407.9A
Other languages
Chinese (zh)
Inventor
赵毅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Yinglou Weixing Information Technology Co ltd
Original Assignee
Chongqing Yinglou Weixing Information Technology Co ltd
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 Chongqing Yinglou Weixing Information Technology Co ltd filed Critical Chongqing Yinglou Weixing Information Technology Co ltd
Priority to CN202010499407.9A priority Critical patent/CN111651274A/en
Publication of CN111651274A publication Critical patent/CN111651274A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources

Abstract

The invention discloses a service distribution method based on a micro-service architecture, which comprises the steps of obtaining service information; calling the current load levels of all sub-service nodes in the target cluster corresponding to the service information; the load grade is matched with the load value of the corresponding sub service node; determining the current processing capacity value of the corresponding sub-service node according to the load grade; arranging the sub-service nodes according to a preset sequence, and determining a distribution interval corresponding to the sub-service nodes according to the processing capacity value; and determining the sub-service node corresponding to the distribution interval in which the random number falls as a target sub-service node, and distributing the service information to the target sub-service node. On the premise of referring to the residual load capacity of the sub-service nodes in the target cluster, the service information is distributed according to the distribution interval in which the random number falls, and the load of each sub-service node can be balanced. The invention also provides a device, equipment and a storage medium, which also have the beneficial effects.

Description

Business distribution method based on micro-service architecture and related device
Technical Field
The present invention relates to the field of micro-service technologies, and in particular, to a micro-service architecture based service distribution method, a micro-service architecture based service distribution apparatus, a micro-service architecture based service distribution device, and a computer-readable storage medium.
Background
With the progress of science and technology and the development of society, the micro service system is more and more widely applied to the daily life of people. Microservice is an emerging software architecture that splits a large single application and service into tens of supporting microservices. A microservice policy may facilitate work by extending individual components rather than the entire application stack to meet service level agreements.
At present, a plurality of sub-service nodes are usually used to form a cluster with specific functions, such as a cluster for implementing a user management function, a cluster for implementing an order service, a cluster for implementing a payment service function, and the like. The above-mentioned clusters do not generally correspond to a physical structure, but rather a logical concept. In the prior art, when a gateway node distributes traffic to sub-service nodes corresponding to the same cluster, the traffic is generally distributed to a plurality of sub-service nodes in a balanced manner. But the resources occupied by different services are different. When the traffic volume is large, the situation that the load of some sub-service nodes exceeds the standard is easily caused. Therefore, the problem to be solved by the technical personnel is urgently needed when the load of each sub service node is balanced.
Disclosure of Invention
The invention aims to provide a service distribution method based on a micro-service architecture, which can balance the load of each sub-service node; another object of the present invention is to provide a micro service architecture-based service distribution apparatus, a micro service architecture-based service distribution device, and a computer-readable storage medium, which can balance the load of each sub service node.
In order to solve the above technical problem, the present invention provides a method for distributing services based on a micro service architecture, which is applied to a gateway node, and comprises:
acquiring service information;
calling the current load levels of all sub-service nodes in the target cluster corresponding to the service information; the load grades comprise a plurality of load grades which are sequentially arranged from low to high; the load grade is matched with the load value of the corresponding sub service node;
determining the current processing capacity value of the corresponding sub service node according to the load grade; the magnitude of the processing capacity value is inversely proportional to the height of the load grade;
arranging the sub-service nodes according to a preset sequence, and determining a distribution interval corresponding to the sub-service nodes according to the processing capacity value; the length of the distribution interval is equal to the processing capacity value; from the second distribution interval to the last distribution interval, the starting value of any distribution interval is equal to the ending value of the previous distribution interval;
generating a random number; the initial value of the value interval of the random number is the initial value of the first distribution interval, and the termination value is the termination value of the last distribution interval;
and determining the sub-service node corresponding to the distribution interval in which the random number falls as a target sub-service node, and distributing the service information to the target sub-service node.
Optionally, the arranging the sub-service nodes according to the preset sequence includes:
arranging the sub-service nodes according to the names of the sub-service nodes; or, arranging the sub service nodes from low to high according to the load levels of the sub service nodes.
Optionally, before invoking the current load levels of all the sub-service nodes in the target cluster corresponding to the service information, the method further includes:
acquiring the current load value and the load grade of the sub service node;
when the current load value is larger than the load upper limit value corresponding to the load level, the load level of the sub service node is increased to the load level corresponding to the current load value;
and when the current load value is smaller than the load lower limit value corresponding to the load grade, reducing the load grade of the sub service node by one grade.
Optionally, the obtaining the current load value of the child service node includes:
acquiring the latest continuous five load values in the sub-service nodes along the time sequence;
calculating an average of five of the load values as the current load value.
Optionally, between two adjacent load classes, the upper load limit value of the low load class is greater than the lower load limit value of the high load class.
Optionally, the load classes include zero-level load, first-level load, second-level load and third-level load; the load capacity value corresponding to the zero-level load is 100, the load capacity value corresponding to the first-level load is 66, the load capacity value corresponding to the second-level load is 33, and the load capacity value corresponding to the third-level load is 0;
the upper load limit value of the zero-level load is 70; the upper limit value of the load of the primary load is 80, and the lower limit value of the load of the primary load is 65; the upper limit value of the load of the secondary load is 90, and the lower limit value of the load of the secondary load is 75; the lower load limit of the tertiary load is 85.
The invention also provides a service distribution device based on the micro-service architecture, which is applied to the gateway node and comprises the following components:
a service acquisition module: the system is used for acquiring service information;
a load level calling module: the load level of all the sub-service nodes in the target cluster corresponding to the service information is called; the load grades comprise a plurality of load grades which are sequentially arranged from low to high; the load grade is matched with the load value of the corresponding sub service node;
a throughput value determination module: the processing capacity value of the corresponding sub service node is determined according to the load grade; the magnitude of the processing capacity value is inversely proportional to the height of the load grade;
a distribution section determination module: the distribution interval is used for arranging the sub-service nodes according to a preset sequence and determining the distribution interval corresponding to the sub-service nodes according to the processing capacity value; the length of the distribution interval is equal to the processing capacity value; from the second distribution interval to the last distribution interval, the starting value of any distribution interval is equal to the ending value of the previous distribution interval;
a random number generation module: for generating a random number; the initial value of the value interval of the random number is the initial value of the first distribution interval, and the termination value of the value interval of the random number is the termination value of the last distribution interval;
a service distribution module: and the sub-service node corresponding to the distribution interval in which the random number falls is determined as a target sub-service node, and the service information is distributed to the target sub-service node.
Optionally, the method further includes:
a load information acquisition module: the load control method comprises the steps of obtaining a current load value and a current load grade of the sub service node;
a load level up-regulation module: the load level of the sub-service node is increased to the load level corresponding to the current load value when the current load value is larger than the load upper limit value corresponding to the current load level;
a load level down-regulation module: and the load level of the sub service node is decreased by one level when the current load value is smaller than the lower limit value of the load corresponding to the current load level.
The invention also provides a service distribution device based on the micro-service architecture, which is applied to the gateway node and comprises the following components:
a memory for storing a computer program;
a processor, configured to implement the steps of the micro service architecture based service distribution method according to any one of the above items when executing the computer program.
The present invention further provides a computer-readable storage medium, applied to a gateway node, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps of the micro service architecture-based service distribution method according to any one of the above.
The invention provides a service distribution method based on a micro-service architecture, which is applied to a gateway node and comprises the steps of obtaining service information; calling the current load levels of all sub-service nodes in the target cluster corresponding to the service information; the load grades comprise a plurality of load grades which are sequentially arranged from low to high; the load grade is matched with the load value of the corresponding sub service node; determining the current processing capacity value of the corresponding sub-service node according to the load grade; the magnitude of the processing capacity value is in inverse proportion to the height of the load grade; arranging the sub-service nodes according to a preset sequence, and determining a distribution interval corresponding to the sub-service nodes according to the processing capacity value; the length of the distribution interval is equal to the processing capacity value; from the second distribution interval to the last distribution interval, the starting value of any distribution interval is equal to the ending value of the previous distribution interval; generating a random number; the initial value of the value interval of the random number is the initial value of the first distribution interval, and the termination value is the termination value of the last distribution interval; and determining the sub-service node corresponding to the distribution interval in which the random number falls as a target sub-service node, and distributing the service information to the target sub-service node.
And determining the processing capacity value, namely the residual load capacity, of each sub-service node according to the load level of the sub-service node corresponding to the target cluster. The distribution interval is generated according to the processing capacity value of each sub-service node, and after the random number is generated, the service information is distributed according to the distribution interval in which the random number falls, so that the service can be randomly distributed to each sub-service node on the premise of considering the load capacity of each sub-service node, the load of each sub-service node is balanced, and the sub-service node can reasonably execute the service.
The invention also provides a micro-service-architecture-based service distribution device, a micro-service-architecture-based service distribution device and a computer-readable storage medium, which also have the beneficial effects and are not repeated herein.
Drawings
In order to more clearly illustrate the embodiments or technical solutions of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
Fig. 1 is a flowchart of a method for distributing services based on a micro service architecture according to an embodiment of the present invention;
fig. 2 is a flowchart of a specific micro service architecture-based service distribution method according to an embodiment of the present invention;
fig. 3 is a block diagram of a service distribution apparatus based on a micro service architecture according to an embodiment of the present invention;
fig. 4 is a block diagram of a service distribution device based on a micro service architecture according to an embodiment of the present invention.
Detailed Description
The core of the invention is to provide a service distribution method based on a micro-service architecture. In the prior art, when a gateway node distributes traffic to sub-service nodes corresponding to the same cluster, the traffic is generally distributed to a plurality of sub-service nodes in a balanced manner. But the resources occupied by different services are different. When the traffic volume is large, the situation that the load of some sub-service nodes exceeds the standard is easily caused.
The micro-service architecture-based service distribution method provided by the invention can determine the processing capacity value, namely the residual load capacity, of each sub-service node according to the load level of the sub-service node corresponding to the target cluster. The distribution interval is generated according to the processing capacity value of each sub-service node, and after the random number is generated, the service information is distributed according to the distribution interval in which the random number falls, so that the service can be randomly distributed to each sub-service node on the premise of considering the load capacity of each sub-service node, the load of each sub-service node is balanced, and the sub-service node can reasonably execute the service.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a service distribution method based on a micro service architecture according to an embodiment of the present invention.
Referring to fig. 1, in the embodiment of the present invention, a service distribution method based on a micro service architecture is applied to a gateway node, and includes:
s101: and acquiring the service information.
In this step, the gateway node may obtain service information sent by an external client, where the service information generally corresponds to a certain target cluster with a specific function in the micro service system, and a sub-service node in the target cluster needs to execute a corresponding service according to the service information. The specific type of the related service information is not specifically limited in the embodiment of the present invention, and is determined according to the specific situation. In the embodiment of the present invention, the service information generally has identification information of a corresponding target cluster, so that the gateway node identifies the target cluster corresponding to the service information.
S102: and calling the current load levels of all the sub-service nodes in the target cluster corresponding to the service information.
In the embodiment of the present invention, the load classes include a plurality of load classes arranged in sequence from low to high; the load level matches the load value of the corresponding child service node. The load level corresponds to the current load value of the sub service node but is not equal to the current load value of the sub service node. In general, the higher the load value of a sub-service node is, the higher the corresponding load level is; the lower the load value level is, the lower the corresponding load level is, and the variation of the load value of the sub service node causes the variation of the load level.
However, it should be emphasized that, in a general situation, the load value of the sub-service node is usually obtained by the gateway node through regular polling in the micro-service system, and the distribution of the service information has randomness, so that the distribution cannot be performed according to the most accurate current load value of the sub-service node when performing the service distribution; in the embodiment of the present invention, when the load value of the sub-service node changes, the load level corresponding to the sub-service node is adjusted, and the distribution is performed specifically according to the load level, so that appropriate fuzziness and generalization of the load of the sub-service node are realized through the load level, which can effectively reduce the calculation amount of the gateway node and increase the service distribution speed. The detailed related contents related to the load level will be described in detail in the following embodiments of the invention, and will not be described herein again.
In the embodiment of the present invention, specifically, how to select a specific sub-service node in a target cluster for service distribution after determining that service information can be distributed to the target cluster is achieved; correspondingly, in this step, the current load levels of all the sub-service nodes in the target cluster corresponding to the service information need to be called, so that the service is distributed in the following steps in combination with the load levels. It should be noted that the load level specific information is typically stored in the gateway node.
S103: and determining the current processing capacity value of the corresponding sub service node according to the load grade.
In the embodiment of the invention, the magnitude of the processing capacity value is inversely proportional to the magnitude of the load grade. The processing capacity value, namely the residual load capacity, the higher the load level of the sub service node is, which means that the lower the residual load capacity is, the lower the processing capacity value is, and vice versa. The corresponding relation between the load grade and the processing capacity value is preset, and the level of the processing capacity value directly reflects the specific service which can be carried by the sub-service node. After determining the current processing capability value of the child service node, the distribution of the service is specifically completed according to the processing capability value in the following steps.
S104: and arranging the sub-service nodes according to a preset sequence, and determining a distribution interval corresponding to the sub-service nodes according to the processing capacity value.
In the embodiment of the present invention, the length of the distribution interval is equal to the processing capability value; from the second distribution interval to the last distribution interval, the starting value of any one distribution interval is equal to the ending value of the previous distribution interval.
In this step, a distribution section corresponding to the processing capacity value is established, and when the sub-service nodes are arranged in the preset order, the distribution section corresponding to the sub-service node is arranged in addition to the sub-service nodes. The determined distribution intervals are usually left-closed and right-open intervals, so that when the target cluster corresponds to a plurality of sub-service nodes, the distribution intervals arranged according to the preset sequence are usually continuous and do not overlap. In the embodiment of the present invention, the starting value of the first distribution interval from the left is usually preset, and the starting value of the first distribution interval is usually zero. Of course, the specific value of the initial starting value is not particularly limited in the embodiments of the present invention, and is determined as the case may be.
Specifically, the step may specifically be: arranging the sub-service nodes according to the names of the sub-service nodes; or, arranging the sub service nodes from low to high according to the load levels of the sub service nodes. That is, in the embodiment of the present invention, the sub-service nodes are arranged according to the preset sequence, that is, the sub-service nodes may be arranged only according to names of the sub-service nodes, or may be arranged according to load levels of the sub-service nodes, which is determined by specific circumstances and is not specifically limited in the embodiment of the present invention.
S105: a random number is generated.
In this embodiment of the present invention, the start value of the value interval of the random number is the start value of the first distribution interval, and the end value is the end value of the last distribution interval. The distribution intervals corresponding to the plurality of sub-service nodes form a large value-taking interval, the initial value of the value-taking interval is the initial value of the first distribution interval, and the end value is the end value of the last distribution interval. In this step, the entity may take a randomly generated random number within the value range, and the random number may specifically fall within the certain distribution range, so that the random number may specifically correspond to a sub-service node. For the specific steps related to generating random numbers, reference may be made to the prior art, and further description is omitted here.
S106: and determining the sub-service node corresponding to the distribution interval in which the random number falls as a target sub-service node, and distributing the service information to the target sub-service node.
In this step, since the random number generated in S105 corresponds to one sub-service node, in this step, the corresponding sub-service node is specifically determined as a target sub-service node, and the service information acquired in S101 is sent to the target sub-service node, so that the gateway node completes service distribution.
The service distribution method based on the micro-service architecture provided by the embodiment of the invention is applied to a gateway node and comprises the steps of obtaining service information; calling the current load levels of all sub-service nodes in the target cluster corresponding to the service information; the load grades comprise a plurality of load grades which are sequentially arranged from low to high; the load grade is matched with the load value of the corresponding sub service node; determining the current processing capacity value of the corresponding sub-service node according to the load grade; the magnitude of the processing capacity value is in inverse proportion to the height of the load grade; arranging the sub-service nodes according to a preset sequence, and determining a distribution interval corresponding to the sub-service nodes according to the processing capacity value; the length of the distribution interval is equal to the processing capacity value; from the second distribution interval to the last distribution interval, the starting value of any distribution interval is equal to the ending value of the previous distribution interval; generating a random number; the initial value of the value interval of the random number is the initial value of the first distribution interval, and the termination value is the termination value of the last distribution interval; and determining the sub-service node corresponding to the distribution interval in which the random number falls as a target sub-service node, and distributing the service information to the target sub-service node.
And determining the processing capacity value, namely the residual load capacity, of each sub-service node according to the load level of the sub-service node corresponding to the target cluster. The distribution interval is generated according to the processing capacity value of each sub-service node, and after the random number is generated, the service information is distributed according to the distribution interval in which the random number falls, so that the service can be randomly distributed to each sub-service node on the premise of considering the load capacity of each sub-service node, the load of each sub-service node is balanced, and the sub-service node can reasonably execute the service.
The detailed contents of the method for distributing services based on micro service architecture provided by the present invention will be described in detail in the following embodiments of the invention.
Referring to fig. 2, fig. 2 is a flowchart of a specific micro service architecture-based service distribution method according to an embodiment of the present invention.
Referring to fig. 2, in the embodiment of the present invention, a service distribution method based on a micro service architecture is applied to a gateway node, and includes:
s201: and acquiring the current load value and the load grade of the sub service node.
In this step, the current load value and the load level of the sub-service node are obtained, so that the load level is modified according to the current load value in the subsequent steps.
Specifically, the step may specifically be: acquiring the latest continuous five load values in the sub-service nodes along the time sequence; calculating an average of five of the load values as the current load value. Specifically, in this step, the average value of the latest five consecutive load values of the sub-service node is used as the current load value, so that the load level of the sub-service node is adjusted according to the current load value in the following steps.
S202: and when the current load value is larger than the load upper limit value corresponding to the load level, the load level of the sub-service node is increased to the load level corresponding to the current load value.
In the embodiment of the present invention, each load level corresponds to an upper load limit value and a lower load limit value, and in the embodiment of the present invention, a plurality of load levels, typically three load levels or four load levels from low to high, are set. In this step, when the current load value of the sub service node at a certain load level is greater than the load upper limit value of the load level to which the sub service node belongs, the load level of the sub service node is adjusted upward, and specifically, the load level corresponding to the current load value is adjusted. It should be noted that, when the load level is adjusted in this step, the load level may be adjusted by skipping steps. For example, if a certain sub-service node is in the lowest load level, but the obtained current load value corresponds to the highest load level, the load level corresponding to the sub-service node may be directly adjusted from the lowest load level to the highest load level in this step, regardless of the number of load levels in the middle interval, so that when the load of the sub-service node is higher, the load level may accurately reflect the actual situation of the load.
S203: and when the current load value is smaller than the load lower limit value corresponding to the load grade, reducing the load grade of the sub service node by one grade.
In this step, when the current load value of the sub service node at a certain load level is smaller than the lower limit of the load level of the sub service node, the load level of the sub service node is adjusted downward, specifically, the load level of one level is adjusted downward, and the level-crossing adjustment is not possible. In this step, when the current load value of the sub-service node is lower than the lower limit of the load of the current belonging load class, only one load class is decreased no matter how low the current load value is, so as to achieve the effect of smooth valley-cutting and avoid the impact of sudden change of the service flow on the micro-service system.
It should be noted that, in the embodiment of the present invention, when the micro service system starts to operate, the initial load level of each self-service node is usually the lowest load level, and after the current load value of the sub-service node is obtained each time, the load level of the sub-service node is adjusted according to the above S202 and S203.
Specifically, in the embodiment of the present invention, between two adjacent load classes, the upper load limit value of the low load class is greater than the lower load limit value of the high load class. At this time, the situation that the load level of the sub service node frequently jumps can be avoided. For example, if the load upper limit value of the low load level is smaller than the load lower limit value of the high load level between two adjacent load levels, when the current load value of the sub-service node is gradually increased, the current load value is first larger than the load upper limit value of the low load level to make an upward jump, then the current load value is subjected to a downward jump by using the load lower limit value of the high load level, and then the current load value is subjected to an upward jump by using the load upper limit value larger than the load upper limit value of the low load level. When the upper load limit value of the low load level is greater than the lower load limit value of the high load level, the above situation can be avoided.
Specifically, in the embodiment of the present invention, the load classes include a zero-level load, a first-level load, a second-level load, and a third-level load; the load capacity value corresponding to the zero-level load is 100, the load capacity value corresponding to the first-level load is 66, the load capacity value corresponding to the second-level load is 33, and the load capacity value corresponding to the third-level load is 0; the upper load limit value of the zero-level load is 70; the upper limit value of the load of the primary load is 80, and the lower limit value of the load of the primary load is 65; the upper limit value of the load of the secondary load is 90, and the lower limit value of the load of the secondary load is 75; the lower load limit of the tertiary load is 85.
In the embodiment of the invention, a total of four load levels are set from low to high, which are respectively a zero-level load, a first-level load, a second-level load and a third-level load. Correspondingly, the load capacity value and other values such as the load value are all in a percentage system, and the load capacity value and other values are 100 at the highest and 0 at the lowest. In the embodiment of the present invention, the load capacity value corresponding to the zero-level load is 100, the load capacity value corresponding to the first-level load is 66, the load capacity value corresponding to the second-level load is 33, and the load capacity value corresponding to the third-level load is 0.
Accordingly, in the embodiment of the present invention, the load upper limit value of the zero-level load is 70; the upper limit value of the load of the primary load is 80, and the lower limit value of the load of the primary load is 65; the upper limit value of the load of the secondary load is 90, and the lower limit value of the load of the secondary load is 75; the lower load limit of the tertiary load is 85. Of course, in the embodiment of the present invention, the load upper limit value and the load lower limit value corresponding to each load class may have different values in the face of different clusters, and are not specifically limited in the embodiment of the present invention depending on the specific situation.
S204: and acquiring the service information.
S205: and calling the current load levels of all the sub-service nodes in the target cluster corresponding to the service information.
S206: and determining the current processing capacity value of the corresponding sub service node according to the load grade.
S207: and arranging the sub-service nodes according to a preset sequence, and determining a distribution interval corresponding to the sub-service nodes according to the processing capacity value.
S208: a random number is generated.
S209: and determining the sub-service node corresponding to the distribution interval in which the random number falls as a target sub-service node, and distributing the service information to the target sub-service node.
S204 to S209 are substantially the same as S101 to S106 in the above embodiment of the invention, and for details, reference is made to the above embodiment of the invention, which is not repeated herein. The above-mentioned S204 to S209 and S201 to S203 are usually executed in parallel, but S205 needs to adopt the load levels adjusted by S202 and S203.
For example, there are a total of 6 child service nodes in the target cluster, and their corresponding load status and processing capability values are shown in table 1 below:
TABLE 1
Figure BDA0002524218150000121
In the embodiment of the present invention, after the load levels of the sub service nodes are sorted from small to large, a distribution table of the target cluster is generated as shown in table 2 below:
TABLE 2
Figure BDA0002524218150000122
Accordingly, when generating the random number, the random number is specifically generated within a value interval [0,299 ], which is usually a left-closed right-open interval.
According to the business distribution method based on the micro-service architecture, when the load grade is adjusted according to the current load value of the sub-service node, the gateway node can be enabled to cope with the influence of the traffic spurt, and smooth peak clipping and valley clipping processing are carried out; and frequent jump of the load level of the sub-service node can be avoided.
In the following, a service distribution apparatus based on a micro service architecture provided by an embodiment of the present invention is introduced, and the service distribution apparatus described below and the service distribution method described above may be referred to correspondingly.
Fig. 3 is a block diagram of a service distribution apparatus based on a micro service architecture according to an embodiment of the present invention, and referring to fig. 3, the service distribution apparatus based on a micro service architecture, applied to a gateway node, may include:
the service acquisition module 100: for obtaining service information.
Load level call module 200: the load level of all the sub-service nodes in the target cluster corresponding to the service information is called; the load grades comprise a plurality of load grades which are sequentially arranged from low to high; the load level matches the load value of the corresponding child service node.
The processing capability value determination module 300: the processing capacity value of the corresponding sub service node is determined according to the load grade; the magnitude of the handling capacity value is inversely proportional to the magnitude of the load grade.
Distribution section determination module 400: the distribution interval is used for arranging the sub-service nodes according to a preset sequence and determining the distribution interval corresponding to the sub-service nodes according to the processing capacity value; the length of the distribution interval is equal to the processing capacity value; from the second distribution interval to the last distribution interval, the starting value of any one distribution interval is equal to the ending value of the previous distribution interval.
The random number generation module 500: for generating a random number; the initial value of the value interval of the random number is the initial value of the first distribution interval, and the termination value of the value interval of the random number is the termination value of the last distribution interval.
The service distribution module 600: and the sub-service node corresponding to the distribution interval in which the random number falls is determined as a target sub-service node, and the service information is distributed to the target sub-service node.
Preferably, in the embodiment of the present invention, the distribution interval determining module 400 is specifically configured to:
arranging the sub-service nodes according to the names of the sub-service nodes; or, arranging the sub service nodes from low to high according to the load levels of the sub service nodes.
Preferably, in the embodiment of the present invention, the method further includes:
a load information acquisition module: the load control method comprises the steps of obtaining a current load value and a current load grade of the sub service node;
a load level up-regulation module: the load level of the sub-service node is increased to the load level corresponding to the current load value when the current load value is larger than the load upper limit value corresponding to the current load level;
a load level down-regulation module: and the load level of the sub service node is decreased by one level when the current load value is smaller than the lower limit value of the load corresponding to the current load level.
Preferably, in an embodiment of the present invention, the load information acquiring module includes:
an acquisition unit: and the method is used for acquiring the latest continuous five load values in the sub service nodes along the chronological order.
A calculation unit: calculating an average of five of the load values as the current load value.
Preferably, in the embodiment of the present invention, between two adjacent load classes, the upper load limit value of the low load class is greater than the lower load limit value of the high load class.
Preferably, in the embodiment of the present invention, the load classes include zero-level load, first-level load, second-level load and third-level load; the load capacity value corresponding to the zero-level load is 100, the load capacity value corresponding to the first-level load is 66, the load capacity value corresponding to the second-level load is 33, and the load capacity value corresponding to the third-level load is 0;
the upper load limit value of the zero-level load is 70; the upper limit value of the load of the primary load is 80, and the lower limit value of the load of the primary load is 65; the upper limit value of the load of the secondary load is 90, and the lower limit value of the load of the secondary load is 75; the lower load limit of the tertiary load is 85.
The micro service architecture based service distribution apparatus of this embodiment is configured to implement the foregoing micro service architecture based service distribution method, and therefore specific embodiments in the service distribution apparatus may be seen in the foregoing embodiments of the service distribution method, for example, the service acquisition module 100, the load level invoking module 200, the processing capability value determining module 300, the distribution interval determining module 400, the random number generating module 500, and the service distribution module 600 are respectively configured to implement steps S101, S102, S103, S104, S105, and S106 in the service distribution method, so that the specific embodiments thereof may refer to descriptions of corresponding embodiments of each part, and are not described herein again.
In the following, a service distribution device based on a micro service architecture provided by an embodiment of the present invention is introduced, and the service distribution device described below, the service distribution method described above, and the service distribution apparatus described above may be referred to correspondingly.
Referring to fig. 4, fig. 4 is a block diagram of a service distribution device based on a micro service architecture according to an embodiment of the present invention.
Referring to fig. 4, the micro service architecture based traffic distribution apparatus may include a processor 11 and a memory 12, both applied to a gateway node.
The memory 12 is used for storing a computer program; the processor 11 is configured to implement the service distribution method based on the micro service architecture in the embodiment of the present invention when executing the computer program.
The processor 11 in the service distribution device of this embodiment is used to install the service distribution apparatus described in the above embodiment of the invention, and meanwhile, the processor 11 and the memory 12 are combined to implement the service distribution method described in any embodiment of the invention. Therefore, the specific implementation of the service distribution device based on the micro service architecture can be seen in the foregoing embodiments of the service distribution method, and the specific implementation thereof may refer to the description of each corresponding embodiment, which is not described herein again.
The present invention further provides a computer-readable storage medium, where a computer program is stored, and when executed by a processor, the computer program implements a micro service architecture-based service distribution method introduced in any of the embodiments of the present invention. The rest can be referred to the prior art and will not be described in an expanded manner.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 a process, method, article, or apparatus that comprises the element.
The service distribution method based on the micro-service architecture, the service distribution device based on the micro-service architecture, the service distribution equipment based on the micro-service architecture and the computer readable storage medium provided by the invention are described in detail above. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

Claims (10)

1. A service distribution method based on micro service architecture is characterized in that the method is applied to a gateway node and comprises the following steps:
acquiring service information;
calling the current load levels of all sub-service nodes in the target cluster corresponding to the service information; the load grades comprise a plurality of load grades which are sequentially arranged from low to high; the load grade is matched with the load value of the corresponding sub service node;
determining the current processing capacity value of the corresponding sub service node according to the load grade; the magnitude of the processing capacity value is inversely proportional to the height of the load grade;
arranging the sub-service nodes according to a preset sequence, and determining a distribution interval corresponding to the sub-service nodes according to the processing capacity value; the length of the distribution interval is equal to the processing capacity value; from the second distribution interval to the last distribution interval, the starting value of any distribution interval is equal to the ending value of the previous distribution interval;
generating a random number; the initial value of the value interval of the random number is the initial value of the first distribution interval, and the termination value is the termination value of the last distribution interval;
and determining the sub-service node corresponding to the distribution interval in which the random number falls as a target sub-service node, and distributing the service information to the target sub-service node.
2. The method of claim 1, wherein the arranging the sub-service nodes according to the preset order comprises:
arranging the sub-service nodes according to the names of the sub-service nodes; or, arranging the sub service nodes from low to high according to the load levels of the sub service nodes.
3. The method according to claim 1 or 2, wherein before invoking the current load levels of all the child service nodes in the target cluster corresponding to the service information, the method further comprises:
acquiring the current load value and the load grade of the sub service node;
when the current load value is larger than the load upper limit value corresponding to the load level, the load level of the sub service node is increased to the load level corresponding to the current load value;
and when the current load value is smaller than the load lower limit value corresponding to the load grade, reducing the load grade of the sub service node by one grade.
4. The method of claim 3, wherein obtaining the current load value of the child service node comprises:
acquiring the latest continuous five load values in the sub-service nodes along the time sequence;
calculating an average of five of the load values as the current load value.
5. The method according to claim 3, wherein between two adjacent load classes, the upper load limit value of a low load class is greater than the lower load limit value of a high load class.
6. The method of claim 5, wherein the load classes comprise zero level load, first level load, second level load, and third level load; the load capacity value corresponding to the zero-level load is 100, the load capacity value corresponding to the first-level load is 66, the load capacity value corresponding to the second-level load is 33, and the load capacity value corresponding to the third-level load is 0;
the upper load limit value of the zero-level load is 70; the upper limit value of the load of the primary load is 80, and the lower limit value of the load of the primary load is 65; the upper limit value of the load of the secondary load is 90, and the lower limit value of the load of the secondary load is 75; the lower load limit of the tertiary load is 85.
7. A service distribution device based on micro service architecture is characterized in that the device is applied to a gateway node and comprises:
a service acquisition module: the system is used for acquiring service information;
a load level calling module: the load level of all the sub-service nodes in the target cluster corresponding to the service information is called; the load grades comprise a plurality of load grades which are sequentially arranged from low to high; the load grade is matched with the load value of the corresponding sub service node;
a throughput value determination module: the processing capacity value of the corresponding sub service node is determined according to the load grade; the magnitude of the processing capacity value is inversely proportional to the height of the load grade;
a distribution section determination module: the distribution interval is used for arranging the sub-service nodes according to a preset sequence and determining the distribution interval corresponding to the sub-service nodes according to the processing capacity value; the length of the distribution interval is equal to the processing capacity value; from the second distribution interval to the last distribution interval, the starting value of any distribution interval is equal to the ending value of the previous distribution interval;
a random number generation module: for generating a random number; the initial value of the value interval of the random number is the initial value of the first distribution interval, and the termination value of the value interval of the random number is the termination value of the last distribution interval;
a service distribution module: and the sub-service node corresponding to the distribution interval in which the random number falls is determined as a target sub-service node, and the service information is distributed to the target sub-service node.
8. The apparatus of claim 7, further comprising:
a load information acquisition module: the load control method comprises the steps of obtaining a current load value and a current load grade of the sub service node;
a load level up-regulation module: the load level of the sub-service node is increased to the load level corresponding to the current load value when the current load value is larger than the load upper limit value corresponding to the current load level;
a load level down-regulation module: and the load level of the sub service node is decreased by one level when the current load value is smaller than the lower limit value of the load corresponding to the current load level.
9. A service distribution device based on micro service architecture is applied to a gateway node, and comprises:
a memory for storing a computer program;
a processor for implementing the steps of the micro-service architecture based service distribution method according to any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, for a gateway node, the computer-readable storage medium having stored thereon a computer program, which when executed by a processor, implements the steps of the micro service architecture based service distribution method according to any one of claims 1 to 6.
CN202010499407.9A 2020-06-04 2020-06-04 Business distribution method based on micro-service architecture and related device Pending CN111651274A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010499407.9A CN111651274A (en) 2020-06-04 2020-06-04 Business distribution method based on micro-service architecture and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010499407.9A CN111651274A (en) 2020-06-04 2020-06-04 Business distribution method based on micro-service architecture and related device

Publications (1)

Publication Number Publication Date
CN111651274A true CN111651274A (en) 2020-09-11

Family

ID=72351272

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010499407.9A Pending CN111651274A (en) 2020-06-04 2020-06-04 Business distribution method based on micro-service architecture and related device

Country Status (1)

Country Link
CN (1) CN111651274A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113419993A (en) * 2021-05-19 2021-09-21 北京达佳互联信息技术有限公司 Read-write request processing method and device, electronic equipment and storage medium
CN117237004A (en) * 2023-11-10 2023-12-15 深圳海辰储能科技有限公司 Energy storage device transaction processing method and device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453125A (en) * 2016-11-04 2017-02-22 中国电子科技集团公司第二十八研究所 Load balancing system for remote service calling based on real-time load rate
CN108173698A (en) * 2018-01-17 2018-06-15 阿里巴巴集团控股有限公司 Network service management method, apparatus, server and storage medium
CN109067869A (en) * 2018-08-01 2018-12-21 郑州云海信息技术有限公司 The management method and device of micro services node in cloud computing system
CN109144724A (en) * 2018-07-27 2019-01-04 众安信息技术服务有限公司 A kind of micro services resource scheduling system and method
CN110233860A (en) * 2018-03-05 2019-09-13 杭州萤石软件有限公司 A kind of load-balancing method, device and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453125A (en) * 2016-11-04 2017-02-22 中国电子科技集团公司第二十八研究所 Load balancing system for remote service calling based on real-time load rate
CN108173698A (en) * 2018-01-17 2018-06-15 阿里巴巴集团控股有限公司 Network service management method, apparatus, server and storage medium
CN110233860A (en) * 2018-03-05 2019-09-13 杭州萤石软件有限公司 A kind of load-balancing method, device and system
CN109144724A (en) * 2018-07-27 2019-01-04 众安信息技术服务有限公司 A kind of micro services resource scheduling system and method
CN109067869A (en) * 2018-08-01 2018-12-21 郑州云海信息技术有限公司 The management method and device of micro services node in cloud computing system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113419993A (en) * 2021-05-19 2021-09-21 北京达佳互联信息技术有限公司 Read-write request processing method and device, electronic equipment and storage medium
CN117237004A (en) * 2023-11-10 2023-12-15 深圳海辰储能科技有限公司 Energy storage device transaction processing method and device and storage medium
CN117237004B (en) * 2023-11-10 2024-03-05 深圳海辰储能科技有限公司 Energy storage device transaction processing method and device and storage medium

Similar Documents

Publication Publication Date Title
CN111651274A (en) Business distribution method based on micro-service architecture and related device
CN107404541B (en) Method and system for selecting neighbor node in peer-to-peer network transmission
CN110582064B (en) Short message distribution method, device, equipment and medium
CN110661719B (en) Traffic load balancing method and device
WO2021022875A1 (en) Distributed data storage method and system
CN111163178A (en) Game theory-based service deployment and task unloading method in edge computing
CN110636388A (en) Service request distribution method, system, electronic equipment and storage medium
CN110519090A (en) A kind of accelerator card distribution method, system and the associated component of FPGA cloud platform
CN112764920A (en) Edge application deployment method, device, equipment and storage medium
CN111585798B (en) Network resource parameter configuration method, device and computer readable storage medium
CN103150353A (en) Method and device for acquiring microblog information
CN104158902B (en) A kind of Hbase data blocks distribution method and device based on number of request
CN110221917B (en) Method and apparatus for distributing streaming data
CN114357085A (en) Financial data storage method and device based on block chain and storage medium
CN111683133B (en) Service flow limiting method based on micro-service architecture and related device
CN116700920A (en) Cloud primary hybrid deployment cluster resource scheduling method and device
CN116546028A (en) Service request processing method and device, storage medium and electronic equipment
CN116204293A (en) Resource scheduling method, device, computer equipment and storage medium
CN111683132B (en) Business distribution method based on micro-service architecture and related device
CN104899072A (en) Fine-grained resource dispatching system and fine-grained resource dispatching method based on virtualization platform
CN115842828A (en) Gateway load balancing control method, device, equipment and readable storage medium
CN111092959B (en) Request processing method, system and related device for servers in cluster
KR100576713B1 (en) System and method for dynamic load balancing
CN112003900A (en) Method and system for realizing high service availability under high-load scene in distributed system
CN113392130B (en) Data processing method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination