Service request processing method and device

By introducing microservice gateways and designated service middleware into the microservice architecture, the service requests are processed using pre-configured service configuration information, the problems of request complexity and management difficulty in the microservice architecture are solved, and the system is efficient , flexible and secure service request processing.

CN119420794AActive Publication Date: 2025-02-11BEIJING PACTERA JINXIN TECH LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411499088.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-02-11
Estimated Expiration
2044-10-25

AI Technical Summary

Technical Problem

In the microservice architecture, when the client directly interacts with the service node, it will face the problems of increasing request complexity, complex cross-domain request processing, complex authentication, and difficult to refactor.

Method used

By introducing a microservice gateway as a unified entry point, using specified service middleware and filters, service requests are processed based on the service configuration information pre-configured in the database, realizing intelligent routing, load balancing, dynamic current limiting or fuse filtering.

Benefits of technology

It improves the scalability, flexibility and security of the system, reduces the coupling degree of the system, makes the management and maintenance of service clusters more efficient, and ensures the accurate and effective processing of service requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420794A_ABST
    Figure CN119420794A_ABST
Patent Text Reader

Abstract

The invention provides a service request processing method and device, applied to a microservice gateway, and the method comprises the steps: obtaining service configuration information associated with a service cluster from a database; in response to a received service request sent by the client, calculating the service request according to the service configuration information by adopting specified service middleware in the micro-service gateway to obtain a calculation result; and according to the calculation result, processing the service request by adopting a filter in the micro-service gateway indicated by at least one processing node in the request processing link, thereby avoiding the problem that the service configuration information is not persistent, improving the expandability, flexibility and security of the system, reducing the coupling degree of the system, and improving the user experience. And the management and maintenance of the service cluster are more efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of Internet technology, and in particular to a service request processing method and device. Background Art

[0002] With the widespread application of microservice architecture, the number of service nodes in distributed systems built based on microservice architecture has increased and they are deployed independently. Clients directly interacting with service nodes will face problems such as increased request complexity, complex cross-domain request processing, complex authentication, and difficulty in reconstruction. By introducing a microservice gateway as a unified entry point to process service requests, the interaction between clients and service nodes can be simplified, and the security, reliability, and maintainability of the system can be improved. Therefore, it is very important to use a microservice gateway to process service requests. Summary of the invention

[0003] The present disclosure provides a service request processing method and device to solve one of the technical problems in the related art at least to a certain extent. The technical solution of the present disclosure is as follows:

[0004] According to a first aspect of an embodiment of the present disclosure, a service request processing method is provided, comprising: obtaining service configuration information associated with a service cluster from a database; in response to receiving a service request sent by a client, using a specified service middleware in the microservice gateway to calculate the service request according to the service configuration information to obtain a calculation result; based on the calculation result, using a filter in the microservice gateway indicated by at least one processing node in a request processing link to process the service request.

[0005] According to a second aspect of an embodiment of the present disclosure, a service request processing device is provided, including: an acquisition module, used to acquire service configuration information associated with a service cluster from a database; a calculation module, used to respond to receiving a service request sent by a client, use a specified service middleware in the microservice gateway, and calculate the service request according to the service configuration information to obtain a calculation result; a processing module, used to process the service request according to the calculation result, using a filter in the microservice gateway indicated by at least one processing node in a request processing link.

[0006] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the service request processing method as described in the embodiment of the first aspect of the present disclosure.

[0007] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the service request processing method as described in the embodiment of the first aspect of the present disclosure.

[0008] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including: a computer program, which, when executed by a processor, implements the service request processing method as described in the embodiment of the first aspect of the present disclosure.

[0009] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0010] In the present technical scheme, by pre-configuring the service configuration information associated with the service cluster in the database, the microservice gateway dynamically obtains the service configuration information associated with the service cluster from the database, thereby avoiding the problem of non-persistence of the service configuration information. When receiving the service request from the client, the microservice gateway uses the specified service middleware to calculate the service request according to the service configuration information, obtains the calculation result, and processes the service request through the filter in the request processing link according to the calculation result, thereby realizing intelligent routing, load balancing, dynamic current limiting or fuse filtering of service requests, improving the scalability, flexibility and security of the system, while reducing the coupling degree of the system, making the management and maintenance of the service cluster more efficient; wherein, when the microservice gateway uses the specified service middleware to calculate the request according to the service configuration information, by traversing the configuration sub-information associated with multiple processing nodes in turn, it realizes the dynamic adjustment of the processing logic according to actual needs, and when the filter switch state indicated by the currently traversed processing node is the processing node that is turned on, the processing is performed. In one step, the parameter conditions of the configuration parameters of the node are obtained, and the service request is parsed to verify whether the actual value of the configuration parameter meets the corresponding parameter condition. When all relevant parameters meet the conditions, the filter indicated by the current processing node is selected to process the service request. This not only improves the flexibility and scalability of the system, but also ensures that the service request can be accurately and effectively processed according to predetermined rules and conditions, thereby improving the user experience. In addition, when the service request is processed through the filter in the request processing link according to the calculation result, at least one processing parameter corresponding to the indicated filter is obtained from the service configuration information according to the filter indicated by the calculation result; the service request is parsed using the indicated filter to obtain the parameter value of at least one processing parameter; the service request is processed using the indicated filter according to the parameter value of at least one processing parameter, thereby realizing the processing of the corresponding processing parameters according to the processing logic corresponding to the filter, thereby improving the flexibility and accuracy of service request processing.

