A microservice partitioning method, device, equipment and medium
By constructing the membership matrix and parameter matrix of the microservice collection, the microservice collection is automatically divided, which solves the problems of inaccurate microservice division and the influence of subjective factors in the existing technology, and improves the stability and usage efficiency of the system.
Patent Information
- Application Number
- CN202111440228.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-11-30
AI Technical Summary
When the existing technology divides microservices in enterprise systems, the granularity is inaccurate and affected by subjective factors, leading to problems in system usage efficiency and stability.
By constructing the membership matrix and parameter matrix of the microservice collection, the microservice collection is automatically divided, reducing the subjective factors of human experience and achieving accurate microservice division.
It improves the accuracy of microservice division and system stability, reduces the influence of subjective factors, and ensures the accurate classification and usage efficiency of microservices in enterprise systems.
Smart Images

Figure CN114115818B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to a microservice partitioning method, device, equipment, and medium. Background Art
[0002] Microservice Architecture is an architectural concept that aims to decouple solutions by breaking down the overall functionality of a system into discrete services. For enterprises, whether the microservices of the enterprise system and the corresponding microservice set division are reasonable not only affects the efficiency of the system, but sometimes also affects whether the system can operate normally.
[0003] At present, when multiple microservices included in an enterprise system are divided into corresponding microservice sets, they are generally divided according to the business included in the enterprise or human experience. The microservice sets obtained in this way cannot guarantee the granularity of division, and there is a problem that the obtained microservice sets and the microservices included in each microservice set are not accurately divided, which affects the use of the enterprise system. Summary of the invention
[0004] The embodiments of the present invention provide a microservice partitioning method, apparatus, device and medium, which can optimize the existing implementation scheme of microservice partitioning.
[0005] In a first aspect, an embodiment of the present invention provides a microservice partitioning method, including:
[0006] Determine at least one microservice set consisting of multiple microservices in the business segment;
[0007] Constructing a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to the plurality of microservices in the business segment;
[0008] Calculating a parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and a preset function;
[0009] The multiple microservices in the business segment are divided into at least one target microservice set according to the parameter matrix.
[0010] In a second aspect, an embodiment of the present invention provides a microservice partitioning device, including:
[0011] A determination module, used to determine at least one microservice set consisting of multiple microservices in a business segment;
[0012] A construction module, used to construct a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to multiple microservices in the business segment;
[0013] A calculation module, configured to calculate a parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and a preset function;
[0014] A partitioning module is used to partition the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix.
[0015] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the microservice partitioning method provided in the embodiment of the present invention is implemented.
[0016] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the microservice partitioning method provided in an embodiment of the present invention.
[0017] A microservice partitioning scheme provided in an embodiment of the present invention first determines at least one microservice set consisting of multiple microservices in a business segment; then constructs a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to multiple microservices in the business segment; calculates a parameter matrix in a preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and the preset function; finally, divides the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix. By adopting the above technical scheme, by calculating the parameter matrix in the preset function, the multiple microservices corresponding to the business segment can be divided into at least one microservice set according to the parameter matrix, which is helpful for the accurate division of the microservice set of the enterprise system, and each microservice in the enterprise system can also be divided into a corresponding microservice set, so as to achieve accurate classification of all microservices contained in the enterprise system, so as to facilitate the use of the enterprise system, and at the same time reduce the influence of subjective factors when dividing microservices according to business or human experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A schematic diagram of a process of dividing microservices provided in the first embodiment of the present invention;
[0019] Figure 2 A schematic diagram of a process of dividing microservices provided in the second embodiment of the present invention;
[0020] Figure 3A structural block diagram of a microservice partitioning device provided in Embodiment 3 of the present invention;
[0021] Figure 4 This is a structural block diagram of a computer device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0022] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and through specific implementation methods. It is understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It is also necessary to explain that, for ease of description, only parts related to the present invention are shown in the accompanying drawings, rather than all structures.
[0023] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0024] Embodiment 1
[0025] Figure 1 The flowchart of a microservice partitioning implementation method provided in the first embodiment of the present invention is shown in FIG. 1 . The method can be executed by a microservice partitioning device, wherein the device can be implemented by software and / or hardware and can generally be integrated in a computer device such as a server. Figure 1 As shown, the method includes:
[0026] S110. Determine at least one microservice set consisting of multiple microservices in a business segment.
[0027] Generally, the business included in the enterprise system may involve multiple fields. Here, the enterprise system can be divided into different business segments according to the different business fields involved. For example, the business segments can be: financial business segment, medical business segment, and Internet business segment, etc.; it can also be divided into: domestic business segment, international business segment and other business segments according to the scope of the business included in the enterprise system, and the specific way of dividing the business segments is not limited here.
[0028] Accordingly, in the business database of the enterprise system, multiple business data tables related to the business sectors involved in the enterprise are stored, and each business data table can represent the statistical data of the relevant business in the enterprise system. The business data tables stored in the database come from multiple business sectors. Here, each business data table can be regarded as a microservice, and multiple microservices corresponding to the business sectors are stored in the business database.
[0029] Because the business database may directly store all microservices when storing multiple microservices corresponding to the business segment, without dividing the microservices into corresponding business segments, in order to facilitate the division of microservice sets, before determining at least one microservice set composed of multiple microservices in the business segment, it is necessary to first divide the multiple microservices into corresponding business segments.
[0030] When all microservices stored in the business database are divided into corresponding business segments, microservices with similar features can be divided into the same business segment by feature extraction, and at least one microservice set consisting of multiple microservices in the business segment can be further determined.
[0031] Optionally, when determining at least one microservice set consisting of multiple microservices in a business segment, the number of microservice sets can be automatically adjusted by a computer based on the principle of minimum membership loss to obtain at least one microservice set consisting of multiple microservices; the number of microservice sets divided by multiple microservices in the current business segment can also be determined by human experience, etc. The specific method of determining the microservice set is not limited here.
[0032] It should be noted that in the process of determining at least one microservice set composed of multiple microservices in a business segment, no matter which of the above methods is used, it is necessary to pre-set the microservices contained in each microservice set. The microservices contained in the current microservice set can be understood as fuzzy microservices, that is, it is convenient for this scheme to realize the division of microservices based on the affiliation of fuzzy microservices between microservice sets. Currently, fuzzy microservices can be divided arbitrarily and there is no basis for division. Exemplarily, the microservices initially included in the microservice set X1 may be given in advance as a1, a2, a3, that is, X1 = {a1, a2, a3}. After calculation in subsequent steps S120-S140, at least one microservice set divided under the current business segment and the microservices included in each microservice set may be obtained. The microservices included in the current microservice set may be different from the pre-given microservices. Exemplarily, after calculation in steps S120-S140, the microservices included in X1 may be a1, a3, that is, X1 = {a1, a3}, thereby achieving the purpose of accurately dividing the multiple microservices included in the business segment into each microservice set.
[0033] S120: Construct a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to multiple microservices in the business segment.
[0034] When analyzing from a functional perspective, membership can be understood as follows: for any element x in the research range U, there is a number A(x)∈[0,1] corresponding to it. Then A is called a fuzzy set on U, and A(x) is called the membership of x to A. When the membership A(x) is closer to 1, the degree to which the element x belongs to A is higher, and when A(x) is closer to 0, the degree to which x belongs to A is lower.
[0035] When constructing the membership matrix, the embodiment of the present invention assumes that there are n business data tables under the current business sector, representing n microservices. According to the association relationship (R) between all microservices, an nxn microservice association matrix R can be constructed; the association matrix R can construct an entity-relationship diagram (Entity Relationship Diagram, referred to as ER diagram) between the n microservices under the current business sector, and convert each microservice in the ER diagram as a node into an undirected graph, and obtain the n*n degree matrix D of the microservice node according to the degree of the undirected graph (the degree of an undirected graph vertex is the number of edges connected to the vertex), and construct the n*n membership matrix U of the n microservices under the current business sector. Exemplarily, U can be used ij Represents the degree of affiliation between the i-th microservice and the j-th microservice.
[0036] When constructing the first membership matrix and the second membership matrix corresponding to the microservice set through the above process, since the microservices contained in each microservice set have membership before the current business segment is divided into at least one microservice set, after the division, the membership of each microservice set relative to the remaining microservice sets in the current business segment is lost, and it is necessary to construct the first membership matrix corresponding to the current microservice set and the remaining microservice sets; at the same time, the membership of the microservices contained in each microservice set itself is also lost, and it is necessary to construct the second membership matrix corresponding to the current microservice set; and further construct the third membership matrix of the multiple microservices contained in the current business segment.
[0037] The microservice partitioning scheme provided in an embodiment of the present invention characterizes the degree to which each microservice under the current business segment belongs to the corresponding microservice set by constructing a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to multiple microservices in the business segment. If the degree is higher, the current microservice can be divided into the corresponding set.
[0038] S130, calculating a parameter matrix in a preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and the preset function.
[0039] The preset function represents a calculation function of the first membership matrix, the second membership matrix and the third membership matrix composed of at least one microservice set in a general sense, and the function includes the calculation result of the parameter preset function, which is a matrix corresponding to the parameter, representing the microservice set under the current business segment and the specific microservices contained in each microservice set in the form of a matrix.
[0040] S140. Divide the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix.
[0041] In the parameter matrix obtained according to step S130, if the column vector j of the parameter matrix represents the target microservice set, and the row vector i of the parameter matrix represents multiple microservices, the parameter matrix can be represented as an i*j matrix, and the output parameter matrix contains several column vectors, which indicates that the current business segment is divided into several target microservice sets.
[0042] Furthermore, when dividing multiple microservices into corresponding target microservice sets, the division is based on the following: if the current row vector i belongs to the current column vector j, it indicates that the microservice corresponding to the current row vector i belongs to the target microservice set corresponding to the current j vector, and among all the column vectors corresponding to the current row vector, there is only one row vector corresponding to a column vector of 1, and the rest are 0, indicating that each microservice can only be divided into one target microservice set. Further, all row vectors represented by the same column vector of 1 in the current business segment are divided into the same set, and finally at least one target microservice set for the business segment and the microservices contained in each microservice set can be obtained.
[0043] Optionally, the microservice partitioning method provided in an embodiment of the present invention involves several business segments in an enterprise system, and a parameter matrix corresponding to each business segment can be obtained. Each parameter matrix divides the multiple microservices in each corresponding business segment into at least one target microservice set.
[0044] In an embodiment of the present invention, a microservice partitioning method is provided, which first determines at least one microservice set consisting of multiple microservices in a business segment; then constructs a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to the multiple microservices in the business segment; calculates a parameter matrix in a preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and the preset function; and finally, partitions the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix. By adopting the above technical solution, by calculating the parameter matrix in the preset function, the multiple microservices corresponding to the business segment can be partitioned into at least one microservice set according to the parameter matrix, which helps to accurately partition the microservice set of the enterprise system, and can also partition each microservice in the enterprise system into a corresponding microservice set, so as to achieve accurate classification of all microservices contained in the enterprise system, so as to facilitate the use of the enterprise system, and at the same time reduce the influence of subjective factors when partitioning microservices according to business or human experience.
[0045] Embodiment 2
[0046] The embodiment of the present invention is further optimized on the basis of the above embodiment, and optimizes the step of determining at least one microservice set composed of multiple microservices in the business segment, including: determining at least one microservice set composed of multiple microservices in the business segment according to the preset number of microservice sets; or, dividing the multiple microservices in the business segment into at least one microservice set based on the principle of minimizing membership loss. The advantage of this setting is that two methods are provided to determine at least one microservice set corresponding to multiple microservices, so that developers can choose according to actual conditions, so that the method of dividing microservice sets is diverse.
[0047] The steps of constructing the first membership matrix and the second membership matrix corresponding to the microservice set are also optimized, including: constructing the first membership matrix corresponding to the microservice set according to the current microservice set and the remaining microservice sets; constructing the second membership matrix corresponding to the microservice set according to the current microservice set; wherein the microservices in the current microservice set and the microservices in the remaining microservice sets constitute multiple microservices in the business segment. The advantage of this setting is that the division of microservices is realized based on the membership, making the division result more accurate.
[0048] like Figure 2 As shown, Figure 2 The present invention provides a flow chart of a microservice method according to the second embodiment of the present invention. Specifically, the method includes the following steps:
[0049] S201. Extract features of multiple microservices in a business database to obtain feature flags corresponding to each microservice.
[0050] Since the microservices stored in the business database generally come from multiple business sectors, in order to realize the division of microservices in a business sector, we can first extract features from multiple microservices to obtain the feature flags of each microservice, and divide the microservices with similar feature flags into the same business sector. Correspondingly, we also need to obtain the feature flags corresponding to each business sector, so as to realize the division of microservices with similar feature flags into business sectors that also have corresponding feature flags.
[0051] Optionally, when dividing according to the characteristic marks of microservices and the characteristic marks of business segments, the characteristic marks of microservices considered may be: the stability of each microservice, the strong consistency requirement of each microservice with the business type, and the number of calls of each microservice. The characteristic marks of business segments may be: the business type of the business segment, the support domain of the business segment, the core domain of the business segment, and the general domain of the business segment.
[0052] S202: Determine the business sections corresponding to the multiple microservices according to the characteristic flags corresponding to each microservice.
[0053] When determining the business segments corresponding to multiple microservices respectively according to the characteristic flags corresponding to each microservice, the similarity value between the characteristic flags of each business segment and the characteristic flags of each microservice can be calculated through a preset algorithm; when the similarity value is greater than a preset threshold, the current business segment is determined to be the business segment corresponding to the microservice.
[0054] The above preset algorithm can be: Euclidean metric algorithm, cosine similarity algorithm or Pearson correlation coefficient algorithm, etc. The specific algorithm is not limited here, as long as it can satisfy the calculation of the similarity value between the characteristic mark of each business segment and the characteristic mark of each microservice.
[0055] It should be noted that the above preset threshold can be 70%, 80% or 90%. The specific value of the preset threshold is not limited here and is subject to the actual needs of the developer.
[0056] S203a. According to a preset number of microservice sets, determine at least one microservice set consisting of multiple microservices in the business segment.
[0057] After obtaining multiple microservices included in each business segment according to step S202, it is further necessary to determine the microservice set included in the business segment. In this regard, the embodiment of the present invention provides two methods for determining at least one microservice set composed of multiple microservices in the business segment through step S203a or step S203b, respectively, so that developers can choose according to actual conditions, thereby making the method of dividing the microservice set diverse.
[0058] Based on the experience accumulated by developers for the current business segment, multiple microservices in the business segment can be divided into a corresponding number of microservice sets by artificially giving a preset number of microservice sets. The number of microservices determined by this method is consistent with the preset number of microservice sets after calculation in subsequent steps, but the microservices included in each microservice set may change.
[0059] S203b. Based on the principle of minimizing membership loss, multiple microservices in the business segment are divided into at least one microservice set.
[0060] The method of using this method to divide multiple microservices in a business segment into at least one microservice set is a method for automatically dividing microservice sets by a computer. The corresponding process can be: the developer can give the computer an initial value, the current initial value represents the number of initial microservice sets into which multiple microservices in the business segment are divided, and the microservices contained in each initial microservice set are given, so as to construct a membership matrix corresponding to the microservices contained in each initial microservice set, and then automatically adjust the number of initial microservice sets and the microservices contained in each initial microservice set based on the principle of minimum membership loss, so as to obtain at least one microservice set composed of multiple microservices in the current business segment. When dividing microservice sets in this way, the number of target microservice sets calculated in subsequent steps is not necessarily the same as the number of initial microservice sets, and accordingly, the microservices contained in the target microservice set are also different.
[0061] Exemplarily, the business sector is defined as A, the microservices included in the current business sector are a1, a2, ..., a9, and the number of preset microservice sets is 3, namely X1, X2 and X3. If the microservices included in each microservice set are X1 = {a1, a2, a3}, X2 = {a4, a5}, X3 = {a6, a7, a8, a9}, when the microservice set is determined according to step S203a, after calculation in subsequent steps, the target microservice set and the microservices included in each microservice set may be: X1 = {a1, a4}, X2 = {a2, a3, a9, a5}, X3 = {a6, a7, a8, a9}. 6, a7, a8}. When the microservice set is determined according to step S203b, after adjusting the microservice set according to the principle of minimum membership loss, the target microservice set obtained and the microservices included in each microservice set may be: X1 = {a1, a4}, X2 = {a2, a3, a9}, X3 = {a7, a8}, X4 = {a5, a6}. Accordingly, the number of microservice sets determined according to step S203b may also be less than or equal to the preset number of microservice sets, which shall be subject to the actual situation.
[0062] S204: Construct a first membership matrix corresponding to the microservice set according to the current microservice set and the remaining microservice sets.
[0063] Assuming that the microservice set included in the current business segment is X, the number of microservices included is m, and the microservice set is represented by n, the membership matrix of the microservice set in the current business segment can be expressed as: U = [u ij ], represents the membership degree between the i-th microservice and the j-th microservice, where 1≤i≤m, 1≤j≤m,.
[0064] For example, assume that the microservice set X included in business segment A contains n microservice sets, that is, X = {X1, X2, X3, ..., X n};
[0065] Now assume that the m microservices contained in business segment A are divided into two microservice sets, namely X1 set and X2 set. Definition: X1 set belongs to X, X2 set also belongs to X, and the intersection of X1 and X2 is empty; if the two microservice sets X1 and X2 are divided according to the assumption, the corresponding membership loss result can be expressed by the following formula:
[0066]
[0067] In the above formula, iE X1 Indicates that the i-th microservice belongs to the microservice set of set X1, jE X2 Indicates that the jth microservice belongs to the microservice set X2. Because the microservices contained in the X1 and X2 sets have membership before the m microservices are divided into X1 and X2 sets, the membership of U(X1, X2) is lost when they are divided into two microservice sets X1 and X2.
[0068] According to formula (1), when the set of microservices in the business segment is further expanded to n, the function is:
[0069]
[0070] In formula (2), U(X i ,C) represents the first membership matrix corresponding to the current microservice set and the remaining microservice sets, where C = XX i .
[0071] S205. Construct a second membership matrix corresponding to the microservice set according to the current microservice set.
[0072] In formula (2), U(X i ,X i) represents the second membership matrix, in which the microservices in the current microservice set and the microservices in the remaining microservice sets constitute multiple microservices in the business segment, that is, satisfying the formula X i +C=X.
[0073] S206. Construct a third membership matrix corresponding to multiple microservices in the business segment.
[0074] In formula (2), Represents the third membership matrix.
[0075] Furthermore, in order to minimize the membership loss of the n microservice sets that are divided, formula (2) can be converted into a preset function containing parameters, so that the problem of microservice division to be solved is converted into a problem of solving the problem of minimizing the membership loss. The corresponding formula is as follows:
[0076]
[0077] In formula (3), Y represents the parameter matrix to be calculated, and i represents the ij The i-th microservice in the parameter matrix Y ij Since a microservice can only belong to one microservice set, that is, the parameter matrix Y ij There is only one value 1 in a column vector of .
[0078] S207: Construct a unit matrix of parameters corresponding to the business segment.
[0079] The unit matrix of the parameters corresponding to the business segment can be expressed by the following formula:
[0080]
[0081] In the above formula, y j Represents a column vector in the parameter matrix.
[0082] S208. Determine the objective function of the parameters corresponding to the business segment according to the degree matrices corresponding to the first membership matrix, the second membership matrix, the third membership matrix, and the unit matrix contained in the preset function.
[0083] Expanding the above formula (3) yields the diagonal matrix (U(X i ,X)-U(X i ,X i )*DM) -1 , the determinant of the current matrix can be obtained. Where DM represents the degree matrix corresponding to the third membership matrix.
[0084] Since the diagonal matrix can be obtained, we can set the above diagonal matrix = Q, and then combine formula (3) and formula (4) to get the objective function:
[0085] JJ(X)=argmia Y (Y T *Q*YY T *U*Y) (5)
[0086] S209. Calculate the partial derivative of the objective function.
[0087] In formula (5), since U is known, Q can be obtained based on U, so it is also known. The parameter Y is further solved by taking the partial derivative of the objective function.
[0088] S210. Determine whether the partial derivative result is less than or equal to a first threshold.
[0089] Each time the solution is obtained, it can be determined whether the result of the current objective function is less than or equal to the preset threshold. If so, execute step S211; if not, execute step S209, that is, iterate the partial derivative again until the derivative result of the objective partial function is less than or equal to the first threshold.
[0090] S211. Determine the partial derivative result as the parameter matrix of the preset function.
[0091] The first threshold may be 0, that is, when the result of the objective function is 0, it indicates that the parameter Y has been iterated to a constant, and the partial derivative result may be determined as the parameter matrix of the preset function.
[0092] S212. Divide the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix.
[0093] The current parameter matrix represents the division result of the target microservice set of the current business segment. The enterprise system contains multiple business segments. One business segment can be analyzed to obtain the parameter matrix corresponding to the current business segment, and then the above steps S201-S211 can be repeated to determine the parameter matrix under each business segment respectively. Multiple business segments of the enterprise system can also be analyzed at the same time. After steps S201-S211, the parameter matrix corresponding to each business segment can be obtained, so that each parameter matrix can represent the division result of the target microservice set corresponding to each business segment. The specific analysis method of the business segment is not limited here.
[0094] After dividing the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix, the microservice division method provided in the embodiment of the present invention can also verify the target microservice combination and the microservice to determine the accuracy of the division. In the microservice sets divided in two different ways according to step S203a and S203b, the final verification method is also different, as follows:
[0095] When determining at least one microservice set consisting of multiple microservices in the business segment according to step S203b, dividing the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix includes:
[0096] Determine a set partition result of multiple microservices according to the parameter matrix; when the number of sets corresponding to the set partition result meets the first preset condition, and the number of microservices corresponding to the set partition result meets the second preset condition, determine the set partition result as at least one target microservice set, and multiple microservices included in the at least one target microservice set; when the result does not meet the first preset condition, and / or does not meet the second preset condition, based on the principle of minimizing membership loss, re-divide the multiple microservices in the business segment into at least one microservice set.
[0097] Among them, the first preset condition includes: the number of target microservice sets is greater than or equal to 2; the second preset condition includes: the number of microservices is greater than the number of target microservice sets.
[0098] In the set partitioning result of the multiple microservices obtained according to the parameter matrix, if the number of the target microservice sets obtained is greater than or equal to 2, the partitioning of the multiple microservices contained in the current business section has corresponding significance. It is also possible that the initial microservice set given by the computer according to step S203b does not meet the demand and needs to be readjusted. For each target microservice set of the partition, at least one microservice needs to be included, and the number of the microservices finally partitioned needs to be greater than the number of the target microservice set.
[0099] If the set partitioning result does not meet any of the above conditions, it indicates that an error occurred in the computer during execution. Based on the principle of minimum membership loss, steps S203b-S212 need to be re-executed until the set partitioning result meets the above first preset condition and the second preset condition.
[0100] When at least one microservice set consisting of multiple microservices in the business section is determined according to step S203a, the multiple microservices in the business section are divided into at least one target microservice set according to the parameter matrix:
[0101] Determine a set partition result of multiple microservices according to the parameter matrix; when the number of microservices corresponding to the set partition result meets the second preset condition, determine the set partition result as at least one target microservice set and multiple microservices included in the at least one target microservice set.
[0102] The second preset condition includes: the number of microservices is greater than the number of target microservice sets.
[0103] At least one microservice set determined according to step S203a is an empirical value. If the number of microservices finally obtained is less than the number of the target microservice set, it indicates that the current empirical value is inaccurate, and the developer needs to re-enter the empirical value or use the method of step S203b to determine.
[0104] The microservice partitioning method provided in the embodiment of the present invention partitions microservices into corresponding business segments by extracting features from each microservice and business segment. The strong consistency requirements between microservice business segments, the difficulty of distributed transactions, etc. are considered during feature extraction, solving the problem that it is difficult to grasp the granularity boundary of microservice splitting. Further, when partitioning the microservice set, a membership matrix is constructed for the microservice set and the microservices contained in each set according to the principle of minimum membership loss, the objective function is calculated, and the multiple microservices in the business segment are partitioned into at least one target microservice set through the parameter matrix, which helps to achieve accurate partitioning of the microservice set of the enterprise system.
[0105] Embodiment 3
[0106] Figure 3 A structural block diagram of a microservice partitioning device is provided for the third embodiment of the present invention. The device can be implemented by software and / or hardware, and can generally be integrated in a computer device such as a server. The microservice partitioning method can be executed to partition the microservices. Figure 3 As shown, the device includes: a determination module 31, a construction module 32, a calculation module 33 and a division module 34, wherein:
[0107] A determination module 31 is used to determine at least one microservice set consisting of multiple microservices in a business segment;
[0108] A construction module 32 is used to construct a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to the plurality of microservices in the business segment;
[0109] A calculation module 33, configured to calculate a parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and a preset function;
[0110] The division module 34 is used to divide the multiple microservices in the business section into at least one target microservice set according to the parameter matrix.
[0111] The microservice partitioning device provided in the embodiment of the present invention first determines at least one microservice set composed of multiple microservices in the business segment; then constructs a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to the multiple microservices in the business segment; calculates the parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and the preset function; finally, the multiple microservices in the business segment are divided into at least one target microservice set according to the parameter matrix. By adopting the above technical solution, by calculating the parameter matrix in the preset function, the multiple microservices corresponding to the business segment can be divided into at least one microservice set according to the parameter matrix, which is helpful for the accurate division of the microservice set of the enterprise system, and each microservice in the enterprise system can also be divided into the corresponding microservice set, so as to achieve accurate classification of all microservices contained in the enterprise system, so as to facilitate the use of the enterprise system, and at the same time reduce the influence of subjective factors when dividing microservices according to business or human experience.
[0112] Optionally, the determination module 31 is further used to determine at least one microservice set consisting of multiple microservices in the business segment based on a preset number of microservice sets; or, based on the principle of minimizing membership loss, divide the multiple microservices in the business segment into at least one microservice set.
[0113] Optionally, the device further comprises: an extraction module;
[0114] An extraction module is used to extract features of multiple microservices in the business database to obtain feature flags corresponding to each microservice;
[0115] The determination module 31 is further used to determine the business sections corresponding to the multiple microservices according to the characteristic flags corresponding to each microservice.
[0116] Optionally, the construction module 32 is also used to construct a first membership matrix corresponding to the microservice set based on the current microservice set and the remaining microservice sets; and to construct a second membership matrix corresponding to the microservice set based on the current microservice set; wherein the microservices in the current microservice set and the microservices in the remaining microservice sets constitute multiple microservices in the business segment.
[0117] Optionally, the calculation module 33 includes: a construction unit, a first determination unit and a calculation unit, wherein:
[0118] A construction unit, used to construct a unit matrix of parameters corresponding to the business segment;
[0119] A first determination unit, configured to determine an objective function of the parameters corresponding to the business segment according to the first membership matrix, the second membership matrix, the degree matrix corresponding to the third membership matrix, and the identity matrix contained in the preset function;
[0120] A calculation unit, used to calculate the partial derivative result of the objective function;
[0121] The first determination unit is also used to determine the partial derivative result as the parameter matrix of the preset function when the partial derivative result is less than or equal to the first threshold; and to repeatedly calculate the partial derivative result of the objective function when the result of the objective function is greater than the first threshold until the parameter matrix of the preset function is determined.
[0122] Optionally, the division module 34 includes: a second determination unit and a division unit, wherein:
[0123] A second determining unit, configured to determine a set partitioning result of the plurality of microservices according to the parameter matrix;
[0124] A partitioning unit, for determining the set partitioning result as at least one target microservice set and a plurality of microservices included in the at least one target microservice set, when the number of sets corresponding to the set partitioning result meets a first preset condition and the number of microservices corresponding to the set partitioning result meets a second preset condition; and for re-dividing the plurality of microservices in the business segment into at least one microservice set based on the principle of minimizing membership loss when the result does not meet the first preset condition and / or does not meet the second preset condition.
[0125] The first preset condition includes: the number of the target microservice set is greater than or equal to 2; the second preset condition includes: the number of the microservices is greater than the number of the target microservice set.
[0126] Optionally, the division module 34 further includes: a second determination unit, wherein:
[0127] A second determining unit is used to determine a set partitioning result of the plurality of microservices according to the parameter matrix; and is also used to determine the set partitioning result as at least one target microservice set and a plurality of microservices included in the at least one target microservice set when the number of microservices corresponding to the set partitioning result meets a second preset condition;
[0128] The second preset condition includes: the number of microservices is greater than the number of target microservice sets. The microservice partitioning device provided by the embodiment of the present invention can execute the microservice partitioning method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the method.
[0129] Embodiment 4
[0130] An embodiment of the present invention provides a computer device, in which the microservice partitioning apparatus provided by an embodiment of the present invention can be integrated. Figure 4 This is a structural block diagram of a computer device provided in Embodiment 4 of the present invention. The computer device 400 may include: a memory 401, a processor 402, and a computer program stored in the memory 401 and executable on the processor, and the processor 402 implements the microservice partitioning method as described in the embodiment of the present invention when executing the computer program.
[0131] The computer device provided in the embodiment of the present invention can execute the microservice partitioning method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the method.
[0132] Embodiment 5
[0133] An embodiment of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used for a microservice partitioning method when executed by a computer processor, the method comprising:
[0134] Determine at least one microservice set consisting of multiple microservices in the business segment;
[0135] Constructing a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to the plurality of microservices in the business segment;
[0136] Calculating a parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and a preset function;
[0137] The multiple microservices in the business segment are divided into at least one target microservice set according to the parameter matrix.
[0138] Storage medium - any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDRRAM, SRAM, EDORAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the first computer system in which the program is executed, or may be located in a different second computer system, which is connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (for example, in different computer systems connected by a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.
[0139] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided in an embodiment of the present invention are not limited to the microservice partitioning operations described above, and can also execute related operations in the microservice partitioning method provided in any embodiment of the present invention.
[0140] The microservice partitioning device, equipment and storage medium provided in the above embodiments can execute the microservice partitioning method provided in any embodiment of the present invention, and have the corresponding functional modules and beneficial effects of executing the method. For technical details not described in detail in the above embodiments, please refer to the microservice partitioning method provided in any embodiment of the present invention.
[0141] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A microservice partitioning method, characterized in that: include: Determine at least one microservice set consisting of multiple microservices in the business segment; Constructing a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to the plurality of microservices in the business segment; Calculating a parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix and a preset function; Dividing the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix; The step of constructing a first membership matrix and a second membership matrix corresponding to the microservice set includes: Constructing a first membership matrix corresponding to the microservice set according to the current microservice set and the remaining microservice sets; constructing a second membership matrix corresponding to the microservice set according to the current microservice set; wherein the microservices in the current microservice set and the microservices in the remaining microservice sets constitute a plurality of microservices in the business segment; The step of calculating the parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix and a preset function includes: Constructing a unit matrix of parameters corresponding to the business segment; determining an objective function of the parameters corresponding to the business segment according to the first membership matrix, the second membership matrix, the degree matrix corresponding to the third membership matrix, and the unit matrix contained in the preset function; calculating a partial derivative result of the objective function; when the partial derivative result is less than or equal to a first threshold, determining the partial derivative result as the parameter matrix of the preset function; when the result of the objective function is greater than the first threshold, repeatedly performing the operation of calculating the partial derivative result of the objective function until the parameter matrix of the preset function is determined.
2. The method according to claim 1, characterized in that The determining of at least one microservice set consisting of multiple microservices in the business segment includes: According to the preset number of microservice sets, at least one microservice set consisting of multiple microservices in the business segment is determined; Alternatively, based on the principle of minimizing membership loss, the multiple microservices in the business segment are divided into at least one microservice set.
3. The method according to claim 1, characterized in that Before determining at least one microservice set consisting of multiple microservices in the business segment, the method further includes: Extract features of multiple microservices in the business database to obtain feature flags corresponding to each microservice; The business sectors corresponding to the multiple microservices are determined respectively according to the characteristic flags corresponding to each microservice.
4. The method according to claim 1 or 2, characterized in that: Dividing the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix includes: Determine a set partitioning result of the plurality of microservices according to the parameter matrix; When the number of sets corresponding to the set partitioning result satisfies a first preset condition, and the number of microservices corresponding to the set partitioning result satisfies a second preset condition, the set partitioning result is determined as at least one target microservice set, and a plurality of microservices included in the at least one target microservice set; When the result does not satisfy the first preset condition and / or does not satisfy the second preset condition, based on the principle of minimizing membership loss, the multiple microservices in the business segment are re-divided into at least one microservice set; Among them, the first preset condition includes: the number of the target microservice set is greater than or equal to 2; the second preset condition includes: the number of the microservices is greater than or equal to the number of the target microservice set.
5. The method according to claim 1 or 2, characterized in that: Dividing the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix includes: Determine a set partitioning result of the plurality of microservices according to the parameter matrix; When the number of microservices corresponding to the set partitioning result meets the second preset condition, determining the set partitioning result as at least one target microservice set and a plurality of microservices included in the at least one target microservice set; The second preset condition includes: the number of the microservices is greater than or equal to the number of the target microservice set.
6. A microservice partitioning device, characterized in that: include: A determination module, used to determine at least one microservice set consisting of multiple microservices in a business segment; A construction module, used to construct a first membership matrix and a second membership matrix corresponding to the microservice set, and a third membership matrix corresponding to multiple microservices in the business segment; A calculation module, configured to calculate a parameter matrix in the preset function according to the first membership matrix, the second membership matrix, the third membership matrix, and a preset function; A partitioning module, used to partition the multiple microservices in the business segment into at least one target microservice set according to the parameter matrix; The construction module is further used to construct a first membership matrix corresponding to the microservice set according to the current microservice set and the remaining microservice sets; and to construct a second membership matrix corresponding to the microservice set according to the current microservice set; wherein the microservices in the current microservice set and the microservices in the remaining microservice sets constitute multiple microservices in the business segment; Wherein, the calculation module includes: a construction unit, a first determination unit and a calculation unit; The construction unit is used to construct a unit matrix of parameters corresponding to the business segment; The first determination unit is used to determine the objective function of the parameters corresponding to the business segment according to the first membership matrix, the second membership matrix, the degree matrix corresponding to the third membership matrix, and the identity matrix contained in the preset function; The calculation unit is used to calculate the partial derivative result of the objective function; The first determination unit is also used to determine the partial derivative result as the parameter matrix of the preset function when the partial derivative result is less than or equal to the first threshold; and to repeatedly perform the operation of calculating the partial derivative result of the objective function when the result of the objective function is greater than the first threshold until the parameter matrix of the preset function is determined.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
