A flow control method, device and computer equipment
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- IND BANK CO
- Filing Date
- 2023-05-12
- Publication Date
- 2026-06-19
Smart Images

Figure CN116489089B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a traffic control method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] With the development of technology and the increasing prevalence of Internet applications, when a server is accessed by a large number of users, in order to ensure the stability of server operation, rate limiting is used to control the flow and prevent problems such as service quality degradation and latency caused by a large amount of access traffic.
[0003] In related technologies, rate limiting conditions can be set, and all access requests will be rejected once the rate limiting conditions are met. However, existing degradation strategies cannot achieve fine-grained traffic control. Summary of the Invention
[0004] Based on this, it is necessary to provide a flow control method, device, computer equipment, storage medium, and computer program product to address the aforementioned technical problems. This method can establish user level lists and interface level lists, and when the resource usage of a business processing request exceeds the flow limiting threshold, it can determine whether to execute the business processing request based on the established lists.
[0005] Firstly, this application provides a flow control method. The method includes:
[0006] Obtain a business processing request including an authentication token, wherein the authentication token includes at least one of user information and historical access counts, and add the authentication token to a preset user level list according to the historical access counts;
[0007] Parse the business processing request to obtain the service interface of the microservice node;
[0008] When the resource usage of the business processing request exceeds the first rate limiting threshold, the user level list and interface level list returned by the service interface are received and cached locally. The interface level list is determined based on the resource usage data parameters of each service interface in all preset microservice nodes.
[0009] If the user information in the business processing request matches the user level list, and the service interface matches the interface level list, then the business processing request is executed.
[0010] In one embodiment, the method further includes:
[0011] When the resource usage of the business processing request exceeds the second rate limiting threshold, the service interface intercepts the business processing request and returns a rate limiting prompt to the client.
[0012] In one embodiment, the interface level list is obtained by means of:
[0013] Calculate the interface weight of the service interface based on the resource usage parameters of the microservice node and service interface;
[0014] The service interfaces are sorted according to their respective weights to obtain the interface level list.
[0015] In one embodiment, the method further includes:
[0016] User information is obtained based on the authentication token, and user access permission information is obtained through the user information, wherein the access permission information includes a list of interface addresses that the user can access;
[0017] If the service interface in the business processing request is not in the interface address list, the service interface will intercept the business processing request.
[0018] In one embodiment, the first rate limiting threshold and the second rate limiting threshold are determined based on the resource usage parameters of the service node.
[0019] Secondly, this application also provides a flow control device, the device comprising:
[0020] A generation module is used to obtain a business processing request including an authentication token, wherein the authentication token includes at least one of user information and historical access counts, and adds the authentication token to a preset user level list according to the historical access counts;
[0021] The parsing module is used to parse the business processing request and obtain the service interface of the microservice node;
[0022] The judgment module is used to receive the user level list and interface level list returned by the service interface to the local cache when the resource usage of the business processing request is greater than the first rate limiting threshold. The interface level list is determined according to the resource usage data parameters of each service interface in all preset microservice nodes.
[0023] The matching module is used to execute the business processing request if the user information in the business processing request matches the user level list and the service interface matches the interface level list.
[0024] In one embodiment, the device further includes:
[0025] When the resource usage of the business processing request exceeds the second rate limiting threshold, the service interface intercepts the business processing request and returns a rate limiting prompt to the client.
[0026] In one embodiment, the interface level list is obtained by means of:
[0027] Calculate the interface weight of the service interface based on the resource usage parameters of the microservice node and service interface;
[0028] The service interfaces are sorted according to their respective weights to obtain the interface level list.
[0029] In one embodiment, the device further includes:
[0030] User information is obtained based on the authentication token, and user access permission information is obtained through the user information, wherein the access permission information includes a list of interface addresses that the user can access;
[0031] If the service interface in the business processing request is not in the interface address list, the service interface will intercept the business processing request.
[0032] In one embodiment, the first rate limiting threshold and the second rate limiting threshold are determined based on the resource usage parameters of the service node.
[0033] Thirdly, this disclosure also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of a flow control method.
[0034] Fourthly, this disclosure also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of a flow control method.
[0035] Fifthly, this disclosure also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of a flow control method.
[0036] The above-mentioned flow control method has at least the following beneficial effects:
[0037] The embodiments provided in this disclosure can create a user level list based on authentication token information and an interface level list based on resource usage data parameters of service interfaces. Upon receiving a business processing request, if resource usage exceeds a first rate-limiting threshold, it can determine whether to execute the business processing request based on the user level list and the interface level list. After reaching the initial rate-limiting threshold, it can ensure that high-priority service interfaces and users execute business requests first. The maximum rate-limiting threshold of the service interface is used as a second rate-limiting threshold. After reaching the maximum rate-limiting threshold, all business processing requests are restricted, improving the accuracy of traffic control.
[0038] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments or conventional technologies of this disclosure, the accompanying drawings used in the description of the embodiments or conventional technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a diagram illustrating the application environment of the flow control method in one embodiment;
[0041] Figure 2 This is a flowchart illustrating a flow control method in one embodiment;
[0042] Figure 3 This is a flowchart illustrating a flow control method in one embodiment;
[0043] Figure 4 This is a structural block diagram of a flow control device in one embodiment;
[0044] Figure 5 This is a structural block diagram of a flow control device in one embodiment;
[0045] Figure 6 This is an internal structural diagram of a computer device in one embodiment;
[0046] Figure 7 This is an internal structure diagram of a server in one embodiment. Detailed Implementation
[0047] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0048] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure 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 this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims. The terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of other identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any specific order.
[0049] This disclosure provides a flow control method that can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0050] In some embodiments of this disclosure, such as Figure 2 As shown, a flow control method is provided, which is applied to... Figure 1 This method is illustrated using the example of a server processing a business request. It is understood that this method can be applied to a server, and also to a system including both a terminal and a server, and is implemented through the interaction between the terminal and the server. In a specific embodiment, the method may include the following steps:
[0051] S202: Obtain a business processing request including an authentication token, wherein the authentication token includes at least one of user information and historical access counts, and add the authentication token to a preset user level list according to the historical access counts.
[0052] Before executing a business processing request sent by a client, the server can first verify the user information. After successful verification, the server executes the business processing request. Typically, the client sends a login request to the server. Upon receiving the login request, the server verifies the user information, which may include the user's identifier, key, name, etc. If the verification is successful, an authentication token is generated and returned to the client. The authentication token can be stored in a cache containing the latest user information. Users can send multiple business processing requests, and user information and historical access counts can be recorded in the authentication token. Based on historical access counts, the authentication token can be added to a preset user level list.
[0053] S204: Parse the business processing request to obtain the service interface of the microservice node.
[0054] A microservice architecture can include multiple microservice nodes, each corresponding to a sub-business module. Each microservice node can integrate at least one service interface. The process involves parsing business processing requests, locating the corresponding sub-business module (i.e., the microservice node), and then executing the request through the microservice node's service interface.
[0055] S206: When the resource usage of the business processing request exceeds the first rate limiting threshold, the user level list and interface level list returned by the service interface are received and cached locally. The interface level list is determined based on the resource usage data parameters of each service interface in all preset microservice nodes.
[0056] Resource usage data parameters for a service interface can refer to parameters reflecting the resource usage of the service interface, and may include, but are not limited to, the following values: average CPU usage time per unit time, average memory usage per unit time, and average network bandwidth consumption per unit time. Resource usage data parameters can also refer to parameters reflecting the service interface's capabilities, and may include, but are not limited to, the following values: average processing time per unit time, interface baseline response time, and number of calls per unit time.
[0057] The rate limiting threshold for each service interface can be calculated based on its resource usage. An interface level list is then created based on each service interface's rate limiting threshold. The resource usage of a business processing request is determined. When the resource usage of a business processing request exceeds the first rate limiting threshold, the user level list and interface level list returned by the service interface are received and cached locally to determine whether to execute the business processing request.
[0058] S208: If the user information in the business processing request matches the user level list and the service interface matches the interface level list, execute the business processing request.
[0059] User information in the user level list changes with the number of user visits. If the user information in the business processing request has a high priority in the user level list, and the interface level list contains the service interface for the business processing request, the business processing request can be executed. This ensures that when resource usage reaches the first rate limiting threshold, most users already in use can continue to access the system.
[0060] In the above traffic control method, a user level list can be created based on the authentication token information, and an interface level list can be created based on the resource usage data parameters of the service interface. Upon receiving a business processing request, if the resource usage exceeds the first rate-limiting threshold, it can be determined whether to execute the business processing request based on the user level list and the interface level list. After reaching the initial rate-limiting threshold, it can ensure that high-priority service interfaces and users execute business requests first, improving the flexibility of traffic control.
[0061] In some embodiments of this disclosure, Figure 3 This is a flowchart illustrating a flow control method in one embodiment, the method further comprising:
[0062] S302: When the resource usage of the business processing request exceeds the second rate limiting threshold, the service interface intercepts the business processing request and returns a rate limiting prompt to the client.
[0063] The maximum rate limiting threshold for each service interface can be calculated based on its average processing time per unit time, baseline response time, and number of calls per unit time. The highest rate limiting threshold among all service interfaces can be used as the second rate limiting threshold. When the resource usage of a business processing request exceeds the second rate limiting threshold, a server rate limiting warning message is returned directly.
[0064] When the first rate-limiting threshold is reached, rate limiting can be implemented using a combination of user level and interface level lists. When the second rate-limiting threshold is reached, an indiscriminate rate-limiting approach can be adopted, rejecting all business processing requests. This ensures that high-priority business interfaces and users can use resources, improving the accuracy of traffic control.
[0065] In some embodiments of this disclosure, the interface level list is obtained in the following ways:
[0066] Calculate the interface weight of the service interface based on the resource usage parameters of the microservice node and service interface;
[0067] The service interfaces are sorted according to their respective weights to obtain the interface level list.
[0068] A microservice architecture comprises multiple microservice nodes, each corresponding to a sub-business module. Each microservice node can integrate at least one service interface. The interface weight of each service interface is calculated based on both the service level of the microservice node and the interface level of each service interface within that node. The service level of a microservice node reflects its importance, while the interface level reflects the importance of its service interface. Service interfaces in the interface level list are arranged in order of priority.
[0069] In some embodiments of this disclosure, the method further includes:
[0070] User information is obtained based on the authentication token, and user access permission information is obtained through the user information, wherein the access permission information includes a list of interface addresses that the user can access;
[0071] If the service interface in the business processing request is not in the interface address list, the service interface will intercept the business processing request.
[0072] Users can initiate business processing requests and call service interfaces to execute tasks. The interface can obtain the user's access permission information based on the authentication token information in the business processing request. The access permission information can include a list of interface addresses that the user can access. If the service interface address in the business processing request is not included in the list of interface addresses, the service interface cannot execute the business processing request and can return an error message to the client to remind the user.
[0073] In some embodiments of this disclosure, the first rate limiting threshold and the second rate limiting threshold are determined based on the resource usage parameters of the service node.
[0074] It can obtain resource usage data parameters for each service interface in a microservice node, calculate the rate limiting threshold for each service interface, and formulate a first rate limiting threshold based on the rate limiting threshold and rate limiting requirements for each service interface. The highest rate limiting threshold among all service interfaces can be used as the second rate limiting threshold. If the resource usage reaches the second rate limiting threshold, the service interface will refuse to execute business processing requests.
[0075] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0076] Based on the same inventive concept, this disclosure also provides a flow control device for implementing the flow control method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in the flow control device embodiments provided below can be found in the limitations of the flow control method described above, and will not be repeated here.
[0077] The apparatus may include a system (including a distributed system), software (application), module, component, server, client, etc., that uses the methods described in the embodiments of this specification, combined with necessary hardware implementation. Based on the same innovative concept, the apparatuses in one or more embodiments provided in this disclosure are as described in the following embodiments. Since the implementation schemes and methods for solving the problem by the apparatus are similar, the implementation of the specific apparatus in the embodiments of this specification can refer to the implementation of the foregoing methods, and repeated details will not be repeated. As used below, the terms "unit" or "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the apparatuses described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0078] In one embodiment, such as Figure 4 As shown, a flow control device 400 is provided. This device can be the aforementioned server, or a module, component, device, or unit integrated into the server. The device 400 may include:
[0079] The generation module 402 is used to obtain a business processing request including an authentication token, wherein the authentication token includes at least one of user information and historical access counts, and adds the authentication token to a preset user level list according to the historical access counts;
[0080] Parsing module 404 is used to parse the business processing request to obtain the service interface of the microservice node;
[0081] The judgment module 406 is used to receive the user level list and interface level list returned by the service interface to the local cache when the resource usage of the business processing request is greater than the first rate limiting threshold. The interface level list is determined according to the resource usage data parameters of each service interface in all preset microservice nodes.
[0082] The matching module 408 is used to execute the business processing request if the user information in the business processing request matches the user level list and the service interface matches the interface level list.
[0083] In one embodiment, Figure 5 This is a structural block diagram of a flow control device in one embodiment, the device further comprising:
[0084] The interception module 502 is used to intercept the service processing request and return a rate limiting prompt to the client when the resource usage of the service processing request exceeds the second rate limiting threshold.
[0085] In one embodiment, the interface level list is obtained by means of:
[0086] Calculate the interface weight of the service interface based on the resource usage parameters of the microservice node and service interface;
[0087] The service interfaces are sorted according to their respective weights to obtain the interface level list.
[0088] In one embodiment, the apparatus further includes:
[0089] User information is obtained based on the authentication token, and user access permission information is obtained through the user information, wherein the access permission information includes a list of interface addresses that the user can access;
[0090] If the service interface in the business processing request is not in the interface address list, the service interface will intercept the business processing request.
[0091] In one embodiment, the first rate limiting threshold and the second rate limiting threshold are determined based on the resource usage parameters of the service node.
[0092] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0093] The modules described above in the flow control device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0094] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores business processing requests. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a flow control method.
[0095] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a flow control method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0096] Those skilled in the art will understand that Figure 6 , Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present disclosure and does not constitute a limitation on the computer device to which the present disclosure is applied. A specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0097] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the methods described in any embodiment of this disclosure.
[0098] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the methods described in any embodiment of this disclosure.
[0099] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this disclosure may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this disclosure may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0100] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0101] The embodiments described above are merely illustrative of several implementations of this disclosure, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent disclosure. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this disclosure, and these all fall within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the appended claims.
Claims
1. A flow control method, characterized in that, The method includes: Obtain a business processing request including an authentication token, wherein the authentication token includes user information and historical access counts, and add the authentication token to a preset user level list based on the historical access counts; Parse the business processing request to obtain the service interface of the microservice node; Calculate the rate limiting threshold for each service interface based on the resource usage of each service interface in the microservice node, and formulate an interface level list based on the rate limiting threshold for each service interface. When the resource usage of the business processing request exceeds the first rate limiting threshold, the user level list and interface level list returned by the service interface are received and cached locally. The interface level list is determined based on the resource usage data parameters of each service interface in all preset microservice nodes, and the user information in the user level list changes with the number of times the user accesses the service. If the user information in the business processing request matches the user level list, and the service interface matches the interface level list, the business processing request is executed. Matching the user information in the business processing request with the user level list includes: the user information in the business processing request has a higher priority in the user level list. Matching the service interface with the interface level list includes: the interface level list contains the service interface of the business processing request.
2. The method according to claim 1, characterized in that, The method further includes: When the resource usage of the business processing request exceeds the second rate limiting threshold, the service interface intercepts the business processing request and returns a rate limiting prompt to the client.
3. The method according to claim 1, characterized in that, The methods for obtaining the interface level list include: Calculate the interface weight of the service interface based on the resource usage parameters of the microservice node and service interface; The service interfaces are sorted according to their respective weights to obtain the interface level list.
4. The method according to claim 1, characterized in that, The method further includes: User information is obtained based on the authentication token, and user access permission information is obtained through the user information, wherein the access permission information includes a list of interface addresses that the user can access; If the service interface in the business processing request is not in the interface address list, the service interface will intercept the business processing request.
5. The method according to claim 2, characterized in that, The first rate limiting threshold and the second rate limiting threshold are determined based on the resource usage parameters of the service node.
6. A flow control device, characterized in that, The device includes: A generation module is used to obtain a business processing request including an authentication token, wherein the authentication token includes user information and historical access counts, and adds the authentication token to a preset user level list based on the historical access counts; The parsing module is used to parse the business processing request and obtain the service interface of the microservice node; Calculate the rate limiting threshold for each service interface based on the resource usage of each service interface in the microservice node, and formulate an interface level list based on the rate limiting threshold for each service interface. The judgment module is used to receive the user level list and interface level list returned by the service interface to the local cache when the resource usage of the business processing request is greater than the first rate limiting threshold. The interface level list is determined according to the resource usage data parameters of each service interface in all preset microservice nodes, and the user information in the user level list changes with the number of times the user accesses the service. The matching module is used to execute the business processing request if the user information in the business processing request matches the user level list and the service interface matches the interface level list. Matching the user information in the business processing request with the user level list includes: the user information in the business processing request has a higher priority in the user level list; matching the service interface with the interface level list includes: the interface level list contains the service interface of the business processing request.
7. The apparatus according to claim 6, characterized in that, The device further includes: The interception module is used to intercept the service processing request and return a rate limiting prompt to the client when the resource usage of the service processing request exceeds the second rate limiting threshold.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the flow control method according to any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the flow control method according to any one of claims 1 to 5.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the flow control method according to any one of claims 1 to 5.