[0011] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0013] Figure 1 is a flowchart of a service request processing method shown in the first embodiment of the present disclosure;

[0014] Figure 2 is a flowchart of a service request processing method shown in the second embodiment of the present disclosure;

[0015] Figure 3 is a flowchart of a service request processing method shown in the third embodiment of the present disclosure;

[0016] Figure 4 It is a schematic diagram of the principle of the request processing link shown in the embodiment of the present disclosure;

[0017] Figure 5 is a flowchart of a service request processing method shown in the fourth embodiment of the present disclosure;

[0018] FIG6(A) is a schematic diagram of a portion of multiple service configuration tables shown in an embodiment of the present disclosure;

[0019] FIG6(B) is another partial schematic diagram of a plurality of service configuration tables shown in an embodiment of the present disclosure;

[0020] Figure 7 is a flowchart of a service request processing method shown in the fifth embodiment of the present disclosure;

[0021] Figure 8 It is a topological diagram of a network system where a microservice gateway is located as shown in an embodiment of the present disclosure;

[0022] Fig. 9 is a structural diagram of a service request processing device shown in the sixth embodiment of the present disclosure;

[0023] Fig.10 It is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0024] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0026] It should be noted that in the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are all carried out with the user's consent, and are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0027] In microservice development, gateways are often needed to load, limit, and fuse backend application services. For example, the default gateway provided by SpringCoud (a microservice architecture) implements current limiting through a built-in current limiting filter (RequestRateLimiter), uses a token bucket algorithm, and uses a Redis server to save intermediate data. For fuses, it can be implemented by default using Hystrix (an open source fault-tolerant framework). However, the default functions provided by SpringCoud are relatively simple and leaky. To meet the needs of different scenarios of the project, developers need to customize gateway filters.

[0028] For the flow control and circuit breaking of service requests, for example, the open source framework sentinel (an open source service middleware) is used to implement the flow control and circuit breaking of service requests. However, the open source sentinel does not provide configuration storage, and the default gateway provided by SpringCoud does not provide components integrated with sentinel. Relevant developers are required to complete the integration according to the relevant technical documents of sentinel, which increases the learning cost and implementation cost.

[0029] Therefore, in order to solve the above problems, the present disclosure proposes a service request processing method and device.

[0030] The following describes the service request processing method and device according to the embodiments of the present disclosure with reference to the accompanying drawings.

[0031] Figure 1 It is a flow chart of the service request processing method shown in the first embodiment of the present disclosure. It should be noted that the embodiment of the present disclosure is applied to a microservice gateway.

[0032] like Figure 1 As shown, the service request processing method includes the following steps:

[0033] Step 101: Obtain service configuration information associated with the service cluster from a database.

[0034] In order to avoid the problem of non-persistence of service configuration information, as an example, the service configuration information associated with the service cluster is pre-configured in the database, the microservice gateway obtains the service configuration information from the database, and stores the service configuration information in the memory of the microservice gateway.

[0035] Step 102, in response to receiving a service request sent by the client, using the specified service middleware in the microservice gateway, calculates the service request according to the service configuration information to obtain a calculation result.

[0036] In order to reduce development costs, in the embodiments of the present disclosure, the service middleware is designated as open source service middleware, for example, the service middleware is designated as sentinel.

[0037] It should be understood that the microservice gateway includes multiple types of filters, such as authentication filters, current limiting filters, fuse filters, and log filters, etc., wherein each filter corresponds to a processing node in the request processing link. Before the filter indicated by the processing node in the request processing link is used to process the service request, the specified middleware needs to be used to calculate according to the service configuration information to determine whether to use the filter indicated by the corresponding processing node to process the service request. Therefore, when the microservice gateway receives a service request sent by the client, the service request is calculated according to the service configuration information, and the calculation result of using the filter indicated by the corresponding processing node to process the service request is obtained.

[0038] Step 103: Based on the calculation result, the service request is processed using a filter in the microservice gateway indicated by at least one processing node in the request processing link.

[0039] In order to realize intelligent routing, load balancing, dynamic current limiting or fusing of service requests, as an example, based on the filter indicated by the calculation result and according to the processing parameters corresponding to the filter, the service request is processed. It should be noted that different filters have different corresponding processing parameters.

[0040] In summary, by pre-configuring the service configuration information associated with the service cluster in the database, the microservice gateway dynamically obtains the service configuration information associated with the service cluster from the database, avoiding the problem of non-persistence of the service configuration information. When receiving a service request from the client, the microservice gateway uses the specified service middleware to calculate the service request according to the service configuration information, obtains the calculation result, and processes the service request through the filter in the request processing link according to the calculation result, realizing intelligent routing, load balancing, dynamic current limiting or fuse filtering of service requests, improving the scalability, flexibility and security of the system, while reducing the coupling degree of the system, making the management and maintenance of the service cluster more efficient.

