A micro-service calling method, system, computer device and storage medium
By sending the interface address and subscription information to the target scheduler, the consistency and availability issues in microservice calls are resolved, and the efficiency of microservice calls is improved.
Patent Information
- Application Number
- CN202311376045.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-19
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-10-19
AI Technical Summary
Microservices cannot meet consistency and availability requirements during the invocation process, resulting in reduced efficiency.
By sending the interface address to the target scheduler after receiving the query command and sending subscription information in response to the subscription request, the second microservice can subscribe to the data of the first microservice, satisfying the consistency requirement and responding to the call request in a timely manner to ensure availability.
It achieves consistency and availability requirements during microservice calls, and improves call efficiency.
Smart Images

Figure CN117560414B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of communication technology and finance, and in particular to a microservice invocation method, system, computer device, and storage medium. Background Technology
[0002] In the financial sector, with the popularization of electronic information technology, more and more financial transactions are being completed online by both parties. When processing financial transactions online, due to the complexity of the financial transactions, it may be necessary to call multiple different microservices to process the financial transactions.
[0003] However, microservices cannot meet consistency and availability requirements during the invocation process. The consistency requirement means that all microservices have the same data at the same time, and the availability requirement means that the invocation request is guaranteed to respond regardless of success or failure. This makes it easy to encounter errors during the invocation of microservices, thereby reducing the efficiency of invocation. Summary of the Invention
[0004] The main objective of this invention is to provide a microservice invocation method, system, computer device, and storage medium, aiming to solve the technical problem that microservices cannot meet consistency and availability requirements during invocation, thereby reducing the efficiency of microservice invocation.
[0005] To achieve the above objectives, the present invention provides a microservice invocation method, the method comprising:
[0006] Upon receiving a first query instruction from the first microservice, the first interface address of the target scheduler in the scheduler cluster is sent to the first microservice; the target scheduler is the scheduler in the scheduler cluster that stores the data shards corresponding to the first microservice, and the first microservice is the microservice called by the second microservice;
[0007] Receive the second query command sent by the second microservice;
[0008] In response to the second query command, the first interface address is sent to the second microservice;
[0009] Receive the subscription request sent by the second microservice to the target scheduler;
[0010] In response to the subscription request, the subscription information of the first microservice is sent to the second microservice so that the second microservice can call the first microservice.
[0011] Optionally, before receiving the second query instruction sent by the second microservice, the method further includes:
[0012] Receive the control machine query command sent by the first microservice;
[0013] In response to the control machine query instruction, the second interface address of the control machine in the scheduler cluster is sent to the first microservice; the control machine query instruction is generated based on the call instruction sent by the second microservice to the first microservice.
[0014] Receive the target scheduler query instruction sent by the first microservice to the control machine;
[0015] In response to the target scheduler query command, the first interface address of the target scheduler is sent to the first microservice.
[0016] Optionally, the method further includes:
[0017] The system controls each scheduler in the scheduler cluster to shard the stored data and synchronize it to the preset execution machine cluster.
[0018] The scheduling machine cluster includes N scheduling machines, and the execution machine cluster includes N execution machines that correspond one-to-one with the N scheduling machines. The data shards stored in each execution machine are the same as the data shards stored in the corresponding scheduling machine, where N is a positive integer greater than 1.
[0019] Optionally, the method further includes:
[0020] Each executor in the executor cluster is controlled to write the microservice data from the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the executor cluster.
[0021] Optionally, the method further includes:
[0022] If an error is detected in the subscription information of the first microservice, the subscription information of the first microservice is read from the execution machine cluster;
[0023] The subscription information of the first microservice is resent to the second microservice so that the second microservice can call the first microservice.
[0024] Optionally, the scheduling machine cluster includes a control machine and at least one scheduling machine, and the method further includes:
[0025] Each scheduler sends a registration request to the control machine to register the interface address corresponding to each scheduler on the control machine;
[0026] The control machine synchronizes microservice data to each scheduler based on a consistency protocol.
[0027] Optionally, the method further includes:
[0028] Each scheduler in the scheduler cluster is controlled to write the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the scheduler cluster.
[0029] In addition, to achieve the above objectives, the present invention also provides a microservice system, which includes a scheduler cluster, a first microservice, and a second microservice;
[0030] The second microservice is used to send a call request to the first microservice;
[0031] The first microservice is used to send a first query instruction to the scheduler cluster based on the call request;
[0032] The scheduling machine cluster is used to send the first interface address of the target scheduling machine to the first microservice when it receives the first query instruction sent by the first microservice; the target scheduling machine is the scheduling machine in the scheduling machine cluster that stores the data shards corresponding to the first microservice.
[0033] Receive the second query command sent by the second microservice;
[0034] In response to the second query command, the first interface address is sent to the second microservice;
[0035] Receive the subscription request sent by the second microservice to the target scheduler;
[0036] In response to the subscription request, the subscription information of the first microservice is sent to the second microservice;
[0037] The second microservice is also used to invoke the first microservice based on the subscription information.
[0038] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution:
[0039] The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the microservice invocation method proposed in any of the embodiments of this application.
[0040] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below:
[0041] The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the microservice invocation method proposed in any of the embodiments of this application.
[0042] Compared with the prior art, the embodiments of this application have the following main advantages:
[0043] This invention provides a microservice invocation method, a system computer device, and a storage medium. The microservice invocation method includes: upon receiving a first query instruction from a first microservice, sending the first interface address of a target scheduler in a scheduler cluster to the first microservice; the target scheduler is a scheduler in the scheduler cluster that stores data shards corresponding to the first microservice, and the first microservice is a microservice invoked by a second microservice; receiving a second query instruction from the second microservice; responding to the second query instruction, sending the first interface address to the second microservice; receiving a subscription request from the second microservice to the target scheduler; and responding to the subscription request, sending subscription information of the first microservice to the second microservice, so that the second microservice can invoke the first microservice. In this embodiment of the invention, by having the target scheduler respond to the subscription request from the second microservice and send the subscription information of the first microservice to the second microservice, the second microservice can subscribe to the microservice data of the first microservice, satisfying consistency requirements; and when the first microservice is invoked by the second microservice, promptly responding to both the instructions sent by the first and second microservices, ensuring that the invocation request from the second microservice to the first microservice is responded to in a timely manner, satisfying availability requirements. This satisfies the consistency and availability requirements of microservices during the invocation process, thereby improving the efficiency of invoking microservices. Attached Figure Description
[0044] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is an exemplary system architecture diagram to which this application can be applied;
[0046] Figure 2 This is a flowchart of the microservice invocation method provided in an embodiment of the present invention;
[0047] Figure 3 This is an application scenario diagram of the microservice invocation method according to this application;
[0048] Figure 4 This is a schematic diagram of the structure of a microservice system according to this application;
[0049] Figure 5 This is a basic structural block diagram of the computer device in this embodiment. Detailed Implementation
[0050] The data format determination method provided in this invention is applied to a data processing system. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing specific embodiments only and is not intended to limit the application. The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or accompanying drawings of this application are used to distinguish different objects, not to describe a specific order.
[0051] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0052] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0053] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0054] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, and social online platform software.
[0055] Terminal devices 101, 102, and 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 players (Moving Picture Experts Group Audio Layer IV), laptops, and desktop computers, etc.
[0056] Server 105 can be a server that provides various services, such as a backend server that supports the pages displayed on terminal devices 101, 102, and 103.
[0057] It should be noted that the microservice invocation method provided in this application embodiment is generally executed by a server / terminal device, and correspondingly, the microservice system is generally set up in the server / terminal device.
[0058] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0059] Continue to refer to Figure 2 The diagram illustrates a flowchart of an embodiment of the microservice invocation method proposed in this application. This embodiment can acquire and process relevant data based on artificial intelligence technology, and the microservice method can be applied to a microservice system.
[0060] It should be noted that the microservice invocation method proposed in this application is applied to a microservice system, which includes a service provider, a registry center, and a service discoverer. The service provider includes the first microservice, which is the microservice being invoked, and the service discoverer includes the second microservice. The registry center includes a scheduler cluster, which includes multiple schedulers, also known as Master machines.
[0061] In an optional application scenario, the aforementioned service providers include a monitoring center, a tracking center, and a decision center, and the aforementioned service discoverers include a monitoring center and a decision center.
[0062] The microservice invocation method provided in this embodiment of the invention includes the following steps:
[0063] S210, upon receiving the first query instruction sent by the first microservice, send the first interface address of the target scheduler in the scheduler cluster to the first microservice.
[0064] It should be noted that the first microservice mentioned above is the microservice called by the second microservice, and the first query instruction mentioned above is used to represent the interface address of the target scheduler.
[0065] In this step, the scheduler cluster receives a first query instruction sent by the first microservice and, in response to the first query instruction, sends the first interface address of the target scheduler to the first microservice. The scheduler cluster stores data shards corresponding to each microservice, and these data shards store microservice data. The target scheduler is the scheduler in the scheduler cluster that stores the data shards corresponding to the first microservice. The first query instruction is used to query the first interface address of the target scheduler. Optionally, the interface address can be a Feign interface, and each interface address can correspond to a Uniform Resource Identifier (URI) address.
[0066] S220 receives the second query command sent by the second microservice.
[0067] The second microservice mentioned above is the microservice that calls the first microservice, and the second query instruction mentioned above is used to query the first interface address of the target scheduler.
[0068] Optionally, before receiving the second query instruction sent by the second microservice, the method further includes:
[0069] Receive the control machine query command sent by the first microservice;
[0070] In response to the control machine query instruction, the second interface address of the control machine in the scheduler cluster is sent to the first microservice; the control machine query instruction is generated based on the call instruction sent by the second microservice to the first microservice.
[0071] Receive the target scheduler query instruction sent by the first microservice to the control machine;
[0072] In response to the target scheduler query command, the first interface address of the target scheduler is sent to the first microservice.
[0073] In this embodiment, another optional implementation method for the first microservice to obtain the first interface address of the target scheduler is as follows:
[0074] The second microservice sends a call instruction to the first microservice, so that the first microservice generates a controller query instruction.
[0075] The first microservice sends a control machine query command to the scheduling machine cluster. The control machine query command is used to query the second interface address of the control machine in the scheduling machine cluster. It should be noted that the control machine can control any scheduling machine in the scheduling machine cluster.
[0076] The scheduling machine cluster responds to the control machine query command by sending the second interface address of the control machine in the scheduling machine cluster to the first microservice.
[0077] The first microservice sends a target scheduler query instruction to the control machine based on the second interface address. The target scheduler query instruction is used to query the target scheduler in the scheduler cluster.
[0078] The scheduling cluster responds to the target scheduling query command by sending the first interface address of the target scheduling machine to the first microservice.
[0079] S230, in response to the second query instruction, send the first interface address to the second microservice.
[0080] In this step, after receiving the second query instruction, the scheduler cluster responds by sending the first interface address to the second microservice.
[0081] S240, receive the subscription request sent by the second microservice to the target scheduler.
[0082] In this step, the second microservice can send a subscription request to the target scheduler based on the received first interface address. The subscription request is used to represent the subscription information of the first microservice.
[0083] S250, in response to the subscription request, send the subscription information of the first microservice to the second microservice so that the second microservice can call the first microservice.
[0084] In this step, after receiving the subscription request, the target scheduler responds by sending the subscription information of the first microservice to the second microservice. The second microservice then subscribes to the first microservice to make calls to it.
[0085] In this embodiment of the invention, the target scheduler responds to the subscription request sent by the second microservice and sends the subscription information of the first microservice to the second microservice, enabling the second microservice to subscribe to the microservice data of the first microservice and satisfying the consistency requirement. When the first microservice is called by the second microservice, the scheduler promptly responds to the instructions sent by both the first and second microservices, ensuring that the second microservice's call request to the first microservice is responded to in a timely manner, satisfying the availability requirement. This satisfies the consistency and availability requirements of microservices during the call process, thereby improving the efficiency of microservice calls.
[0086] Optionally, the method further includes:
[0087] The system controls each scheduler in the scheduler cluster to shard the stored data and synchronize it to the preset execution machine cluster.
[0088] The scheduling machine cluster includes N scheduling machines, and the execution machine cluster includes N execution machines that correspond one-to-one with the N scheduling machines. The data shards stored in each execution machine are the same as the data shards stored in the corresponding scheduling machine, where N is a positive integer greater than 1.
[0089] In this embodiment, the registration center also includes an execution machine cluster, which includes multiple execution machines, also known as slave machines.
[0090] It should be noted that if the scheduling machine cluster includes N scheduling machines, then the execution machine cluster also includes N execution machines, and the above N execution machines correspond one-to-one with the N scheduling machines, where N is a positive integer greater than 1.
[0091] In this embodiment, each scheduler in the control scheduler cluster synchronizes the data shards it stores to the preset execution machine cluster, so that the data shards stored by each execution machine are the same as the data shards stored by the corresponding scheduler.
[0092] In this embodiment, for financial businesses involving a large amount of microservice data, an execution machine cluster can be added to synchronize microservice data from the scheduler cluster to the execution machine cluster. A master and slave combined architecture can be deployed so that microservices can be invoked through the execution machine cluster even if the scheduler cluster fails, thereby ensuring that microservices can be invoked in a timely manner.
[0093] Furthermore, by simultaneously setting up scheduler clusters and execution machine clusters, horizontal scaling can be achieved, enabling the registration of large-scale microservices to meet the needs of financial businesses with high data volumes.
[0094] Optionally, the method further includes:
[0095] Each executor in the executor cluster is controlled to write the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the executor cluster.
[0096] It should be noted that each execution machine in the execution machine cluster stores a data shard, which is used to store microservice data.
[0097] In this embodiment, the execution machine cluster is associated with data snapshot files and write-ahead log files, also known as WAL log files. Each execution machine in the cluster writes the microservice data from the stored data shards into the associated data snapshot files and write-ahead log files, thus achieving microservice data backup.
[0098] In this embodiment, the microservice data stored in the execution machine cluster is backed up to a data snapshot file and a write-ahead log file. If the execution machine cluster crashes, the microservice data can be quickly restored through the data snapshot file and the write-ahead log file, avoiding data loss and data corruption caused by the execution machine cluster crash.
[0099] Optionally, the method further includes:
[0100] If an error is detected in the subscription information of the first microservice, the subscription information of the first microservice is read from the execution machine cluster;
[0101] The subscription information of the first microservice is resent to the second microservice so that the second microservice can call the first microservice.
[0102] In this embodiment, the scheduling cluster periodically or in real time detects communication with the first microservice. If an error is detected in the subscription information of the first microservice, it indicates that the scheduling cluster has failed to send the message or the first microservice has failed. In this case, the scheduling cluster reads the subscription information of the first microservice from the execution cluster and resends the subscription information of the first microservice to the second microservice so that the second microservice can call the first microservice.
[0103] In this embodiment, if the subscription information of the called microservice is found to be incorrect, the backed-up subscription information is read from the execution machine cluster in a timely manner to avoid microservice call failure and improve the success rate of calling microservice.
[0104] Optionally, the scheduling machine cluster includes a control machine and at least one scheduling machine, and the method further includes:
[0105] Each scheduler sends a registration request to the control machine to register the interface address corresponding to each scheduler on the control machine;
[0106] The control machine synchronizes microservice data to each scheduler based on a consistency protocol.
[0107] In this embodiment, the scheduling machine cluster includes a control machine and at least one scheduling machine. As described above, the control machine can control any scheduling machine in the scheduling machine cluster.
[0108] In this embodiment, before joining the scheduling machine cluster, each scheduling machine needs to initiate a node registration process with the control machine. That is, each scheduling machine sends a registration request to the control machine to register its corresponding interface address. Furthermore, the control machine synchronizes microservice data to each scheduling machine based on a consistency protocol, achieving data consistency and ensuring that each node has the same data.
[0109] Optionally, the method further includes:
[0110] Each scheduler in the scheduler cluster is controlled to write the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the scheduler cluster.
[0111] It should be noted that each execution machine in the scheduler cluster stores data shards, which are used to store microservice data.
[0112] In this embodiment, the scheduler cluster is associated with data snapshot files and write-ahead log files, also known as WAL log files. The data snapshot files and write-ahead log files associated with the scheduler cluster are different from those associated with the execution machine cluster. Each scheduler in the scheduler cluster writes the microservice data from the stored data shards into the data snapshot files and write-ahead log files associated with the scheduler cluster, thus achieving microservice data backup.
[0113] In this embodiment, the microservice data stored in the scheduling cluster is backed up to data snapshot files and write-ahead log files. If the scheduling cluster crashes, the microservice data can be quickly recovered through the data snapshot files and write-ahead log files, avoiding data loss and data corruption caused by the scheduling cluster crash.
[0114] To facilitate understanding of the overall technical solution provided in the embodiments of the present invention, please refer to [link / reference needed]. Figure 3 ,exist Figure 3 In the illustrated application scenario, the scheduler cluster includes three master machines, one of which is a control machine, and the execution machine cluster includes three slave machines. The master machines synchronize stored data slices to the corresponding slave machines, and the scheduler cluster writes the stored microservice data to the associated data snapshot file and WAL log file. The execution machine cluster also writes the stored microservice data to the associated data snapshot file and WAL log file.
[0115] exist Figure 3In the illustrated application scenario, the second microservice sends a call request to the first microservice. The first microservice sends a control machine query command to the scheduling machine cluster to obtain the control machine's interface address, and then sends a target scheduler query command to the control machine to obtain the target scheduler's interface address. The second microservice sends a second query command to the control machine to obtain the target scheduler's interface address, and then sends a subscription request to the target scheduler to invoke the first microservice.
[0116] Further reference Figure 4 As a response to the above Figure 2 The implementation of the method shown in this application provides an embodiment of a microservice system 400, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0117] This invention provides a microservice system 400, which includes a scheduler cluster 410, a first microservice 420, and a second microservice 430.
[0118] The second microservice 430 is used to send a call request to the first microservice 410;
[0119] The first microservice 410 is used to send a first query instruction to the scheduler cluster 410 based on the call request;
[0120] The scheduling machine cluster 410 is used to send the first interface address of the target scheduling machine to the first microservice 420 when it receives the first query instruction sent by the first microservice 420; the target scheduling machine is the scheduling machine in the scheduling machine cluster 410 that stores the data shards corresponding to the first microservice 420.
[0121] Receive the second query command sent by the second microservice 430;
[0122] In response to the second query command, the first interface address is sent to the second microservice 430;
[0123] Receive the subscription request sent by the second microservice 430 to the target scheduler;
[0124] In response to the subscription request, the subscription information of the first microservice 420 is sent to the second microservice 430;
[0125] The second microservice 430 is also used to invoke the first microservice 420 based on the subscription information.
[0126] Optionally, the scheduling cluster 410 is further configured to receive a control machine query instruction sent by the first microservice 420;
[0127] In response to the controller query instruction, the second interface address of the controller in the scheduler cluster 410 is sent to the first microservice 420; the controller query instruction is generated based on the call instruction sent by the second microservice 430 to the first microservice 420.
[0128] Receive the target scheduler query instruction sent by the first microservice 420 to the control machine;
[0129] In response to the target scheduler query command, the first interface address of the target scheduler is sent to the first microservice 420.
[0130] Optionally, the scheduling machine cluster 410 is further configured to control each scheduling machine to shard the stored data and synchronize it to a preset execution machine cluster;
[0131] The scheduling machine cluster 410 includes N scheduling machines, and the execution machine cluster includes N execution machines that correspond one-to-one with the N scheduling machines. The data shards stored in each execution machine are the same as the data shards stored in the corresponding scheduling machine, where N is a positive integer greater than 1.
[0132] Optionally, the scheduler cluster 410 is further configured to control each executor in the executor cluster to write the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the executor cluster.
[0133] Optionally, the scheduler cluster 410 is further configured to read the subscription information of the first microservice 420 from the execution machine cluster when an error is detected in the subscription information of the first microservice 420;
[0134] The subscription information of the first microservice 420 is resent to the second microservice 430 so that the second microservice 430 can call the first microservice 420.
[0135] Optionally, the scheduling machine cluster 410 includes a control machine and at least one scheduling machine. The scheduling machine cluster 410 is also configured to control each scheduling machine to send a registration request to the control machine to register the interface address corresponding to each scheduling machine on the control machine.
[0136] The control machine synchronizes microservice data to each scheduler based on a consistency protocol.
[0137] Optionally, the scheduler cluster 410 is further configured to control each scheduler to write the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the scheduler cluster 410.
[0138] In this embodiment of the invention, the target scheduler responds to the subscription request sent by the second microservice and sends the subscription information of the first microservice to the second microservice, enabling the second microservice to subscribe to the microservice data of the first microservice and satisfying the consistency requirement. When the first microservice is called by the second microservice, the scheduler promptly responds to the instructions sent by both the first and second microservices, ensuring that the second microservice's call request to the first microservice is responded to in a timely manner, satisfying the availability requirement. This satisfies the consistency and availability requirements of microservices during the call process, thereby improving the efficiency of microservice calls.
[0139] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 5 , Figure 5 This is a basic structural block diagram of the computer device in this embodiment.
[0140] The computer device 5 includes a memory 51, a processor 52, and a network interface 53 that are interconnected via a system bus. It should be noted that only the computer device 5 with components 51-53 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0141] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0142] The memory 51 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 51 may be an internal storage unit of the computer device 5, such as the hard disk or memory of the computer device 5. In other embodiments, the memory 51 may also be an external storage device of the computer device 5, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 5. Of course, the memory 51 may include both the internal storage unit and its external storage device of the computer device 5. In this embodiment, the memory 51 is typically used to store the operating system and various application software installed on the computer device 5, such as the program code of the application's calling methods. In addition, the memory 51 can also be used to temporarily store various types of data that have been output or will be output.
[0143] In some embodiments, the processor 52 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. The processor 52 is typically used to control the overall operation of the computer device 5. In this embodiment, the processor 52 is used to run program code stored in the memory 51 or process data, for example, to run the program code of the microservice calling method.
[0144] The network interface 53 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 5 and other electronic devices.
[0145] This application also provides another embodiment, namely, providing a computer-readable storage medium storing the microservice calling program, which can be executed by at least one processor to cause the at least one processor to perform the steps of the microservice calling method as described above.
[0146] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware online platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0147] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0148] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. A microservice invocation method, characterized in that, include: Upon receiving the first query instruction sent by the first microservice, send the first interface address of the target scheduler in the scheduler cluster to the first microservice; The target scheduler is the scheduler in the scheduler cluster that stores the data shards corresponding to the first microservice, and the first microservice is the microservice called by the second microservice. Receive the second query command sent by the second microservice; In response to the second query command, the first interface address is sent to the second microservice; Receive the subscription request sent by the second microservice to the target scheduler; In response to the subscription request, the subscription information of the first microservice is sent to the second microservice so that the second microservice can call the first microservice; The system controls each scheduler in the scheduler cluster to synchronize its stored data shards to a preset execution machine cluster, so that the data shards stored by each execution machine in the execution machine cluster are the same as the data shards stored by the corresponding scheduler; wherein, the scheduler cluster includes N schedulers, and the execution machine cluster includes N execution machines that correspond one-to-one with the N schedulers, and the data shards stored by each execution machine are the same as the data shards stored by the corresponding scheduler, where N is a positive integer greater than 1; In the event of a failure in the scheduler cluster, the microservice invocation is carried out by the execution machine cluster.
2. The method according to claim 1, characterized in that, Before receiving the second query instruction sent by the second microservice, the method further includes: Receive the control machine query command sent by the first microservice; In response to the control machine query instruction, the second interface address of the control machine in the scheduler cluster is sent to the first microservice; the control machine query instruction is generated based on the call instruction sent by the second microservice to the first microservice. Receive the target scheduler query instruction sent by the first microservice to the control machine; In response to the target scheduler query command, the first interface address of the target scheduler is sent to the first microservice.
3. The method according to claim 1, characterized in that, The method further includes: Each executor in the executor cluster is controlled to write the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the executor cluster.
4. The method according to claim 1, characterized in that, The method further includes: If an error is detected in the subscription information of the first microservice, the subscription information of the first microservice is read from the execution machine cluster; The subscription information of the first microservice is resent to the second microservice so that the second microservice can call the first microservice.
5. The method according to claim 1, characterized in that, The scheduling machine cluster includes a control machine and at least one scheduling machine, and the method further includes: Each scheduler sends a registration request to the control machine to register the interface address corresponding to each scheduler on the control machine; The control machine synchronizes microservice data to each scheduler based on a consistency protocol.
6. The method according to claim 1, characterized in that, The method further includes: Each scheduler in the scheduler cluster is controlled to write the microservice data in the stored data shards into the data snapshot file and write-ahead log file associated with the scheduler cluster.
7. A microservice system, characterized in that, The microservice system includes a scheduler cluster, a first microservice, and a second microservice. The second microservice is used to send a call request to the first microservice; The first microservice is used to send a first query instruction to the scheduler cluster based on the call request; The scheduling cluster is used to send the first interface address of the target scheduling machine to the first microservice when it receives the first query instruction sent by the first microservice. The target scheduler is the scheduler in the scheduler cluster that stores the data shards corresponding to the first microservice; Receive the second query command sent by the second microservice; In response to the second query command, the first interface address is sent to the second microservice; Receive the subscription request sent by the second microservice to the target scheduler; In response to the subscription request, the subscription information of the first microservice is sent to the second microservice; The second microservice is also used to invoke the first microservice based on the subscription information; The scheduling machine cluster is further configured to control each scheduling machine in the cluster to synchronize its stored data shards to a preset execution machine cluster, so that the data shards stored by each execution machine in the execution machine cluster are the same as the data shards stored by the corresponding scheduling machine; wherein, the scheduling machine cluster includes N scheduling machines, and the execution machine cluster includes N execution machines that correspond one-to-one with the N scheduling machines, and the data shards stored by each execution machine are the same as the data shards stored by the corresponding scheduling machine, where N is a positive integer greater than 1; In the event of a failure in the scheduler cluster, the microservice invocation is carried out by the execution machine cluster.
8. A computer device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the microservice invocation method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the microservice invocation method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Micro-service calling method and device, computer equipment and storage medium
CN112887279A
Cluster node control method and device, equipment, storage medium and program product
CN115834668A
