A distributed microservice component system and request processing method
By using interface mapping and asynchronous processing in a distributed microservice component system, the problems of code redundancy and low efficiency in microservice architecture are solved, achieving efficient request processing and system reliability.
Patent Information
- Application Number
- CN202511285254.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-10
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-09-10
AI Technical Summary
In microservice architecture, existing technologies suffer from code redundancy and maintenance difficulties, and the system becomes less efficient when handling a large number of requests.
A distributed microservice component system is adopted, including a request allocation module, a first component, and a second component. Through interface mapping relationships and control information, request processing methods are reasonably allocated, reducing interface definition code and realizing asynchronous processing.
It improved development efficiency, reduced code redundancy, and enhanced system reliability and request processing efficiency.
Smart Images

Figure CN120780506B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software technology, and in particular to a distributed microservice component system and a request processing method. Background Technology
[0002] With the deepening of enterprise informatization, microservice architecture has become the mainstream architectural pattern for large-scale distributed systems. Currently, in distributed systems based on microservice architecture, one approach to microservice communication involves developers defining a Controller interface on the service provider side and the same Feign interface on the service consumer side, leading to code redundancy and maintenance difficulties. Furthermore, as the number of requests received by the system increases, this approach may suffer from untimely processing, resulting in reduced system request handling efficiency. Summary of the Invention
[0003] This invention provides a distributed microservice component system and a request processing method to significantly improve the development efficiency and reliability of the distributed microservice component system.
[0004] According to one aspect of the present invention, a distributed microservice component system is provided, the system comprising: a request allocation module, a first component, and a second component; the first component includes an interface address of a first microservice, control information, and an interface mapping relationship between the interface addresses of the second microservice; the control information is used to describe parameter configuration information for calling the interface of the second microservice;
[0005] The request allocation module is configured to, in response to at least one first request, determine a request processing method for each first request, and classify the first request into a second request and a third request based on the request processing method; the request processing method is used to describe the method of processing the request using the first component or the second component;
[0006] The first component is used to call the corresponding second microservice to process the data to be processed in the first microservice based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship;
[0007] The second component is used to call the fourth microservice to process the first event in the third microservice if the pending event corresponding to the third request is the first event; wherein the third microservice and the fourth microservice are different microservices.
[0008] According to another aspect of the present invention, a request processing method is provided, applied to a distributed microservice component system, the system including a request allocation module, a first component, and a second component; the first component includes an interface address of a first microservice, control information, and an interface mapping relationship between the interface addresses of the second microservice; the control information is used to describe parameter configuration information for calling the interface of the second microservice, the method comprising:
[0009] In response to at least one first request, the request allocation module determines the request processing method for each first request and divides the first request into a second request and a third request based on the request processing method; the request processing method is used to describe the way the request is processed using the first component or the second component.
[0010] Based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship, the first component calls the corresponding second microservice to process the data to be processed in the first microservice.
[0011] If the pending event corresponding to the third request of the second component is the first event, then the fourth microservice is invoked to process the first event in the third microservice; wherein the third microservice and the fourth microservice are different microservices.
[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0013] At least one processor; and
[0014] A memory communicatively connected to the at least one processor; wherein,
[0015] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the request processing method according to any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the request processing method described in any embodiment of the present invention.
[0017] The distributed microservice component system of this invention includes: a request allocation module, a first component, and a second component. The request allocation module is used to respond to at least one first request, determine the request processing method for each first request, and divide the first request into a second request and a third request based on the request processing method. The request processing method describes the method of processing the request using the first component or the second component, so that the first request can be reasonably allocated subsequently, i.e., the second request is allocated to the first component for processing, and the third request is allocated to the second component for processing, avoiding a decrease in system processing efficiency due to too many requests. Furthermore, the first component is used to call the corresponding second microservice to process the pending data in the first microservice based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship. Because the first component contains the interface address of the first microservice, control information, and the interface mapping relationship between the interface addresses of the second microservice, it reduces the need to set input parameters, output parameters, etc., in the first microservice, second microservice, and controller functions, greatly reducing the repetitive interface definition code and significantly improving development efficiency. Meanwhile, the second component is used to call the fourth microservice to process the first event in the third microservice if the pending event corresponding to the third request is the first event; wherein the third microservice and the fourth microservice are different microservices, realizing the reasonable processing of the third request in an asynchronous manner. This invention rationally allocates each request based on the request processing method, enabling requests to be processed quickly and greatly improving the reliability of the system.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the structure of a distributed microservice component system provided in an embodiment of the present invention;
[0021] Figure 2 This is a schematic diagram of the structure of another distributed microservice component system provided by an embodiment of the present invention;
[0022] Figure 3This is an architecture diagram of a distributed microservice component system applicable to embodiments of the present invention.
[0023] Figure 4 This is a flowchart of a request processing method provided according to an embodiment of the present invention;
[0024] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the request processing method of the present invention, according to an embodiment of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] Example 1
[0028] Figure 1 This is a schematic diagram of a distributed microservice component system provided in an embodiment of the present invention. This embodiment can be applied to improve the distributed microservice component system to make requests more reasonable. The distributed microservice component system can be implemented in hardware and / or software and can be configured in any electronic device with network communication function.
[0029] like Figure 1As shown, the distributed microservice component system of the present invention includes: a request allocation module 110, a first component 120, and a second component 130; the first component contains the interface address of the first microservice, control information, and the interface mapping relationship between the interface address of the second microservice; the control information is used to describe the parameter configuration information for calling the interface of the second microservice; the second microservice is a microservice called by the first microservice and is used to process the request corresponding to the second microservice, and the data to be processed for the request corresponding to the second microservice is stored in the first microservice.
[0030] The request allocation module 110 is used to respond to at least one first request, determine the request processing method for each first request, and divide the first request into a second request and a third request based on the request processing method; the request processing method is used to describe the way the request is processed by the first component or the second component; the second request is the first request corresponding to the first request processed by the first component; the third request is the first request corresponding to the first request processed by the second component.
[0031] The first component 120 is used to call the corresponding second microservice to process the data to be processed in the first microservice based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship.
[0032] Specifically, in response to the second request, the first interface address of the first microservice corresponding to the second request is determined, the second microservice corresponding to the second request is determined based on the first interface address and the interface mapping relationship, and the second microservice corresponding to the second request is controlled to process the second request.
[0033] The second component 130 is used to call the fourth microservice to process the first event in the third microservice if the pending event corresponding to the third request is the first event; wherein the third microservice and the fourth microservice are different microservices.
[0034] Specifically, when the pending event corresponding to the third request is the first event, the first event stored in the third microservice is sent to the preset message queue, and the fourth microservice is controlled to call the first event from the preset message queue and process the first event; the third microservice and the fourth microservice are different microservices.
[0035] In this invention, a request can be a client-initiated request to process data to be processed. This data is stored in a microservice. Therefore, after responding to a request, the system categorizes the requests and, for different requests, uses a first component or a second component to control the microservice to process them appropriately. The pending event can include the data to be processed corresponding to the request, so that the server can subsequently process the data by invoking the pending event. The first event can be understood as a pending event that is stored in a microservice that is not the same microservice that processes it; that is, the first event is an asynchronous processing event.
[0036] The present invention, based on a first interface address and an interface mapping relationship, determines the second microservice corresponding to a second request. This can include: querying the control information associated with the second request from the interface mapping relationship based on the first interface address; querying the second interface address from the interface mapping relationship based on the control information associated with the second request; and determining that the second interface address corresponds to a second microservice, thus accurately obtaining the second microservice corresponding to the second request. Further, the first interface address is associated with the first microservice of the second request, i.e., the microservice storing the data to be processed in the second request. The second microservice corresponding to the second request defines its interface based on the control information associated with the second request, thereby enabling communication between the second microservice and the first microservice. This allows the second microservice to call the data to be processed from the first microservice, process the data to obtain a processing result, and then feed the processing result back to the client.
[0037] In this embodiment, optionally, in response to at least one first request, determining the request processing method for each first request may include: if the first request meets a preset condition, then the request processing method for the first request is determined to be a first processing method; the first processing method is processing the request using a first component; if the first request does not meet the preset condition, then the request processing method for the first request is determined to be a second processing method; the second processing method is processing the request using a second component. The preset condition is at least one of a first preset condition, a second preset condition, and a third preset condition; the first preset condition is that the processing time of the request is less than a first preset time; the second preset condition is that the processing result of the request needs to be returned within a second preset time; the third preset condition is that no external tools of the distributed microservice component system need to be called during the request processing. This embodiment proposes determining whether a first request meets preset conditions, thereby accurately classifying the request processing method for each first request, thus rationally allocating resources for processing each first request, and greatly improving the efficiency of the system in processing requests.
[0038] In this embodiment, optionally, the process of determining the interface mapping relationship may include steps A1-A6:
[0039] Step A1: Obtain the first interface information and the corresponding control function of each microservice in the distributed microservice component system.
[0040] The first interface information can be understood as the interface information associated with the microservice's interface, which at least includes the interface's address information.
[0041] Control functions describe the processing logic of the interface. This processing logic defines what types of data the microservice's interface can process. For example, for image data processing, control functions describe the interface's logic for handling image data.
[0042] Step A2: Determine the first interface information containing the preset annotation information as the second interface information, and the interface corresponding to the second interface information is the first interface.
[0043] The preset annotation information can be understood as identification information that enables the decomposition of the first interface information. For example, the preset annotation information could be the @FeignClient annotation.
[0044] Step A3: Parse the second interface information to determine the interface address of the first interface; the microservice corresponding to the first interface is the second microservice.
[0045] Step A4: Parse the control function corresponding to the second interface information to determine the control information corresponding to the second interface information.
[0046] The control information may include the configuration parameters of the interface corresponding to the control information. The configuration parameters may be parameters that define the interface code, including at least the interface input parameters and the interface output parameters.
[0047] Step A5: Determine the first microservice that calls the second microservice, and the interface address of the second interface of the first microservice.
[0048] Step A6: Based on the interface address of the second interface, the interface address of the first interface, and the control information corresponding to the second interface information, establish an interface mapping relationship between the interface address of the first microservice, the control information, and the interface address of the second microservice.
[0049] This invention, through parsing the interface information and control functions of each microservice, accurately determines the control information that can be defined once in the second microservice. This establishes an interface mapping relationship between the interface address of the first microservice, the control information, and the interface address of the second microservice—a bidirectional interface mapping. This allows for the retrieval of control information and the interface address of the second microservice based on the interface mapping relationship during practical applications, avoiding multiple interface definitions required to establish communication between the first and second microservices. This reduces interface definition code by more than 50%, significantly avoids code redundancy, greatly improves development efficiency, and reduces the difficulty of system maintenance.
[0050] Optionally, in this embodiment of the invention, the control information further includes standard information, which may be standard logic information defining the interface of the microservice; the data to be processed for the request corresponding to the second microservice is stored in the first microservice; correspondingly, based on the first interface address and interface mapping relationship of the first microservice corresponding to the second request, the corresponding second microservice is invoked to process the data to be processed in the first microservice, including: obtaining the first control information corresponding to the second microservice from the interface mapping relationship; defining the interface of the second microservice corresponding to the second request based on the standard information and parameter configuration information in the first control information, so as to establish a connection between the second microservice corresponding to the second request and the first microservice. After the connection is established between the second microservice corresponding to the second request and the first service, the second microservice corresponding to the second request is controlled to invoke the data to be processed associated with the second request from the first microservice, and process the data to obtain the data processing result. In this embodiment of the invention, the first control information is accurately obtained through the interface mapping relationship of the first component, thereby ensuring that the second microservice can complete the interface definition once based on the first control information. This eliminates the need to define interfaces in both the first and second microservices, greatly avoiding the duplication of interface definition code, significantly improving development efficiency, and also improving the communication efficiency between the second and first microservices.
[0051] Optionally, in this embodiment of the invention, the second component is further configured to, when the pending event corresponding to the third request is the second event, control the fifth microservice storing the second event to process the second event; the second event is an event that the microservice storing the pending event can directly process. Specifically, if the pending event can be processed directly in the microservice storing the pending event, then the pending event is determined as the second event, and the microservice storing the second event is designated as the fifth microservice, then the fifth microservice is directly controlled to process the second event. The second component of this invention can be understood as an event-driven model that combines the processing functions of the first and second events, simplifying the event-driven architecture, reducing direct dependencies between services, improving system scalability, and simultaneously enabling reasonable processing of the pending event corresponding to the third request, synchronous and asynchronous event processing, and reasonable resource allocation.
[0052] In an embodiment of the present invention, optionally, the fourth microservice includes at least one consumer group, and controlling the fourth microservice to invoke a first event from a preset message queue and process the first event may include steps B1-B2:
[0053] Step B1: If the first event is a consumer group event, then control one of the consumer groups in the fourth microservice to call the consumer group event from the preset message queue and process the consumer group event.
[0054] Step B2: If the first event is a broadcast event, then control all consumer groups in the fourth microservice to call the broadcast event from the preset message queue and process the broadcast event.
[0055] Consumer group events can be understood as events that require processing by a specific consumer group. If multiple consumer groups process them simultaneously, it will lead to resource waste and data redundancy. Broadcast events, on the other hand, require all consumer groups to be aware of the message. Therefore, all consumer groups in the microservice need to process broadcast events to avoid affecting other branch tasks due to inadequate notification.
[0056] In this embodiment of the invention, the processing of the first event is further divided into consumer group events and broadcast events to ensure that the consumer group in the fourth microservice can process the first event reasonably and avoid data redundancy or inaccurate message transmission.
[0057] In this embodiment of the invention, optionally, such as Figure 2As shown, the distributed microservice component system also includes a third component 140; the third component is used to connect the client and the microservice for communication based on a preset communication method; the preset communication method is a communication method in which the microservice continuously sends data to the client after the client and the microservice have connected once. The third component is connected to both the microservice and the second component for communication between the microservice and the second component.
[0058] The microservices include, but are not limited to, the first microservice, second microservice, third microservice, and fourth microservice of this invention. For example, ... Figure 2 As shown, the third component is connected to the third microservice, the fourth microservice, and the second component to enable communication between the third microservice, the fourth microservice, and the second component, as well as communication between the third microservice and the fourth microservice and the client through the third component; the third component is also connected to the first microservice and the second microservice to enable communication between the first microservice and the second microservice and the client through the third component.
[0059] The default communication method can be Server-Sent Events (SSE) technology. Specifically, the third component of this invention is used to connect the client and the microservice based on SSE technology. By employing lightweight SSE for real-time communication, it can support large-scale concurrent connections. Simultaneously, a heartbeat detection mechanism can automatically send heartbeat messages to maintain the stability of the long-term connection between the client and the microservice. Using SSE technology also ensures automatic reconnection after a client disconnects, improving connection reliability. This invention integrates the third and second components, supporting communication of information from the second component, thereby improving system stability and reliability.
[0060] In an optional embodiment of this invention, the distributed microservice component system further includes a fourth component. This fourth component adds preset tagging information to the request header of the first request and records preset parameter information of the first request in real time based on the preset tagging information. The preset parameter information includes at least one of the following: the number of responses, the number of reads, the request input parameters, the request output parameters, and the request duration. The preset tagging information can be understood as identification information used for link tracing. When a request is marked with preset tagging information, all call chains of the request can be viewed in the link tracing platform. The addition of this fourth component reduces problem localization time by more than 80% through full-link log tracing.
[0061] like Figure 3As shown, the distributed microservice component system of the present invention is illustrated by an example. The first component in the distributed microservice component system of the present invention can be a service communication layer, the second component is an event processing layer, the third component is an event communication layer, and the fourth component is an observability layer. These components work together to provide core functions such as service communication, event-driven, real-time push and full-link log tracing for microservice applications, which greatly improves the development efficiency and system reliability of microservice architecture.
[0062] The distributed microservice component system of this invention includes: a request allocation module, a first component, and a second component. The request allocation module is used to respond to at least one first request, determine the request processing method for each first request, and divide the first request into a second request and a third request based on the request processing method. The request processing method describes the method of processing the request using the first component or the second component, so that the first request can be reasonably allocated subsequently, i.e., the second request is allocated to the first component for processing, and the third request is allocated to the second component for processing, avoiding a decrease in system processing efficiency due to too many requests. Furthermore, the first component is used to call the corresponding second microservice to process the pending data in the first microservice based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship. Because the first component contains the interface address of the first microservice, control information, and the interface mapping relationship between the interface addresses of the second microservice, it reduces the need to set input parameters, output parameters, etc., in the first microservice, second microservice, and controller functions, greatly reducing the repetitive interface definition code and significantly improving development efficiency. Meanwhile, the second component is used to call the fourth microservice to process the first event in the third microservice if the pending event corresponding to the third request is the first event; wherein the third microservice and the fourth microservice are different microservices, realizing the reasonable processing of the third request in an asynchronous manner. This invention rationally allocates each request based on the request processing method, enabling requests to be processed quickly and greatly improving the reliability of the system.
[0063] Example 2
[0064] Figure 4This is a flowchart illustrating a request processing method provided in an embodiment of the present invention. This embodiment is applicable to improving a distributed microservice component system to handle requests appropriately using the distributed microservice component system. The method can be executed by the distributed microservice component system, which can be implemented in hardware and / or software and can be configured in any electronic device with network communication capabilities. The distributed microservice component system includes a request allocation module, a first component, and a second component. The first component contains the interface address of a first microservice, control information, and an interface mapping relationship between the interface addresses of the second microservice and the first microservice. The control information describes the parameter configuration information for calling the interface of the second microservice. The second microservice is the microservice called by the first microservice and is used to process requests corresponding to the second microservice. The data to be processed for the requests corresponding to the second microservice is stored in the first microservice. Figure 4 As shown, the request processing method includes:
[0065] S210. In response to at least one first request, the request allocation module determines the request processing method for each first request and divides the first request into a second request and a third request based on the request processing method; the request processing method is used to describe the way the request is processed by the first component or the second component.
[0066] The second request is the first request that uses the first component to process the request in the first request; the third request is the first request that uses the second component to process the request in the first request.
[0067] S220. Based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship, the first component calls the corresponding second microservice to process the data to be processed in the first microservice.
[0068] S230. If the pending event corresponding to the third request of the second component is the first event, then the fourth microservice is called to process the first event in the third microservice; wherein the third microservice and the fourth microservice are different microservices.
[0069] Specifically, when the pending event corresponding to the third request is the first event, the first event stored in the third microservice is sent to a preset message queue, and the fourth microservice is controlled to call the first event from the preset message queue and process the first event; the third microservice and the fourth microservice are different microservices.
[0070] Based on the above embodiments, optionally, the process of determining the interface mapping relationship includes:
[0071] Obtain the first interface information of each microservice in the distributed microservice component system and the control function corresponding to the first interface information; the control function is used to describe the processing logic of the interface;
[0072] The first interface information containing preset annotation information is determined as the second interface information, and the interface corresponding to the second interface information is the first interface.
[0073] The second interface information is parsed to determine the interface address of the first interface; the microservice corresponding to the first interface is the second microservice.
[0074] The control function corresponding to the second interface information is parsed to determine the control information corresponding to the second interface information; the control information includes the configuration parameters of the interface corresponding to the control information.
[0075] Determine the first microservice that calls the second microservice, and the interface address of the second interface of the first microservice;
[0076] Based on the interface address of the second interface, the interface address of the first interface, and the control information corresponding to the second interface information, an interface mapping relationship is established between the interface address of the first microservice, the control information, and the interface address of the second microservice.
[0077] Based on the above embodiments, optionally, the control information further includes standard information, which is standard logic information defining the interface of the microservice; the data to be processed for the request corresponding to the second microservice is stored in the first microservice;
[0078] Accordingly, based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship, the corresponding second microservice is invoked to process the data to be processed in the first microservice, including:
[0079] Obtain the first control information corresponding to the second microservice from the interface mapping relationship, and define the interface of the second microservice corresponding to the second request based on the standard information and parameter configuration information in the first control information, so that the second microservice corresponding to the second request and the first microservice can complete the connection.
[0080] After the connection is established between the second microservice corresponding to the second request and the first microservice, the second microservice corresponding to the second request is controlled to call the pending data associated with the second request from the first microservice, and process the pending data to obtain the data processing result.
[0081] Based on the above embodiments, optionally, in response to at least one first request, determining the request processing method for each first request includes:
[0082] If the first request meets the preset conditions, then the request processing method of the first request is determined to be the first processing method; the first processing method is the method of processing the request using the first component; the preset conditions are at least one of the first preset conditions, the second preset conditions, and the third preset conditions; the first preset condition is that the processing time of the request is less than the first preset time; the second preset condition is that the processing result of the request needs to be returned within the second preset time; the third preset condition is that no external tools of the distributed microservice component system need to be called during the processing of the request.
[0083] If the first request does not meet the preset conditions, then the request processing method of the first request is determined to be the second processing method; the second processing method is the method of processing the request using the second component.
[0084] Based on the above embodiments, optionally, when the pending event corresponding to the third request is the second event, the second component controls the fifth microservice that stores the second event to process the second event; the second event is an event that the microservice that stores the pending event can directly process.
[0085] Based on the above embodiments, optionally, the fourth microservice includes at least one consumer group, which controls the fourth microservice to invoke the first event from a preset message queue and process the first event, including:
[0086] If the first event is a consumer group event, then control one of the consumer groups in the fourth microservice to call the consumer group event from the preset message queue and process the consumer group event;
[0087] If the first event is a broadcast event, then all consumer groups in the fourth microservice are controlled to call the broadcast event from the preset message queue and process the broadcast event.
[0088] Based on the above embodiments, optionally, the distributed microservice component system further includes a third component; the third component connects the client and the microservice based on a preset communication method; the preset communication method is a communication method in which the microservice continuously sends data to the client after the client and the microservice have connected once.
[0089] Based on the above embodiments, optionally, the third component is connected to both the microservice and the second component for communication between the microservice and the second component.
[0090] Based on the above embodiments, optionally, the distributed microservice component system further includes a fourth component; the fourth component adds preset tag information to the request header of the first request, and records the preset parameter information of the first request in real time according to the preset tag information; the preset parameter information includes at least one of the following: the number of responses, the number of reads, the request input parameters, the request output parameters, and the request time.
[0091] The request processing method provided in this embodiment of the invention can be applied to the distributed microservice component system provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0092] Example 3
[0093] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0094] Figure 5 A schematic diagram of an electronic device that can be used to implement the request processing method of embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0095] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0096] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0097] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as request processing methods.
[0098] In some embodiments, the request processing method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the request processing method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the request processing method by any other suitable means (e.g., by means of firmware).
[0099] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0100] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0101] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0102] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0103] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0104] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0105] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0106] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A distributed microservice component system, characterized in that, The system includes: a request allocation module, a first component, and a second component; the first component contains the interface address of a first microservice, control information, and the interface mapping relationship between the interface addresses of the second microservice; the control information is used to describe the parameter configuration information for calling the interface of the second microservice; The request allocation module is configured to, in response to at least one first request, determine a request processing method for each first request, and classify the first request into a second request and a third request based on the request processing method; the request processing method is used to describe the method of processing the request using the first component or the second component; The first component is used to call the corresponding second microservice to process the data to be processed in the first microservice based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship; The second component is used to invoke the fourth microservice to process the first event in the third microservice if the pending event corresponding to the third request is the first event; wherein the third microservice and the fourth microservice are different microservices. The process of determining the interface mapping relationship includes: Obtain the first interface information of each microservice in the distributed microservice component system and the control function corresponding to the first interface information; the control function is used to describe the processing logic of the interface; The first interface information containing preset annotation information is determined as the second interface information, and the interface corresponding to the second interface information is the first interface. The second interface information is parsed to determine the interface address of the first interface; the microservice corresponding to the first interface is the second microservice. The control function corresponding to the second interface information is parsed to determine the control information corresponding to the second interface information; the control information includes the configuration parameters of the interface corresponding to the control information. Determine the first microservice that calls the second microservice, and the interface address of the second interface of the first microservice; Based on the interface address of the second interface, the interface address of the first interface, and the control information corresponding to the second interface information, an interface mapping relationship is established between the interface address of the first microservice, the control information, and the interface address of the second microservice.
2. The system according to claim 1, characterized in that, The control information also includes standard information, which is information about the standard logic defining the interface of the microservice; the data to be processed for the request corresponding to the second microservice is stored in the first microservice; Accordingly, based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship, the corresponding second microservice is invoked to process the data to be processed in the first microservice, including: Obtain the first control information corresponding to the second microservice from the interface mapping relationship, and define the interface of the second microservice corresponding to the second request based on the standard information and parameter configuration information in the first control information, so that the second microservice corresponding to the second request and the first microservice can complete the connection. After the connection is established between the second microservice corresponding to the second request and the first microservice, the second microservice corresponding to the second request is controlled to call the pending data associated with the second request from the first microservice, and process the pending data to obtain the data processing result.
3. The system according to claim 1, characterized in that, In response to at least one first request, determine how to handle each first request, including: If the first request meets the preset conditions, then the request processing method of the first request is determined to be the first processing method; the first processing method is the method of processing the request using the first component; the preset conditions are at least one of the first preset conditions, the second preset conditions, and the third preset conditions; the first preset condition is that the processing time of the request is less than the first preset time; the second preset condition is that the processing result of the request needs to be returned within the second preset time; the third preset condition is that no external tools of the distributed microservice component system need to be called during the processing of the request. If the first request does not meet the preset conditions, then the request processing method of the first request is determined to be the second processing method; the second processing method is the method of processing the request using the second component.
4. The system according to claim 1, characterized in that, The second component is further configured to control the fifth microservice storing the second event to process the second event when the pending event corresponding to the third request is the second event; The second event is an event that the microservice storing the event to be processed can directly process.
5. The system according to claim 1, characterized in that, The fourth microservice includes at least one consumer group, which controls the fourth microservice to invoke the first event from a preset message queue and process the first event, including: If the first event is a consumer group event, then control one of the consumer groups in the fourth microservice to call the consumer group event from the preset message queue and process the consumer group event; If the first event is a broadcast event, then all consumer groups in the fourth microservice are controlled to call the broadcast event from the preset message queue and process the broadcast event.
6. The system according to claim 1, characterized in that, The distributed microservice component system also includes a third component; the third component is used to connect the client and the microservice based on a preset communication method; the preset communication method is to continuously maintain the communication method of the microservice sending data to the client after the client and the microservice have connected once.
7. The system according to claim 6, characterized in that, The third component is connected to both the microservice and the second component, and is used for communication between the microservice and the second component.
8. The system according to claim 1, characterized in that, The distributed microservice component system further includes a fourth component; the fourth component is used to add preset tag information to the request header of the first request, and record the preset parameter information of the first request in real time according to the preset tag information. The preset parameter information includes at least one of the following: the number of responses to the first request, the number of reads, the request input parameters, the request output parameters, and the request time.
9. A request processing method, characterized in that, Applied to the distributed microservice component system according to any one of claims 1-8, the system includes a request allocation module, a first component, and a second component; the first component includes the interface address of the first microservice, control information, and the interface mapping relationship between the interface addresses of the second microservice. The control information is used to describe the parameter configuration information for calling the interface of the second microservice, and the method includes: In response to at least one first request, the request allocation module determines the request processing method for each first request and divides the first request into a second request and a third request based on the request processing method; the request processing method is used to describe the way the request is processed using the first component or the second component. Based on the first interface address of the first microservice corresponding to the second request and the interface mapping relationship, the first component calls the corresponding second microservice to process the data to be processed in the first microservice. If the pending event corresponding to the third request is the first event, the second component calls the fourth microservice to process the first event in the third microservice; wherein the third microservice and the fourth microservice are different microservices. The process of determining the interface mapping relationship includes: Obtain the first interface information of each microservice in the distributed microservice component system and the control function corresponding to the first interface information; the control function is used to describe the processing logic of the interface; The first interface information containing preset annotation information is determined as the second interface information, and the interface corresponding to the second interface information is the first interface. The second interface information is parsed to determine the interface address of the first interface; the microservice corresponding to the first interface is the second microservice. The control function corresponding to the second interface information is parsed to determine the control information corresponding to the second interface information; the control information includes the configuration parameters of the interface corresponding to the control information. Determine the first microservice that calls the second microservice, and the interface address of the second interface of the first microservice; Based on the interface address of the second interface, the interface address of the first interface, and the control information corresponding to the second interface information, an interface mapping relationship is established between the interface address of the first microservice, the control information, and the interface address of the second microservice.
Citation Information
Patent Citations
Network traffic collection and analysis system based on micro-service components
CN106487594A
Micro-service architecture system and access method thereof
CN108270818A
Micro-service processing method and device, storage medium and electronic equipment
CN120196384A
Enhanced self-assembling and self-configuring microservices
US20210037114A1