[0041] In order to clearly illustrate how the above embodiment uses the specified service middleware in the microservice gateway to calculate the service request according to the service configuration information to obtain the calculation result, the present disclosure proposes another service request processing method.

[0042] Figure 2 It is a flow chart of a service request processing method shown in the second embodiment of the present disclosure. It should be noted that the embodiment of the present disclosure is applied to a microservice gateway.

[0043] like Figure 2 As shown, the service request processing method includes the following steps:

[0044] Step 201: Obtain service configuration information associated with the service cluster from a database.

[0045] Step 202: in response to receiving a service request sent by a client, sequentially traverse configuration sub-information associated with a plurality of processing nodes.

[0046] It should be noted that the service configuration information includes: configuration sub-information associated with multiple processing nodes in the request processing link, and the multiple processing nodes include: authentication processing node, current limiting processing node, fuse processing node and log processing node.

[0047] In order to achieve decoupling between service requests and processing nodes and improve system flexibility, as an example, configuration sub-information associated with multiple processing nodes is traversed in sequence to determine whether to use the filter indicated by the corresponding processing node to process the service request.

[0048] Step 203: Obtain the switch status of the filter indicated by the currently traversed processing node.

[0049] In order to avoid unnecessary processing operations and improve processing efficiency, as an example, the switch state of the filter indicated by the currently traversed processing node is determined according to the configuration sub-information of the currently traversed processing node. For example, if the currently traversed processing node is an authentication processing node, the switch state of the authentication processing node is determined according to whether the value of the configuration parameter filterAuthorizeName corresponding to the authentication processing node obtained from the service configuration information is empty.

[0050] Step 204 , in response to the switch state of the filter indicated by the currently traversed processing node being on, obtaining a parameter condition of at least one configuration parameter configured by the currently traversed processing node from the configuration sub-information associated with the currently traversed processing node.

[0051] In order to accurately determine whether to use the filter indicated by the corresponding processing node to process the service request, as a possible implementation method, when the switch state of the filter indicated by the currently traversed processing node is on, based on the parameter condition of at least one configuration parameter configured by the currently traversed processing node, it is determined whether the actual parameter value of the at least one configuration parameter in the service request meets the corresponding parameter condition.

[0052] As an example, the rules or thresholds (i.e., parameter conditions) of one or more configuration parameters configured by the processing node currently being traversed are retrieved and obtained from the configuration sub-information associated with the node, so as to understand the rules or standards that the processing node should follow when processing requests.

[0053] For example, taking the currently traversed processing node as a current limiting processing node, the configuration parameter corresponding to the current limiting processing node may be: replenishRate of the flow per second, and the parameter condition corresponding to the flow per second is that the upper limit of the flow per second is 1000.

[0054] Step 205: parse the service request to obtain an actual parameter value of at least one service parameter.

[0055] Continuing to take the current processing node as the flow-limiting processing node and the configuration parameter corresponding to the flow-limiting processing node as the flow per second as an example, the actual value of the flow per second is determined by parsing the service request.

[0056] Step 206: When the actual parameter values ​​of the service parameters satisfy the corresponding parameter conditions, a calculation result is generated for indicating that the filter indicated by the currently traversed processing node is used to process the service request.

[0057] For example, taking the currently traversed processing node as a current limiting processing node, when the actual value of the flow per second reaches the upper limit of the flow per second, a calculation result of processing the service request using the current limiting filter indicated by the current limiting processing node is generated.

[0058] In addition, it should be noted that if there is a target parameter in at least one configuration parameter that does not meet the corresponding parameter condition, or the switch state of the filter indicated by the currently traversed processing node is in the off state, the traversal continues to the next processing node until the target processing node is traversed, and a calculation result is generated to indicate that the service request is processed using the filter indicated by the target processing node. When the last processing node is traversed, the traversal is stopped, wherein the switch state of the filter indicated by the target processing node is in the on state and the actual parameter values ​​of each configuration parameter configured by the target processing node meet the corresponding parameter conditions.

[0059] Step 207: Based on the calculation result, the service request is processed using a filter in the microservice gateway indicated by at least one processing node in the request processing link.

[0060] It should be noted that the execution process of step 201 and step 207 can be implemented in any way in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0061] In summary, by traversing the configuration sub-information associated with multiple processing nodes in sequence, the processing logic is dynamically adjusted according to actual needs. When the filter switch state indicated by the currently traversed processing node is an on processing node, the parameter conditions of the configuration parameters of the node are further obtained, and the service request is parsed to verify whether the actual value of the configuration parameter meets the corresponding parameter condition. When all relevant parameters meet the corresponding parameter condition, the filter indicated by the current processing node is selected to process the service request. This not only improves the flexibility and scalability of the system, but also ensures that the service request is accurately and effectively processed according to predetermined rules and conditions, thereby improving the user experience.

[0062] In order to clearly illustrate how the filter in the microservice gateway indicated by at least one processing node in the request processing link is used to process the service request according to the calculation result in the above embodiment, the present disclosure proposes another service request processing method.

