Micro-service flow information alignment method and device, computer device and storage medium
By obtaining and aligning call log information in the microservice system, the problem of data inconsistency in the microservice chain is solved, ensuring the correctness of distributed transactions in the microservice system.
Patent Information
- Application Number
- CN202310268411.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2043-03-20
AI Technical Summary
In a microservice system, if a microservice in the microservice chain crashes or reports an error, it can lead to inconsistencies in the service pipeline data, affecting the correctness of distributed transactions.
By acquiring and generating call log information between the called service and the calling service, and performing alignment processing based on this information, including state alignment and reversal processing, data consistency is ensured.
It achieves data consistency among each microservice in the microservice chain, ensuring the correctness of distributed transactions in the microservice system.
Smart Images

Figure CN116302369B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for aligning microservice pipeline information. Background Technology
[0002] Microservice systems are among the most common distributed systems today. When using microservice systems to handle distributed transactions, the microservices in the system call each other to form a microservice chain. The microservices on the chain can cooperate to complete the distributed transaction. However, if a microservice on the chain crashes or reports an error, it will cause inconsistencies in the service flow data of different microservices, affecting the correctness of the distributed transaction. Summary of the Invention
[0003] Therefore, it is necessary to provide a method, apparatus, computer equipment, and storage medium for aligning microservice pipeline information to ensure the consistency of service pipeline data in a microservice system, in order to address the aforementioned technical problems.
[0004] Firstly, this application provides a method for aligning microservice pipeline information. Applied to a microservice system, the microservice system includes a called service and a calling service, the method includes:
[0005] If the called service responds to the call request of the calling service, then the first call log information of the called service is obtained;
[0006] Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated;
[0007] Based on the first call log information and the second call log information, information alignment is performed between the called service and the calling service.
[0008] In one embodiment, the step of aligning information between the called service and the calling service based on the first call log information and the second call log information includes:
[0009] Based on the second call flow information, call status alignment information is generated in the call service;
[0010] The calling service feeds back the call status alignment information to the called service.
[0011] Based on the call status alignment information, the call status in the first call pipeline information is aligned in the called service.
[0012] In one embodiment, after the called service aligns the call state in the first call pipeline information according to the call state alignment information, the method further includes:
[0013] The first call log information of the called service is extracted in batches to obtain the first information to be verified;
[0014] Extract the second call log information of the called service in batches to obtain the second information to be verified;
[0015] If the first information to be verified and the second information to be verified are not aligned, the first information to be verified of the called service is corrected according to the second information to be verified of the called service.
[0016] In one embodiment, before performing a reversal process on the first call sequence information of the called service based on the second call sequence information of the called service if the first information to be verified and the second information to be verified are not aligned, the method further includes:
[0017] Based on the first information to be verified, detect whether the second call flow information in the second information to be verified is missing;
[0018] If any information is missing, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0019] If no missing information exists, check whether the call status in the first information to be verified is consistent with the call status in the second information to be verified.
[0020] If they are inconsistent, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0021] If they match, it is determined that the first information to be verified and the second information to be verified are aligned.
[0022] In one embodiment, the method further includes:
[0023] Obtain the number of concurrent processes when the calling service calls the called service, the average process time corresponding to the called service, and the preset time threshold;
[0024] If the average process time is greater than the preset time threshold, the number of concurrent processes is adjusted according to the preset time threshold and the average process time.
[0025] In one embodiment, the method further includes:
[0026] Obtain the average call success rate of the called service, the average call success rate of the called service, and a preset call success rate threshold;
[0027] If the average call success rate is not greater than the average call success rate, and the average call success rate is less than the preset call success rate threshold, then the microservice link between the calling service and the called service is broken.
[0028] Secondly, this application also provides a microservice pipeline information alignment device. Applied to a microservice system, the microservice system includes a called service and a calling service, the device includes:
[0029] The first call flow information acquisition module is used to acquire the first call flow information of the called service if it is detected that the called service responds to the call request of the calling service.
[0030] The second call flow information generation module generates the second call flow information of the calling service based on the feedback result of the called service to the call request.
[0031] The information alignment module is used to perform information alignment between the called service and the calling service based on the first call flow information and the second call flow information.
[0032] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0033] If a response from the called service to the calling service is detected, the first call log information of the called service is obtained.
[0034] Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated;
[0035] Based on the first call log information and the second call log information, information alignment is performed between the called service and the calling service.
[0036] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0037] If a response from the called service to the calling service is detected, the first call log information of the called service is obtained.
[0038] Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated;
[0039] Based on the first call log information and the second call log information, information alignment is performed between the called service and the calling service.
[0040] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0041] If a response from the called service to the calling service is detected, the first call log information of the called service is obtained.
[0042] Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated;
[0043] Based on the first call log information and the second call log information, information alignment is performed between the called service and the calling service.
[0044] The aforementioned microservice pipeline information alignment method, apparatus, computer device, and storage medium, upon detecting a response from a called service to a calling service's call request, acquire first call pipeline information of the called service; generate second call pipeline information of the calling service based on the feedback result of the called service to the call request; and perform information alignment between the called service and the calling service based on the first and second call pipeline information. Thus, when the called service responds to a call request, it automatically registers the first call pipeline information, and after receiving the feedback result of the call request, the calling service automatically registers the second call pipeline information. Finally, based on the first and second call pipeline information, the service pipeline information on the microservice chain where the calling service and the called service reside can be aligned, ensuring data consistency between each microservice on the microservice chain and guaranteeing the correctness of distributed transactions in the microservice system. Attached Figure Description
[0045] Figure 1 This is a diagram illustrating the application environment of a microservice pipeline information alignment method in one embodiment.
[0046] Figure 2 This is a flowchart illustrating a microservice pipeline information alignment method in one embodiment;
[0047] Figure 3 This is a flowchart illustrating the microservice pipeline information alignment method in another embodiment;
[0048] Figure 4 This is a schematic diagram of the composition architecture of a microservice system in one embodiment;
[0049] Figure 5 This is a schematic diagram of the module structure for aligning microservice pipeline information in one embodiment;
[0050] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0052] The microservice pipeline information alignment method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, the first terminal 102 communicates with the second terminal 104 via a network. The first terminal 102 can serve as a terminal for deploying and invoking services, and the second terminal 104 can serve as a terminal for deploying the invoked services. The invoking service in the first terminal 102 can call the invoked service in the second terminal 104 to form a microservice link. Both the first terminal 102 and the second terminal 104 can be, but are not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, portable wearable devices, and servers. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. The second terminal 104 can be a single terminal or a cluster; similarly, the first terminal 102 can be a single terminal or a cluster.
[0053] In one embodiment, such as Figure 2 As shown, a microservice pipeline information alignment method is provided, applied to a microservice system, which includes a called service and a calling service, and includes the following steps:
[0054] Step S10: If it is detected that the called service responds to the call request of the calling service, then the first call log information of the called service is obtained;
[0055] It's important to note that a microservices system is a distributed architecture. Using a microservices architecture, applications can be built into micro-independent components, with each application process running as a service; these services are called microservices. When handling distributed transactions based on a microservices system, microservices will call each other, forming microservice chains based on these call relationships. If a microservice in a microservice chain crashes or encounters an error, discrepancies will occur in the service flow data of the preceding and following microservices, making it difficult to guarantee data consistency within the microservices system.
[0056] As an example, step S10 includes: detecting whether the called service responds to the call request of the calling service; if so, registering and obtaining the first call log information of the called service, wherein the first call log information may be one or more of the following: link tracing log number, caller combined service name, call log number, time information, and status information.
[0057] As an example, the tracing sequence number can be a sequence number that marks the microservice link between the calling service and the called service; the call sequence number can be a sequence number that marks the current call process between the calling service and the passively called service; the time information can be the start time and end time of the call; and the status information can be information that identifies the call status, such as whether the call was successful or failed.
[0058] As an example, the calling service can be a composite service, and the called service can be an atomic service.
[0059] As an example, both the calling service and the called service can be composite services.
[0060] Atomic services are the basic, indivisible service units that make up an application. Composite services can be aggregates of multiple atomic services used to implement a specific function. For example, a composite service can be used to implement a money transfer function. Correspondingly, the microservices that make up the composite service can be atomic services that implement functions such as verifying bank card numbers, verifying passwords, and modifying account balances.
[0061] Step S20: Generate the second call log information of the calling service based on the feedback result of the called service to the call request;
[0062] In this embodiment, it should be noted that before sending a call request to the called service, the calling service first registers initial call log information. After receiving the feedback result of the call request, it modifies the initial call log information according to the feedback result to generate the second call log information of the calling service. The feedback result can be either a successful call or a failed call.
[0063] As an example, step S20 includes: receiving feedback results of the call request through the called service, and modifying the call status in the initial call log information originally set by the calling service according to the feedback results to obtain second call log information. For example, assuming the initial status flag in the initial call log information is 0, if the feedback result is a successful call, the initial status flag 0 is changed to a successful call status flag 1; if the feedback result is a failed call, the initial status flag 0 is changed to a failed call status flag 2.
[0064] As an example, if the service call has not received a feedback result within a preset time period, it can be determined that a call timeout has occurred. At this time, the call timeout status can be registered to indicate that the call has timed out. In this embodiment of the application, it is possible to record in real time whether each service call has timed out, so as to ensure the integrity of service pipeline data.
[0065] As an example, the second call log information can be one or more of the following: tracing log number, the name of the called party's atomic service, the call log number, time information, and status information. The tracing log number can be a log number marking the microservice link between the calling service and the called service; the call log number can be a log number marking the current call process between the calling service and the passively called service; the time information can be the start and end times of the call; and the status information can be information identifying the call status, such as call success or call failure.
[0066] Step S30: Based on the first call flow information and the second call flow information, perform information alignment between the called service and the calling service.
[0067] As an example, step S30 includes: generating corresponding call status alignment information based on the call status in the second call flow information; feeding back the call status alignment information to the called service; and modifying the call status in the first call flow information of the called service based on the call status alignment information, so as to align information between the called service and the calling service.
[0068] It should be noted that after the called service successfully responds to the calling service's call request, the called service's call status can be registered as a successful call. However, if the calling service crashes during the service process, the calling service cannot successfully implement the corresponding function based on the called service, and the calling service's call status will be changed to a failed call. At this time, the call statuses of the calling service and the non-called service are different, which means that there will be a misalignment of information between the calling service and the called service.
[0069] As an example, step S30 includes: monitoring the call status in the second call flow information of the calling service; if the call status in the second call flow information changes, generating corresponding call status alignment information based on the call status in the second call flow information; feeding back the call status alignment information to the called service; and modifying the call status in the first call flow information of the called service based on the call status alignment information to perform information alignment between the called service and the calling service.
[0070] The aforementioned microservice pipeline information alignment method, apparatus, computer device, and storage medium, upon detecting a response from a called service to a calling service's call request, acquire first call pipeline information of the called service; generate second call pipeline information of the calling service based on the feedback result of the called service to the call request; and perform information alignment between the called service and the calling service based on the first and second call pipeline information. Thus, when the called service responds to a call request, it automatically registers the first call pipeline information, and after receiving the feedback result of the call request, the calling service automatically registers the second call pipeline information. Finally, based on the first and second call pipeline information, the service pipeline information on the microservice chain where the calling service and the called service reside can be aligned, ensuring data consistency between each microservice on the microservice chain and guaranteeing the correctness of distributed transactions in the microservice system.
[0071] In one embodiment, based on the above embodiments, information alignment is performed between the called service and the calling service according to the first call flow information and the second call flow information, including:
[0072] Step S31: Generate call status alignment information in the call service based on the second call flow information;
[0073] Step S32: The calling service feeds back the call status alignment information to the called service.
[0074] Step S33: According to the call status alignment information, the call status in the first call pipeline information is aligned in the called service.
[0075] It should be noted that since the called service usually cannot know the status of the calling service in real time, the call status of the called service after responding to the call request cannot be determined as either a successful or failed call. The calling service needs to determine whether the call status is successful or failed.
[0076] As an example, steps S31 to S33 include: generating call status alignment information in the calling service based on the call status in the second call log information; feeding back the call status alignment information to the called service through the calling service; and modifying the call status in the first call log information of the called service to be consistent with the call status in the second call log information based on the call status alignment information. Thus, this embodiment of the application, based on the separate registration of log information by the calling service and the called service, further ensures that once the call status of the calling service changes, the call status of the called service can change accordingly in real time, ensuring that the call status of the calling service and the call status of the called service remain consistent in real time, thereby guaranteeing data consistency in the microservice system.
[0077] In one embodiment, based on the above embodiments, referring to Figure 3 After aligning the call status in the first call pipeline information according to the call status alignment information, the method further includes:
[0078] Step S34: Extract the first call log information of the called service in batches to obtain the first information to be verified;
[0079] Step S35: Extract the second call log information of the called service in batches to obtain the second information to be verified;
[0080] Step S36: If the first information to be verified and the second information to be verified are not aligned, then the first information to be verified of the called service is corrected according to the second information to be verified of the called service.
[0081] It should be noted that when handling distributed transactions based on the above microservice system, even though the calling service and the called service exchange call status information in real time, due to various complex factors such as network fluctuations or service downtime, there may still be discrepancies in the call status registered between the called service and the called service over time.
[0082] As an example, steps S34 to S36 include: batch extracting the first call log information of the called service to obtain the first verification information; batch extracting the second call log information of the called service to obtain the second verification information. The batch extraction method can be periodic extraction at regular intervals, specifically, batch extraction can be performed once every periodic time T, or quantitative periodic extraction, specifically, batch extraction can be performed once for every N registered log information. If the first call log information in the first verification information is not aligned with the corresponding second call log information in the second verification information, then the corresponding first call log information of the called service is corrected according to the second call log information of the called service to align the second call log information of the called service and the first call log information of the called service.
[0083] It should be noted that the purpose of the reversal process is to ensure that the first and second call flow information are consistent after the reversal process. When performing the reversal process, data can be added or deleted, and there is no limitation here.
[0084] As an example, before performing the reversal processing on the first call sequence information of the called service based on the second call sequence information of the called service if the first verification information and the second verification information are not aligned, the process includes:
[0085] Step A10: Based on the first information to be verified, detect whether the second call flow information in the second information to be verified is missing;
[0086] Step A20: If there is a missing information, it is determined that the first information to be checked and the second information to be checked are not aligned.
[0087] Step A30: If there is no missing information, check whether the call status in the first information to be verified is consistent with the call status in the second information to be verified.
[0088] Step A40: If they are inconsistent, it is determined that the first information to be checked and the second information to be checked are not aligned.
[0089] Step A50: If they match, then it is determined that the first information to be checked and the second information to be checked are aligned.
[0090] As an example, steps A10 to A50 include: using the first call log information in the first information to be verified as a benchmark, detecting whether the second call log information in the second information to be verified is missing; if it is missing, determining that the first information to be verified and the second information to be verified are not aligned; if it is not missing, detecting whether the call status in the first information to be verified is consistent with the call status in the second information to be verified; if they are inconsistent, determining that the first information to be verified and the second information to be verified are not aligned; if they are consistent, determining that the first information to be verified and the second information to be verified are aligned. For example, assuming that the second call log information in the second information to be verified is not missing, the call statuses in the first information to be verified are 1111211111, and the call statuses in the second information to be verified are 1112211111, where 1 indicates a successful call and 2 indicates a failed call, then it can be determined that the call statuses in the first information to be verified are inconsistent with the call statuses in the second information to be verified.
[0091] As an example, before the step of correcting the first call sequence information of the called service based on the second call sequence information of the called service if the first and second verification information are not aligned, the method further includes:
[0092] Based on the first information to be verified, it is determined whether the second call flow information in the second information to be verified is missing; if it is missing, it is determined that the first information to be verified and the second information to be verified are not aligned; if it is not missing, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0093] As an example, before the step of correcting the first call sequence information of the called service based on the second call sequence information of the called service if the first and second verification information are not aligned, the method further includes:
[0094] The system checks whether the call status in the first information to be verified is consistent with the call status in the second information to be verified. If they are inconsistent, it is determined that the first information to be verified and the second information to be verified are not aligned. If they are consistent, it is determined that the first information to be verified and the second information to be verified are aligned.
[0095] In this embodiment, based on registering call log information for both the calling service and the called service, and the call status of the interactive calling service and the called service, the first call log information of the called service is extracted in batches periodically or quantitatively to form first verification information, and the second call log information of the calling service is extracted in batches to form second verification information. In this way, when the first verification information and the second verification information are inconsistent, the first call log information of the called service can be reversed in batches according to the second call log information of the calling service. This ensures that the first call log information in the entire microservice system is always consistent with the corresponding second call log information, thus further ensuring that the information of the calling service and the called service can be kept consistent, ensuring data consistency in the microservice system, and ensuring the correctness of distributed transactions in the microservice system.
[0096] In one embodiment, based on the above embodiments, the microservice pipeline information alignment method further includes:
[0097] Step B10: Obtain the number of concurrent processes when the calling service calls the called service, the average process time corresponding to the called service, and the preset time threshold.
[0098] Step B20: If the average process time is greater than the preset time threshold, then adjust the number of concurrent processes according to the preset time threshold and the average process time.
[0099] It should be noted that the average process time can be the average time of all corresponding processes of the called service within a unit of time, the preset time threshold can be the maximum time allowed for the called service, and the number of concurrent processes can be the number of processes of the calling service running in parallel with the called service.
[0100] As an example, steps B10 to B20 include: obtaining the number of concurrent processes when the calling service calls the called service, the average process time corresponding to the called service, and a preset time threshold; if the average process time is not greater than the preset time threshold, the number of concurrent processes calling the service remains unchanged; if the average process time is greater than the preset time threshold, the number of concurrent processes calling the service is adjusted according to the difference between the average process time and the preset time threshold.
[0101] As an example, the calculation process for adjusting the number of concurrent processes based on the preset time consumption threshold and the average process consumption is as follows:
[0102] Z′=Z*XY
[0103] Where Z is the number of concurrent processes before adjustment, Z′ is the number of concurrent processes after adjustment, X is the average process time, and Y is the preset time threshold.
[0104] In this embodiment, the system can automatically detect whether the number of concurrent processes calling the service needs to be adjusted based on the average process time of the called service and the preset time threshold. This eliminates the need for manual setting of the number of concurrent processes calling the service. The method of automatically setting the number of concurrent processes calling the service in this embodiment is more flexible and accurate. In high-concurrency scenarios, it can minimize transaction blocking and timeout waiting between the calling service and the called service, reduce the probability of service call failures in the microservice system, thereby reducing data inconsistency caused by call failures and ensuring the correctness of distributed transactions in the microservice system.
[0105] In one embodiment, based on the above embodiments, the microservice pipeline information alignment method further includes:
[0106] Step C10: Obtain the average call success rate of the called service, the average call success rate of the called service, and the preset call success rate threshold.
[0107] Step C20: If the average call success rate is not greater than the average call success rate, and the average call success rate is less than the preset call success rate threshold, then the microservice link between the calling service and the called service is broken.
[0108] It should be noted that the average call success rate is the average probability that the called service is successfully called within a unit of time, while the average call success rate is the average probability that the calling service is successfully called within a unit of time. The preset call success rate threshold is the minimum call success rate set by the calling service.
[0109] As an example, steps C10 to C20 include: obtaining the average call success rate of the called service, the average call success rate of the calling service, and a preset call success rate threshold; if the average call success rate is greater than the preset call success rate threshold, the microservice link between the calling service and the called service is not circuit-broken; if the average call success rate is not greater than the preset call success rate threshold and is not less than the preset call success rate threshold, the microservice link between the calling service and the called service is not circuit-broken; if the average call success rate is not greater than the average call success rate and is less than the preset call success rate threshold, the microservice link between the calling service and the called service is circuit-broken, and a call failure feedback result is directly returned to the calling service and the called service. Thus, by setting a circuit breaker strategy in this embodiment, when the call success rate is low, the failure result can be directly reported to the calling service and the called service without making a real microservice call. In high-concurrency scenarios, transaction blocking and timeout waiting between the calling service and the called service can be avoided to the greatest extent, which can reduce the probability of service call failure in the microservice system, thereby reducing data inconsistency caused by call failure and ensuring the correctness of distributed transactions in the microservice system.
[0110] Furthermore, in one embodiment, reference is made to... Figure 4 , Figure 4 This is a schematic diagram of the architecture of a microservice system. A microservice system includes a calling service, a called service, a calling-side pipeline processing module, a calling-side service governance module, a called-side pipeline processing module, and a batch service pipeline processing module.
[0111] As an example, if a response from the called service to the calling service is detected, the called service's pipeline processing module registers and obtains the first call pipeline information of the called service. When the calling service initiates a call request, the calling service's pipeline processing module also registers the initial call pipeline information of the calling service. Then, the calling service's pipeline processing module modifies the initial call pipeline information according to the feedback result corresponding to the call request received by the calling service to obtain the second call pipeline information. The calling service's pipeline processing module asynchronously feeds back call status alignment information to the called service's pipeline processing module. The called service's pipeline processing module modifies the call status in the first call pipeline information according to the call status alignment information, thereby achieving information alignment between the calling service and the called service.
[0112] In addition, the batch service pipeline processing module will also extract the first call pipeline information of the called service in batches at regular intervals or in quantitative quantities to obtain the first information to be verified; extract the second call pipeline information of the called service in batches to obtain the second information to be verified; determine whether the first information to be verified and the second information to be verified are consistent; if they are inconsistent, the first call pipeline information of the called service will be reversed according to the second call pipeline information of the called service.
[0113] In addition, the caller service governance module will also obtain the number of concurrent processes when the calling service calls the called service, the average process time of the called service, and the preset time threshold; if the average process time is greater than the preset time threshold, the number of concurrent processes will be adjusted according to the preset time threshold and the average process time.
[0114] In addition, the caller service governance module will also obtain the average call success rate of the called service, the average call success rate of the calling service, and the preset call success rate threshold. If the average call success rate is not greater than the average call success rate and the average call success rate is less than the preset call success rate threshold, the microservice link between the calling service and the called service will be broken.
[0115] Thus, the microservice system of this embodiment, by setting up a caller-side pipeline processing module and a callee-side pipeline processing module, can respectively register the first call pipeline information of the called service and the second call pipeline information of the calling service. Furthermore, by interacting with the call status between the calling and called services, the first and second call pipeline information can be aligned, achieving data alignment through accounting and reconciliation of pipeline data, ensuring data consistency in the microservice system. Building upon the above, the microservice system of this embodiment also includes a batch service pipeline processing module, which can periodically or quantitatively check whether the first call pipeline information of the called service and the second call pipeline information of the calling service are consistent. If they are inconsistent, the first call pipeline information of the called service is adjusted based on the second call pipeline information of the calling service. The reversal process further aligns the data between the calling and called services, ensuring data consistency within the microservice system. Building upon this, the microservice system in this embodiment also includes a caller service governance module. This module employs rate limiting and circuit breaker strategies. In high-concurrency scenarios, rate limiting minimizes transaction congestion and timeouts between the calling and called services. Circuit breaker directly reports call failures to both the calling and called services when the success rate is low, without actually initiating a microservice call. Therefore, both rate limiting and circuit breaker strategies reduce the probability of service call failures in the microservice system, thereby reducing data inconsistencies caused by call failures and ultimately ensuring the correctness of distributed transactions within the microservice system.
[0116] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0117] Based on the same inventive concept, this application also provides a microservice pipeline information alignment device for implementing the microservice pipeline information alignment method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more microservice pipeline information alignment device embodiments provided below can be found in the limitations of the microservice pipeline information alignment method described above, and will not be repeated here.
[0118] In one embodiment, such as Figure 5 As shown, a microservice pipeline information alignment device is provided, applied to a microservice system, which includes a called service and a calling service, comprising:
[0119] The first call flow information acquisition module 310 is used to acquire the first call flow information of the called service if it is detected that the called service responds to the call request of the calling service.
[0120] The second call flow information generation module 320 generates second call flow information for the calling service based on the feedback result of the called service to the call request.
[0121] The information alignment module 330 is used to perform information alignment between the called service and the calling service based on the first call flow information and the second call flow information.
[0122] In one embodiment, the information alignment module 330 is used for:
[0123] Based on the second call flow information, the calling service generates call status alignment information; the calling service feeds back the call status alignment information to the called service; based on the call status alignment information, the called service aligns the call status in the first call flow information.
[0124] In one embodiment, the device further includes:
[0125] A batch process module (not shown in the figure) is used to extract the first call flow information of the called service in batches to obtain the first verification information; extract the second call flow information of the called service in batches to obtain the second verification information; if the first verification information and the second verification information are not aligned, the first call flow information of the called service is corrected according to the second call flow information of the called service.
[0126] In one embodiment, the batch processing module is further configured to:
[0127] Based on the first information to be verified, it is checked whether the second call flow information in the second information to be verified is missing; if it is missing, it is determined that the first information to be verified and the second information to be verified are not aligned; if it is not missing, it is checked whether the call status in the first information to be verified is consistent with the call status in the second information to be verified; if they are inconsistent, it is determined that the first information to be verified and the second information to be verified are not aligned; if they are consistent, it is determined that the first information to be verified and the second information to be verified are aligned.
[0128] In one embodiment, the device further includes:
[0129] The rate limiting module (not shown in the figure) is used to obtain the number of concurrent processes when the calling service calls the called service, the average process time of the called service, and a preset time threshold; if the average process time is greater than the preset time threshold, the number of concurrent processes is adjusted according to the preset time threshold and the average process time.
[0130] In one embodiment, the device further includes:
[0131] The circuit breaker module (not shown in the figure) is used to obtain the average call success rate of the called service, the average call success rate of the calling service, and a preset call success rate threshold. If the average call success rate is not greater than the average call success rate and the average call success rate is less than the preset call success rate threshold, then the microservice link between the calling service and the called service is broken.
[0132] Each module in the aforementioned microservice pipeline information alignment device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0133] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores various strings and other data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a microservice pipeline information alignment method.
[0134] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0135] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0136] If a response from the called service to the calling service is detected, the first call log information of the called service is obtained.
[0137] Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated;
[0138] Based on the first call log information and the second call log information, information alignment is performed between the called service and the calling service.
[0139] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0140] Based on the second call flow information, call status alignment information is generated in the call service;
[0141] The calling service feeds back the call status alignment information to the called service.
[0142] Based on the call status alignment information, the call status in the first call pipeline information is aligned in the called service.
[0143] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0144] The first call log information of the called service is extracted in batches to obtain the first information to be verified;
[0145] Extract the second call log information of the called service in batches to obtain the second information to be verified;
[0146] If the first information to be verified and the second information to be verified are not aligned, the first information to be verified of the called service is corrected according to the second information to be verified of the called service.
[0147] The method further includes, before the step of correcting the first call sequence information of the called service based on the second call sequence information of the called service if the first information to be verified and the second information to be verified are not aligned, the method further includes:
[0148] Based on the first information to be verified, detect whether the second call flow information in the second information to be verified is missing;
[0149] If any information is missing, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0150] If no missing information exists, check whether the call status in the first information to be verified is consistent with the call status in the second information to be verified.
[0151] If they are inconsistent, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0152] If they match, it is determined that the first information to be verified and the second information to be verified are aligned.
[0153] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0154] Obtain the number of concurrent processes when the calling service calls the called service, the average process time corresponding to the called service, and the preset time threshold;
[0155] If the average process time is greater than the preset time threshold, the number of concurrent processes is adjusted according to the preset time threshold and the average process time.
[0156] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0157] Obtain the average call success rate of the called service, the average call success rate of the called service, and a preset call success rate threshold;
[0158] If the average call success rate is not greater than the average call success rate, and the average call success rate is less than the preset call success rate threshold, then the microservice link between the calling service and the called service is broken.
[0159] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0160] If a response from the called service to the calling service is detected, the first call log information of the called service is obtained.
[0161] Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated;
[0162] Based on the first call log information and the second call log information, information alignment is performed between the called service and the calling service.
[0163] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0164] Based on the second call flow information, call status alignment information is generated in the call service;
[0165] The calling service feeds back the call status alignment information to the called service.
[0166] Based on the call status alignment information, the call status in the first call pipeline information is aligned in the called service.
[0167] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0168] The first call log information of the called service is extracted in batches to obtain the first information to be verified;
[0169] Extract the second call log information of the called service in batches to obtain the second information to be verified;
[0170] If the first information to be verified and the second information to be verified are not aligned, then the first information to be verified of the called service is corrected according to the second information to be verified of the called service.
[0171] The method further includes, before the step of correcting the first call sequence information of the called service based on the second call sequence information of the called service if the first information to be verified and the second information to be verified are not aligned, the method further includes:
[0172] Based on the first information to be verified, detect whether the second call flow information in the second information to be verified is missing;
[0173] If any information is missing, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0174] If no missing information exists, check whether the call status in the first information to be verified is consistent with the call status in the second information to be verified.
[0175] If they are inconsistent, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0176] If they match, it is determined that the first information to be verified and the second information to be verified are aligned.
[0177] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0178] Obtain the number of concurrent processes when the calling service calls the called service, the average process time corresponding to the called service, and the preset time threshold;
[0179] If the average process time is greater than the preset time threshold, the number of concurrent processes is adjusted according to the preset time threshold and the average process time.
[0180] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0181] Obtain the average call success rate of the called service, the average call success rate of the called service, and a preset call success rate threshold;
[0182] If the average call success rate is not greater than the average call success rate, and the average call success rate is less than the preset call success rate threshold, then the microservice link between the calling service and the called service is broken.
[0183] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0184] If a response from the called service to the calling service is detected, the first call log information of the called service is obtained.
[0185] Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated;
[0186] Based on the first call log information and the second call log information, information alignment is performed between the called service and the calling service.
[0187] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0188] Based on the second call flow information, call status alignment information is generated in the call service;
[0189] The calling service feeds back the call status alignment information to the called service.
[0190] Based on the call status alignment information, the call status in the first call pipeline information is aligned in the called service.
[0191] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0192] The first call log information of the called service is extracted in batches to obtain the first information to be verified;
[0193] Extract the second call log information of the called service in batches to obtain the second information to be verified;
[0194] If the first information to be verified and the second information to be verified are not aligned, the first information to be verified of the called service is corrected according to the second information to be verified of the called service.
[0195] The method further includes, before the step of correcting the first call sequence information of the called service based on the second call sequence information of the called service if the first information to be verified and the second information to be verified are not aligned, the method further includes:
[0196] Based on the first information to be verified, detect whether the second call flow information in the second information to be verified is missing;
[0197] If any information is missing, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0198] If no missing information exists, check whether the call status in the first information to be verified is consistent with the call status in the second information to be verified.
[0199] If they are inconsistent, it is determined that the first information to be verified and the second information to be verified are not aligned.
[0200] If they match, it is determined that the first information to be verified and the second information to be verified are aligned.
[0201] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0202] Obtain the number of concurrent processes when the calling service calls the called service, the average process time corresponding to the called service, and the preset time threshold;
[0203] If the average process time is greater than the preset time threshold, the number of concurrent processes is adjusted according to the preset time threshold and the average process time.
[0204] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0205] Obtain the average call success rate of the called service, the average call success rate of the called service, and a preset call success rate threshold;
[0206] If the average call success rate is not greater than the average call success rate, and the average call success rate is less than the preset call success rate threshold, then the microservice link between the calling service and the called service is broken.
[0207] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0208] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0209] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for aligning microservice pipeline information, characterized in that, Applied to a microservice system, wherein the microservice system includes a called service and a calling service, the method includes: If the called service responds to the call request of the calling service, then the first call log information of the called service is obtained; Based on the feedback result of the called service to the call request, the second call log information of the calling service is generated; Based on the second call flow information, call status alignment information is generated in the call service; The calling service feeds back the call status alignment information to the called service. Based on the call status alignment information, the call status in the first call pipeline information is aligned in the called service; The first call log information of the called service is extracted in batches to obtain the first information to be verified; Extract the second call log information of the called service in batches to obtain the second information to be verified; If the first information to be verified and the second information to be verified are not aligned, the first information to be verified of the called service is corrected according to the second information to be verified of the called service. Before performing correction processing on the first call sequence information of the called service based on the second call sequence information of the called service if the first information to be verified and the second information to be verified are not aligned, the method further includes: Based on the first information to be verified, detect whether the second call flow information in the second information to be verified is missing; If any information is missing, it is determined that the first information to be verified and the second information to be verified are not aligned. If no missing information exists, check whether the call status in the first information to be verified is consistent with the call status in the second information to be verified. If they are inconsistent, it is determined that the first information to be verified and the second information to be verified are not aligned. If they match, it is determined that the first information to be verified and the second information to be verified are aligned.
2. The microservice pipeline information alignment method according to claim 1, characterized in that, The method further includes: Obtain the number of concurrent processes when the calling service calls the called service, the average process time corresponding to the called service, and the preset time threshold; If the average process time is greater than the preset time threshold, the number of concurrent processes is adjusted according to the preset time threshold and the average process time.
3. The microservice pipeline information alignment method according to claim 1, characterized in that, The method further includes: Obtain the average call success rate of the called service, the average call success rate of the called service, and a preset call success rate threshold; If the average call success rate is not greater than the average call success rate, and the average call success rate is less than the preset call success rate threshold, then the microservice link between the calling service and the called service is broken.
4. A microservice pipeline information alignment device, characterized in that, Applied to a microservice system, the microservice system including a called service and a calling service, the apparatus includes: The first call flow information acquisition module is used to acquire the first call flow information of the called service if it is detected that the called service responds to the call request of the calling service. The second call flow information generation module generates the second call flow information of the calling service based on the feedback result of the called service to the call request. An information alignment module is used to generate call status alignment information in the calling service based on the second call flow information; to feed back the call status alignment information to the called service through the calling service; to align the call status in the first call flow information in the called service according to the call status alignment information; to batch extract the first call flow information of the called service to obtain first verification information; to batch extract the second call flow information of the calling service to obtain second verification information; if the first verification information and the second verification information are not aligned, to perform a reversal process on the first call flow information of the called service according to the second call flow information of the calling service; wherein, in the case of... If the first information to be verified and the second information to be verified are not aligned, before correcting the first call flow information of the called service based on the second call flow information of the called service, the method further includes: based on the first information to be verified, detecting whether there is a missing second call flow information in the second information to be verified; if there is a missing information, determining that the first information to be verified and the second information to be verified are not aligned; if there is no missing information, detecting whether the call status in the first information to be verified is consistent with the call status in the second information to be verified; if they are inconsistent, determining that the first information to be verified and the second information to be verified are not aligned; if they are consistent, determining that the first information to be verified and the second information to be verified are aligned.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Routing method and routing machine for PCB (printed circuit board)
CN114364128A
Micro-service calling method and device, electronic equipment and readable storage medium
CN115509770A