[0063] Figure 3 It is a flow chart of a service request processing method shown in the third embodiment of the present disclosure. It should be noted that the embodiment of the present disclosure is applied to a microservice gateway.

[0064] like Figure 3As shown, the service request processing method includes the following steps:

[0065] Step 301: Obtain service configuration information associated with the service cluster from a database.

[0066] Step 302, in response to receiving a service request sent by the client, using the specified service middleware in the microservice gateway, calculates the service request according to the service configuration information to obtain a calculation result.

[0067] Step 303: According to the filter indicated by the calculation result, at least one processing parameter corresponding to the indicated filter is obtained from the service configuration information.

[0068] In the embodiment of the present disclosure, the filters indicated by different processing nodes correspond to different processing parameters.

[0069] For example, Figure 4 As shown, when the processing node is an authentication processing node, the processing parameters corresponding to the authentication filter indicated by the authentication processing node include: message header, host, request method, requester Internet Protocol (IP) address, resource Uniform Resource Locator (URL) address, request parameters, Cookie and time; when the processing node is a current limiting processing node, the processing parameters corresponding to the current limiting filter indicated by the current limiting processing node include: requester IP, resource URL and user information user; when the processing node is a fuse processing node, the processing parameters indicated by the fuse processing node include the fuse threshold; when the processing node is a log processing node, the processing parameters corresponding to the log filter indicated by the log processing node include: request method, requester IP, resource URL address, etc. The processing parameters corresponding to the log filter are used to filter and process logs.

[0070] Step 304: parse the service request using the indicated filter to obtain a parameter value of at least one processing parameter.

[0071] In order to accurately process the service request, as an example, the service request is parsed using the indicated filter to extract and obtain a parameter value of at least one processing parameter from the service request.

[0072] Step 305: Use the indicated filter to process the service request according to the parameter value of at least one processing parameter.

[0073] In order to accurately process the service request, as a possible implementation method, a filter indicated by the calculation result is used to record, compare or verify the parameter value of at least one processing parameter according to preset rules and conditions.

[0074] As an example, in response to the indicated filter being an authentication filter, authentication processing logic information associated with the service cluster is obtained from the service configuration information; the authentication filter is used to perform authentication processing on a parameter value of at least one processing parameter according to the authentication processing logic information.

[0075] That is to say, when the indicated filter is an authentication filter, the authentication processing logic information associated with the service cluster is obtained from the service configuration information; then, the authentication filter performs authentication processing on the parameter value of at least one processing parameter according to the authentication processing logic information to ensure that these parameter values ​​meet specific security requirements and permission settings.

[0076] As another example, in response to the indicated filter being a current limiting filter, a current limiting rule associated with the service cluster is obtained from the service configuration information; the current limiting filter is used to perform current limiting processing on a parameter value of at least one processing parameter according to the current limiting rule.

[0077] That is to say, when the indicated filter is a current limiting filter, the current limiting rules associated with the service cluster are obtained from the service configuration information. Subsequently, the current limiting filter performs current limiting processing on the parameter value of at least one processing parameter according to the current limiting rule to ensure the stability and availability of the service, and prevent the service from crashing due to overload by controlling the service request rate or concurrency.

[0078] As another example, in response to the indicated filter being a fuse filter, a fuse threshold of at least one processing parameter is obtained from the service configuration information; in response to the parameter value of any processing parameter in the at least one processing parameter being greater than or equal to the corresponding fuse threshold, fuse processing is performed on the service request.

[0079] It is important to understand that when the number of service nodes in a service cluster increases and the interdependencies become complex, an abnormality in a service node may cause the entire service cluster to collapse, i.e., the "avalanche effect". To avoid the above problem, the fuse filter obtains the fuse threshold of at least one processing parameter from the service configuration information. When the parameter value of any processing parameter is greater than or equal to the corresponding fuse threshold, the fuse filter performs fuse processing on the service request to prevent the service cluster from collapsing.

[0080] As yet another example, in response to a filter indicated by a processing node in the calculation result being a log filter, at least one processing parameter is recorded.

[0081] It is important to understand that log filters are used to capture key information during the processing of service requests, including but not limited to the values ​​of processing parameters. By recording the processing parameters in the service request, the status of the service node can be traced back during subsequent analysis, monitoring or debugging, which facilitates subsequent problem troubleshooting, performance optimization, and service improvement.

[0082] Therefore, when the filter indicated by the processing node in the calculation result is a log filter, at least one processing parameter is recorded.

[0083] It should be noted that the execution process of steps 301 to 302 can be implemented in any manner in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0084] In summary, by obtaining at least one processing parameter corresponding to the indicated filter from the service configuration information according to the filter indicated by the calculation result; the indicated filter is used to parse the service request to obtain the parameter value of at least one processing parameter; the indicated filter is used to process the service request according to the parameter value of at least one processing parameter. Thus, the filter is automatically matched according to the calculation result, and the corresponding processing parameters are automatically extracted from the service configuration information, so that the corresponding processing parameters are processed according to the processing logic corresponding to the filter, thereby improving the flexibility and accuracy of service request processing.

[0085] In order to clearly explain how to obtain the service configuration information associated with the service cluster from the database in the above embodiment, the present disclosure proposes another service request processing method.

[0086] Figure 5 4 is a flow chart of a service request processing method shown in the fourth embodiment of the present disclosure. It should be noted that the embodiment of the present disclosure is applied to a microservice gateway.

[0087] like Figure 5 As shown, the service request processing method includes the following steps:

[0088] Step 501: Acquire multiple service configuration tables associated with a service cluster from a database.

[0089] As an example, when the microservice gateway is started, a configuration information acquisition request is sent to obtain multiple service configuration tables associated with the service cluster from the database, thereby obtaining service configuration information from the multiple service configuration tables.

[0090] In the embodiment of the present disclosure, as shown in Figures 6(A) and 6(B), multiple service configuration tables include: a path configuration table, a load information table, a load rule table, a service interface registry, a current limiting and fuse rule table, and a script configuration table. There is a mapping relationship between the multiple service configuration tables. For example, the mapping relationship between the path configuration table and the service interface registry is one-to-one, that is, each service interface has a unique corresponding path configuration information in the registry, and the mapping relationship between the service interface registry and the load rule table is one-to-one, or one-to-zero, that is, each service interface has a unique corresponding load rule in the registry, or there is no corresponding load rule.

[0091] Among them, it should be noted that the path configuration table is used to store the processing routing information associated with the service request, the load information table is used to store the basic load information associated with the service cluster, the load rule table is used to store the load rule information for maintaining the load balancing of the service cluster, the service interface registry is used to store the basic information of the service interface of the service cluster, the current limiting and fuse rule table is used to store the rule information for current limiting and fuse breaking of service requests, and the script configuration table is used to store the configuration information of the filter in the microservice gateway (such as authentication logic information).

[0092] In addition, it should be noted that before obtaining multiple service configuration tables associated with the server from the database, the service configuration information needs to be configured in the database, wherein the service configuration information is configured into the database using the following steps:

[0093] 1. In response to the creation operation, a plurality of blank service configuration tables are created in the database, and a mapping relationship between the plurality of blank service configuration tables is established;

[0094] 2. In response to a configuration operation on the service configuration information, the service configuration information is configured in a plurality of blank service configuration tables.

[0095] Step 502: Obtain service configuration information from multiple service configuration tables.

[0096] Furthermore, service configuration information is extracted from a plurality of service configuration tables.

[0097] Step 503: Store the service configuration information in the memory of the microservice gateway.

[0098] In order to improve the access speed of service configuration information and reduce the performance bottleneck caused by frequent access to the database, as an example, the service configuration information is directly loaded and saved in the memory space of the microservice gateway.

[0099] Step 504, in response to receiving the service request sent by the client, using the specified service middleware in the microservice gateway, calculates the service request according to the service configuration information to obtain a calculation result.

[0100] Step 505: Based on the calculation result, the service request is processed using a filter in the microservice gateway indicated by at least one processing node in the request processing link.

[0101] It should be noted that the execution process of steps 504 to 505 can be implemented in any manner in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0102] In summary, by obtaining multiple service configuration tables associated with the service cluster from the database, extracting service configuration information from them, and then storing the service configuration information in the memory of the microservice gateway, this not only improves the access speed of the service configuration information and reduces the performance bottleneck caused by frequent access to the database, but also enables microservices to quickly and efficiently obtain the latest configuration information when needed; in addition, by centrally storing the configuration information in the memory of the microservice gateway, the management and maintenance process of the configuration information is simplified, and the flexibility and scalability of the microservice architecture are improved.

[0103] Based on any of the above embodiments, the service request is processed according to the result of the filter indicated by at least one processing node, and when the processing result meets the set condition, the service request is forwarded. Figure 7 The embodiments are described in detail.

[0104] Figure 7 1 is a flow chart of a service request processing method shown in the fifth embodiment of the present disclosure. It should be noted that the embodiment of the present disclosure is applied to a microservice gateway.

[0105] like Figure 7 As shown, the service request processing method includes the following steps:

[0106] Step 701: Obtain a processing result of a filter indicated by at least one processing node processing a service request.

[0107] In an embodiment of the present disclosure, a filter indicated by at least one processing node is used to process a service request to obtain a processing result, which includes whether the service request passes authentication, whether it is limited and / or whether it is blown.

[0108] Step 702: In response to the processing result satisfying the set condition, a load balancing strategy of the service cluster is obtained from the service configuration information.

[0109] The load balancing strategy includes a load weight, which is used to determine the upper limit of the load of each service node in the service cluster.

[0110] As an example, when the processing result indicates that the service request has passed authentication, is not limited, and / or is not blown, the load balancing strategy of the service cluster is obtained from the service configuration information, wherein the load balancing strategy includes, but is not limited to, a round robin strategy, a random strategy, and a least connections strategy. Among them, the round robin strategy refers to assigning requests to each service node in the service node list in sequence until the end of the list, and then looping. The random strategy refers to randomly selecting a service node from the service cluster to respond to the request; the least connection strategy refers to selecting a service node with the least current number of connections (or number of requests) from the service cluster to respond to the new request.

[0111] Step 703: Based on the load weight, a load balancing strategy is executed on the service request to determine a target service node for responding to the service request from the service cluster.

[0112] As an example, based on the load balancing strategy, the probability of each service node being selected is calculated according to the load weight and current load status of the service node, and then, based on the probability of each service node being selected, a target service node is selected from multiple service nodes to respond to the service request.

[0113] Step 704: dispatch the service request to the target service node, so that the target service node responds to the service request.

[0114] Furthermore, after the target service node receives the service request, the target service node processes the service request and generates a corresponding response. Then, the target service node returns the response result to the microservice gateway, and the microservice gateway returns the response result to the client.

[0115] In summary, the processing result of the service request is processed by obtaining the filter indicated by at least one processing node; in response to the processing result satisfying the set conditions, the load balancing strategy of the service cluster is obtained from the service configuration information; based on the load weight, the load balancing strategy is executed on the service request to determine the target service node for responding to the service request from the service cluster; the service request is dispatched to the target service node so that the target service node responds to the service request. As a result, not only the resource utilization of the service cluster is improved, but also the scalability and flexibility of the service are enhanced. The load balancing strategy based on load weight ensures that the service requests are evenly distributed to each node in the service cluster, avoiding single point overload, so that the distributed system built based on the microservice architecture can better handle various service requests and improve the overall service quality and user experience.

[0116] In order to explain the above embodiment more clearly, an example is now given for illustration.

[0117] For example, Figure 8 As shown in the figure, taking the microservice gateway as the gateway between the front-end service nginx and the application server (instead of letting the front-end service directly request the application server) as an example, the gateway uniformly completes the current limiting, authentication, and fuse operations, and finally loads the requests that meet the requirements to the back-end application server.

[0118] Among them, this solution integrates sentinel service (specified service middleware) in the microservice gateway, and sentinel service provides authentication, current limiting or fuse algorithm services. Current limiting and fuse configuration information will be persisted in the database, and these configuration information will be read when the microservice gateway is started. When a service request comes, the configuration information will be transmitted to the sentinel service to complete the calculation, and decide whether to load the application service based on the calculation results. In addition, it should be noted that the load logic of this solution is to use the microservice gateway to integrate Hystrix, read the application server registration information from nacos, and complete the load forwarding according to the load weight.

[0119] Corresponding to the service request processing method provided in the above embodiment, the present disclosure also provides a service request processing device. Since the service request processing device provided in the embodiment of the present disclosure corresponds to the service request processing method provided in the above embodiment, the implementation method of the service request processing method is also applicable to the service request processing device provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.

[0120] Fig. 9 It is a structural diagram of a service request processing device shown in the sixth embodiment of the present disclosure.

[0121] like Fig. 9 As shown, the service request processing device 900 includes: an acquisition module 910, a calculation module 920 and a processing module 930.

[0122] Among them, the acquisition module 910 is used to obtain service configuration information associated with the service cluster from the database; the calculation module 920 is used to respond to the service request sent by the client, use the specified service middleware in the microservice gateway, and calculate the service request according to the service configuration information to obtain a calculation result; the processing module 930 is used to process the service request according to the calculation result, using the filter in the microservice gateway indicated by at least one processing node in the request processing link.

[0123] As a possible implementation method of the embodiment of the present disclosure, the service configuration information includes: configuration sub-information associated with multiple processing nodes in a request processing link; a computing module 920, which is used to traverse the configuration sub-information associated with the multiple processing nodes in sequence in response to receiving a service request sent by a client; obtain the switch state of the filter indicated by the currently traversed processing node; in response to the switch state of the filter indicated by the currently traversed processing node being on, obtain the parameter condition of at least one configuration parameter configured by the currently traversed processing node from the configuration sub-information associated with the currently traversed processing node; parse the service request to obtain the actual parameter value of at least one configuration parameter; when the actual parameter values ​​of each service parameter meet the corresponding parameter conditions, generate a calculation result for indicating that the service request is processed using the filter indicated by the currently traversed processing node.

[0124] As a possible implementation method of the embodiment of the present disclosure, the calculation module 920 is also used to respond to the presence of a target parameter in at least one configuration parameter, or the switch state of the filter indicated by the currently traversed processing node is in the off state, continue to traverse the next processing node until the target processing node is traversed, and generate a calculation result indicating that the service request is processed using the filter indicated by the target processing node; wherein the actual parameter value of the target parameter does not meet the corresponding parameter condition, the switch state of the filter indicated by the target processing node is in the on state and the actual parameter values ​​of each configuration parameter configured by the target processing node all meet the corresponding parameter conditions.

[0125] As a possible implementation method of an embodiment of the present disclosure, the processing module 930 is used to obtain at least one processing parameter corresponding to the indicated filter from the service configuration information according to the filter indicated by the calculation result; use the indicated filter to parse the service request to obtain the parameter value of at least one processing parameter; use the indicated filter to process the service request according to the parameter value of at least one processing parameter.

[0126] As a possible implementation method of the embodiment of the present disclosure, the processing module 930 is used to, in response to the indicated filter being an authentication filter, obtain authentication processing logic information associated with the service cluster from the service configuration information; using the authentication filter, perform authentication processing on the parameter value of at least one processing parameter according to the authentication processing logic information; in response to the indicated filter being a current limiting filter, obtain the current limiting rule associated with the service cluster from the service configuration information; using the current limiting filter, perform current limiting processing on the parameter value of at least one processing parameter according to the current limiting rule.

[0127] As a possible implementation method of the embodiment of the present disclosure, the processing module 930 is used to obtain the fuse threshold of at least one processing parameter from the service configuration information in response to the indicated filter being a fuse filter; in response to the parameter value of any processing parameter in at least one processing parameter being greater than or equal to the corresponding fuse threshold, perform fuse processing on the service request; in response to the filter indicated by the processing node in the calculation result being a log filter, record at least one processing parameter.

[0128] As a possible implementation method of the embodiment of the present disclosure, the acquisition module 910 is used to obtain multiple service configuration tables associated with the service cluster from the database; obtain the service configuration information from the multiple service configuration tables; and store the service configuration information in the memory of the microservice gateway.

[0129] As a possible implementation method of the embodiment of the present disclosure, the service configuration information is configured into the database using the following steps: in response to a creation operation, a plurality of blank service configuration tables are created in the database, and a mapping relationship between the plurality of blank service configuration tables is established; in response to a configuration operation on the service configuration information, the service configuration information is configured in the plurality of blank service configuration tables.

[0130] As a possible implementation manner of the embodiment of the present disclosure, the service request processing device 900 further includes: a scheduling module.

[0131] Among them, the scheduling module is used to obtain the processing result of the filter indicated by at least one processing node processing the service request; in response to the processing result satisfying the set conditions, the load balancing strategy of the service cluster is obtained from the service configuration information; wherein the load balancing strategy includes a load weight, and the load weight is used to determine the upper limit of the load of each service node in the service cluster; based on the load weight, the load balancing strategy is executed on the service request to determine the target service node for responding to the service request from the service cluster; the service request is scheduled to the target service node so that the target service node responds to the service request.

[0132] The service request processing device of the disclosed embodiment pre-configures the service configuration information associated with the service cluster in the database, and the microservice gateway dynamically obtains the service configuration information associated with the service cluster from the database, thereby avoiding the problem of non-persistence of the service configuration information. When receiving a service request from the client, the microservice gateway uses the specified service middleware to calculate the request according to the service configuration information, obtains the calculation result, and processes the request through the filter in the request processing link according to the calculation result, thereby realizing intelligent routing, load balancing, dynamic current limiting or fuse filtering of service requests, improving the scalability, flexibility and security of the system, while reducing the coupling degree of the system, making the management and maintenance of the service cluster more efficient.

[0133] In an exemplary embodiment, an electronic device is also provided.

[0134] Among them, electronic equipment includes:

[0135] processor;

[0136] a memory for storing processor-executable instructions;

[0137] The processor is configured to execute instructions to implement the service request processing method proposed in any of the aforementioned embodiments.

[0138] As an example, Fig.10 is a schematic diagram of the structure of an electronic device 1000 shown in an exemplary embodiment of the present disclosure, such as Fig.10 As shown, the electronic device 1000 may further include:

[0139] The memory 1010 and the processor 1020, the bus 1030 connecting different components (including the memory 1010 and the processor 1020), the memory 1010 stores a computer program, and when the processor 1020 executes the program, the service request processing method described in the embodiment of the present disclosure is implemented.

[0140] Bus 1030 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0141] The electronic device 1000 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 1000, including volatile and non-volatile media, removable and non-removable media.

[0142] The memory 1010 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 1040 and / or cache memory 1050. The server 1000 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 1060 may be used to read and write non-removable, non-volatile magnetic media ( Fig.10 not shown, usually called a "hard drive"). Although Fig.10Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 1030 via one or more data medium interfaces. The memory 1010 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.

[0143] A program / utility 1080 having a set (at least one) of program modules 1070 may be stored, for example, in the memory 1010, such program modules 1070 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 1070 generally perform the functions and / or methods of the embodiments described in the present disclosure.

[0144] The electronic device 1000 may also communicate with one or more external devices 1090 (e.g., keyboard, pointing device, display 1091, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or communicate with any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 1092. In addition, the electronic device 1000 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 1093. As shown, the network adapter 1093 communicates with other modules of the electronic device 1000 through a bus 1030. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0145] The processor 1020 executes various functional applications and data processing by running the programs stored in the memory 1010 .

[0146] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the service request processing method of the embodiment of the present disclosure, and will not be repeated here.

[0147] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, and the above instructions can be executed by a processor of an electronic device to complete the service request processing method proposed in any of the above embodiments. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0148] In an exemplary embodiment, a computer program product is also provided, including a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the service request processing method proposed in any of the above embodiments is implemented.

[0149] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0150] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A service request processing method, characterized in that: Applied to a microservice gateway, the method includes: Obtain service configuration information associated with the service cluster from the database; In response to receiving a service request sent by a client, using a designated service middleware in the microservice gateway to calculate the service request according to the service configuration information to obtain a calculation result; According to the calculation result, the service request is processed using a filter in the microservice gateway indicated by at least one processing node in the request processing link.

2. The method according to claim 1, characterized in that The service configuration information includes: configuration sub-information associated with a plurality of processing nodes in the request processing link; In response to receiving a service request sent by a client, using the specified service middleware in the microservice gateway, calculating the service request according to the service configuration information to obtain a calculation result, including: In response to receiving a service request sent by a client, sequentially traverse the configuration sub-information associated with the plurality of processing nodes; Get the switch status of the filter indicated by the currently traversed processing node; In response to the switch state of the filter indicated by the currently traversed processing node being on, acquiring a parameter condition of at least one configuration parameter configured by the currently traversed processing node from configuration sub-information associated with the currently traversed processing node; Parsing the service request to obtain an actual parameter value of the at least one configuration parameter; When the actual parameter values ​​of the service parameters all meet the corresponding parameter conditions, a calculation result is generated for indicating that the service request is processed using the filter indicated by the currently traversed processing node.

3. The method according to claim 2, characterized in that The method further comprises: In response to the presence of a target parameter in the at least one configuration parameter, or the switch state of the filter indicated by the currently traversed processing node is in an off state, the next processing node is continued to be traversed until the target processing node is traversed, and a calculation result for indicating that the service request is processed using the filter indicated by the target processing node is generated; Among them, the actual parameter value of the target parameter does not meet the corresponding parameter condition, the switch state of the filter indicated by the target processing node is on and the actual parameter values ​​of each configuration parameter configured by the target processing node meet the corresponding parameter condition.

4. The method according to any one of claims 1 to 3, characterized in that The method of processing the service request according to the calculation result by using a filter in the microservice gateway indicated by at least one processing node in the request processing link includes: According to the filter indicated by the calculation result, acquiring at least one processing parameter corresponding to the indicated filter from the service configuration information; parsing the service request using the indicated filter to obtain a parameter value of the at least one processing parameter; The service request is processed using the indicated filter according to a parameter value of the at least one processing parameter.

5. The method according to claim 4, characterized in that The adopting the indicated filter and processing the service request according to the parameter value of the at least one processing parameter includes: In response to the indicated filter being an authentication filter, acquiring authentication processing logic information associated with the service cluster from the service configuration information; Using the authentication filter, and according to the authentication processing logic information, performing authentication processing on the parameter value of the at least one processing parameter; In response to the indicated filter being a current limiting filter, acquiring a current limiting rule associated with the service cluster from the service configuration information; The current limiting filter is used to perform current limiting processing on the parameter value of the at least one processing parameter according to the current limiting rule.

6. The method according to claim 4, characterized in that The adopting the indicated filter and processing the service request according to the parameter value of the at least one processing parameter includes: In response to the indicated filter being a fuse filter, acquiring a fuse threshold of the at least one processing parameter from the service configuration information; In response to a parameter value of any processing parameter of the at least one processing parameter being greater than or equal to a corresponding fuse threshold, performing fuse processing on the service request; In response to the filter indicated by the processing node in the calculation result being a log filter, the at least one processing parameter is recorded.

7. The method according to claim 1, characterized in that The obtaining of service configuration information associated with the server from the database includes: Acquire a plurality of service configuration tables associated with the service cluster from the database; Acquire the service configuration information from the multiple service configuration tables; The service configuration information is stored in the memory of the microservice gateway.

8. The method according to claim 7, characterized in that The service configuration information is configured into the database using the following steps: In response to the creation operation, a plurality of blank service configuration tables are created in the database, and a mapping relationship between the plurality of blank service configuration tables is established; In response to a configuration operation on the service configuration information, the service configuration information is configured in the plurality of blank service configuration tables.

9. The method according to claim 1, characterized in that: The method further comprises: Obtaining a processing result of the filter indicated by the at least one processing node processing the service request; In response to the processing result satisfying the set condition, obtaining a load balancing strategy of the service cluster from the service configuration information; wherein the load balancing strategy includes a load weight, and the load weight is used to determine the load upper limit of each service node in the service cluster; Based on the load weight, executing the load balancing strategy on the service request to determine a target service node for responding to the service request from the service cluster; The service request is dispatched to the target service node, so that the target service node responds to the service request.

10. A service request processing device, characterized in that: Applied to a microservice gateway, the device comprises: An acquisition module is used to obtain service configuration information associated with the service cluster from a database; A calculation module, configured to, in response to receiving a service request sent by a client, use a designated service middleware in the microservice gateway to calculate the service request according to the service configuration information to obtain a calculation result; A processing module is used to process the service request according to the calculation result using a filter in the microservice gateway indicated by at least one processing node in the request processing link.

Citation Information

Patent Citations

  • Service management and control system based on micro-service architecture

    CN110971449A

  • Service grid configuration method and device based on micro-service architecture, equipment and medium

    CN112000365A

  • Meteorological data service platform based on micro-service architecture

    CN113904917A

  • Micro-service gateway plug-in dynamic loading method, device and system and storage medium thereof

    CN115134235A

  • Micro-service architecture design method and device and computer readable storage medium

    CN115695138A