Intelligent current limiting method and device for API calling, equipment and storage medium

By dynamically adjusting the API current limit rules, using real-time computing modules and log information to optimize the API calls of microservices, the problem that the API current limit rules cannot be adjusted in real time in the existing technology is solved, and the system is stable and trough periods are realized. Optimization of resource utilization.

CN119094446APending Publication Date: 2024-12-06PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411086425.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

The existing technology cannot dynamically adjust API current limit rules to cope with real-time business needs, resulting in system overload during peak periods or underutilization of resources during trough periods, affecting system stability and user experience.

Method used

By obtaining the log information when the microservice calls the API, using the real-time computing module to dynamically determine the API call flow limit rules for each microservice, adjust the optimal flow limit based on the real-time API call information, and update the flow limit rules database to judge each API every time Whether the call triggers the current limiting rule to decide whether to allow the call.

Benefits of technology

Effectively respond to traffic fluctuations during peak business periods, avoid system overload, and at the same time make full use of system resources during trough periods, improve system stability and intelligence level, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094446A_ABST
    Figure CN119094446A_ABST
Patent Text Reader

Abstract

The invention relates to an intelligent flow limiting method for API (Application Program Interface) calling, aiming at solving the problem that an API flow limiting rule cannot be dynamically adjusted to cope with a real-time service requirement in the prior art. According to the method, the API calling logs generated when the micro-service calls the API are obtained, and the API calling information is obtained according to the logs; meanwhile, determining a real-time calculation module, and dynamically determining an API calling flow limiting rule of each micro-service by utilizing the real-time calculation module and the API calling information; and when a certain micro-service calls the API, judging whether the call triggers the flow limiting rule of the micro-service or not, and if not, allowing the micro-service to call the API. According to the invention, by dynamically adjusting the flow limiting rule, the flow fluctuation in the service peak period can be effectively dealt with, the system overload is avoided, meanwhile, the system resources are fully utilized in the service valley period, and the stability and the intelligent level of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an API call intelligent current limiting method, device, equipment and storage medium. Background Art

[0002] In modern computer systems and network architectures, especially with the widespread use of cloud computing and microservice architectures, the frequency and number of API (application programming interface) calls are becoming increasingly high. The high frequency of API calls brings huge load pressure to the system. If not controlled, it may cause a significant decline in system performance or even cause the system to crash. Therefore, current limiting technology has become an important means to ensure system stability.

[0003] Traditional rate limiting technologies are mainly based on static rules, such as fixed rate limiting or rate limiting within a fixed time window (such as the token bucket algorithm). Although these methods can effectively limit the number of requests and prevent system overload to a certain extent, they lack flexibility and intelligence and cannot be dynamically adjusted according to real-time business needs and system load conditions. For example, when business peaks, static rate limiting rules may be too strict, resulting in normal requests being rejected, thus affecting user experience; while during business troughs, static rate limiting rules may appear too loose and fail to fully utilize system resources.

[0004] At present, there are some research and application practices that try to introduce real-time computing frameworks (such as Apache Flink, Apache Spark) and message middleware (such as Kafka) into current limiting technology, and realize dynamic adjustment and intelligent management of current limiting rules through real-time data processing and streaming computing. Although these technologies have improved the flexibility and intelligence of current limiting strategies to a certain extent, they still face many challenges in specific implementation, such as the real-time nature of data processing, the accuracy of current limiting rules, and the scalability of the system. Summary of the invention

[0005] The main purpose of the present invention is to provide an API call intelligent current limiting method, device, equipment and storage medium, aiming to solve the technical problem that the existing technology cannot dynamically adjust API current limiting rules to meet real-time business needs.

[0006] To achieve the above object, the present invention provides an API call intelligent current limiting method, which includes the following steps:

[0007] Obtain the API call log generated when the microservice calls the API, and obtain the API call information according to the API call log;

[0008] Determine a real-time computing module, and use the real-time computing module and the API call information to determine an API call current limiting rule for each microservice;

[0009] When a microservice calls the API, it is determined whether the call triggers the API call current limiting rule of the microservice. If not, the microservice is allowed to call the API.

[0010] Optionally, the step of determining the API call current limiting rule for each microservice by using the real-time calculation module and the API call information includes:

[0011] Determine the optimal flow limit of the API according to the API call information, and obtain the total number of microservices and the weight of each microservice;

[0012] Utilize the real-time calculation module to calculate the API call flow limiting rule for each microservice according to the optimal flow limiting, the total number of microservices, and the weight of each microservice;

[0013] The API call current limiting rules of each microservice are stored in the current limiting rules database.

[0014] Optionally, before the step of determining whether the call triggers the API call current limiting rule of the microservice, the step further includes:

[0015] Determine whether the API call current limiting rule of the microservice has changed according to the current limiting rule database;

[0016] If not, execute the following steps: determine whether the call triggers the API call current limiting rule of the microservice;

[0017] If so, determine whether to allow the microservice to call the API based on the changed API call current limiting rule.

[0018] Optionally, before the step of determining whether the API call current limiting rule of the microservice has changed according to the current limiting rule database, the step further includes:

[0019] The real-time calculation module obtains real-time API call information, dynamically adjusts the optimal flow limit of the API according to the real-time API call information, and updates the API call flow limit rules of each microservice in the flow limit rule database according to the adjusted optimal flow limit.

[0020] Optionally, the step of determining the optimal flow limit of the API according to the API call information includes:

[0021] The optimal flow limit of the API is determined based on the API call information, system capacity and business requirements.

[0022] Optionally, the step of obtaining API call information according to the API call log includes:

[0023] The API call log is sent to a log collection module, and the log collection module extracts the API call information from the API call log.

[0024] Optionally, after the step of extracting the API call information from the API call log by the log collection module, the step further includes:

[0025] The log collection module uses the kafka message middleware to send the API call information to the log message module;

[0026] The log message module sends the API call information to the real-time calculation module in real time.

[0027] Furthermore, in order to achieve the above-mentioned object, the present invention also provides an API call intelligent current limiting device, and the API call intelligent current limiting device comprises:

[0028] A real-time acquisition module obtains the API call log generated when the microservice calls the API, and obtains the API call information according to the API call log;

[0029] A real-time computing module is used to determine a real-time computing module, and to determine an API call current limiting rule for each microservice by using the real-time computing module and the API call information;

[0030] The current limiting module is called. When a microservice calls the API, it is determined whether the call triggers the API call current limiting rule of the microservice. If not, the microservice is allowed to call the API.

[0031] Furthermore, to achieve the above-mentioned purpose, the present invention also provides an API call intelligent current limiting device, wherein the API call intelligent current limiting device includes a memory, a processor, and an API call intelligent current limiting program stored in the memory and executable on the processor, and when the API call intelligent current limiting program is executed by the processor, the steps of the API call intelligent current limiting method as described above are implemented.

[0032] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a storage medium, on which an API call intelligent current limiting program is stored, and when the API call intelligent current limiting program is executed by a processor, the steps of the API call intelligent current limiting method as described above are implemented.

[0033] The present invention relates to an intelligent current limiting method for API calls, which aims to solve the problem that the existing technology cannot dynamically adjust API current limiting rules to cope with real-time business needs. The present invention obtains the API call logs generated when the microservice calls the API, and obtains the API call information based on these logs; at the same time, a real-time calculation module is determined, and the module and the API call information are used to dynamically determine the API call current limiting rules for each microservice; when a microservice calls the API, it is determined whether the call triggers the current limiting rules of the microservice, and if not, the microservice is allowed to call the API. By dynamically adjusting the current limiting rules, the present invention can effectively cope with traffic fluctuations during business peaks and avoid system overloads. At the same time, it makes full use of system resources during business troughs to improve the stability and intelligence level of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of the structure of the device hardware operating environment involved in the embodiment of the API calling intelligent current limiting device of the present invention;

[0035] Figure 2 This is a flow chart of the first embodiment of the API call intelligent current limiting method of the present invention;

[0036] Figure 3 This is a functional module diagram of a preferred embodiment of an API-based intelligent current limiting device of the present invention.

[0037] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0038] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0039] It should be noted that in modern computer systems and network architectures, especially with the widespread application of cloud computing and microservice architectures, the frequency and number of API (application programming interface) calls are becoming increasingly high. The high frequency of API calls brings huge load pressure to the system. If it is not controlled, it may cause a significant decline in system performance or even cause the system to crash. Therefore, current limiting technology has become an important means to ensure system stability.

[0040] Traditional rate limiting technologies are mainly based on static rules, such as fixed rate limiting or rate limiting within a fixed time window (such as the token bucket algorithm). Although these methods can effectively limit the number of requests and prevent system overload to a certain extent, they lack flexibility and intelligence and cannot be dynamically adjusted according to real-time business needs and system load conditions. For example, when business peaks, static rate limiting rules may be too strict, resulting in normal requests being rejected, thus affecting user experience; while during business troughs, static rate limiting rules may appear too loose and fail to fully utilize system resources.

[0041] At present, there are some research and application practices that try to introduce real-time computing frameworks (such as Apache Flink, Apache Spark) and message middleware (such as Kafka) into current limiting technology, and realize dynamic adjustment and intelligent management of current limiting rules through real-time data processing and streaming computing. Although these technologies have improved the flexibility and intelligence of current limiting strategies to a certain extent, they still face many challenges in specific implementation, such as the real-time nature of data processing, the accuracy of current limiting rules, and the scalability of the system.

[0042] Based on the above defects, the present invention provides an API calling intelligent current limiting device, referring to Figure 1 , Figure 1 This is a structural diagram of the device hardware operating environment involved in the implementation scheme of the API calling intelligent current limiting device of the present invention.

[0043] like Figure 1 As shown, the API call intelligent current limiting device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0044] Those skilled in the art will understand that Figure 1 The hardware structure of the API call intelligent current limiting device shown in the figure does not constitute a limitation on the API call intelligent current limiting device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0045] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and an API call intelligent current limiting program. Among them, the operating system is a program for managing and controlling the API call intelligent current limiting device and software resources, supporting the operation of the network communication module, the user interface module, the API call intelligent current limiting program and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.

[0046] exist Figure 1 In the hardware structure of the API call intelligent current limiting device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client and communicate data with the client; the processor 1001 can call the API call intelligent current limiting program stored in the memory 1005 and perform the following operations:

[0047] Obtain the API call log generated when the microservice calls the API, and obtain the API call information according to the API call log;

[0048] Determine a real-time computing module, and use the real-time computing module and the API call information to determine an API call current limiting rule for each microservice;

[0049] When a microservice calls the API, it is determined whether the call triggers the API call current limiting rule of the microservice. If not, the microservice is allowed to call the API.

[0050] Furthermore, the step of determining the API call current limiting rule for each microservice by using the real-time calculation module and the API call information includes:

[0051] Determine the optimal flow limit of the API according to the API call information, and obtain the total number of microservices and the weight of each microservice;

[0052] Utilize the real-time calculation module to calculate the API call flow limiting rule for each microservice according to the optimal flow limiting, the total number of microservices, and the weight of each microservice;

[0053] The API call current limiting rules of each microservice are stored in the current limiting rules database.

[0054] Furthermore, before the step of determining whether the call triggers the API call current limiting rule of the microservice, the method further includes:

[0055] Determine whether the API call current limiting rule of the microservice has changed according to the current limiting rule database;

[0056] If not, execute the following steps: determine whether the call triggers the API call current limiting rule of the microservice;

[0057] If so, determine whether to allow the microservice to call the API based on the changed API call current limiting rule.

[0058] Furthermore, before the step of determining whether the API call current limiting rule of the microservice has changed according to the current limiting rule database, the method further includes:

[0059] The real-time calculation module obtains real-time API call information, dynamically adjusts the optimal flow limit of the API according to the real-time API call information, and updates the API call flow limit rules of each microservice in the flow limit rule database according to the adjusted optimal flow limit.

[0060] Further, the step of determining the optimal flow limit of the API according to the API call information includes:

[0061] The optimal flow limit of the API is determined based on the API call information, system capacity and business requirements.

[0062] Furthermore, the step of obtaining API call information according to the API call log includes:

[0063] The API call log is sent to a log collection module, and the log collection module extracts the API call information from the API call log.

[0064] Furthermore, after the step of extracting the API call information from the API call log, the log collection module further includes:

[0065] The log collection module uses the kafka message middleware to send the API call information to the log message module;

[0066] The log message module sends the API call information to the real-time calculation module in real time.

[0067] The specific implementation of the API calling intelligent current limiting device of the present invention is basically the same as the embodiments of the following API calling intelligent current limiting method, and will not be repeated here.

[0068] The present invention also provides an API calling intelligent current limiting method based on the above API calling intelligent current limiting device.

[0069] Reference Figure 2 , Figure 2This is a flow chart of the first embodiment of the API calling intelligent current limiting method of the present invention.

[0070] An embodiment of the present invention provides an embodiment of an API call intelligent current limiting method. It should be noted that although the logical order is shown in the flow chart, in some cases, the steps shown or described may be executed in an order different from that shown here.

[0071] In various embodiments of the API call intelligent current limiting method, the execution subject is the API call intelligent current limiting device.

[0072] The API call intelligent current limiting method is applied to an API call intelligent current limiting device, and the API call intelligent current limiting method includes:

[0073] Step S10, obtaining an API call log generated when the microservice calls the API, and obtaining API call information according to the API call log;

[0074] In modern computer systems and network architectures, especially with the widespread use of cloud computing and microservice architectures, the frequency and number of API (application programming interface) calls are becoming increasingly high. The high frequency of API calls brings huge load pressure to the system. If not controlled, it may cause a significant decline in system performance or even cause the system to crash. Therefore, current limiting technology has become an important means to ensure system stability.

[0075] Traditional rate limiting technologies are mainly based on static rules, such as fixed rate limiting or rate limiting within a fixed time window (such as the token bucket algorithm). Although these methods can effectively limit the number of requests and prevent system overload to a certain extent, they lack flexibility and intelligence and cannot be dynamically adjusted according to real-time business needs and system load conditions. For example, when business peaks, static rate limiting rules may be too strict, resulting in normal requests being rejected, thus affecting user experience; while during business troughs, static rate limiting rules may appear too loose and fail to fully utilize system resources.

[0076] At present, there are some research and application practices that try to introduce real-time computing frameworks (such as Apache Flink, Apache Spark) and message middleware (such as Kafka) into current limiting technology, and realize dynamic adjustment and intelligent management of current limiting rules through real-time data processing and streaming computing. Although these technologies have improved the flexibility and intelligence of current limiting strategies to a certain extent, they still face many challenges in specific implementation, such as the real-time nature of data processing, the accuracy of current limiting rules, and the scalability of the system.

[0077] In this embodiment, each microservice generates a log record containing key information when calling the API. These log records usually include the following:

[0078] API Name: Indicates the specific API being called.

[0079] Microservice name: indicates the microservice instance that calls the API.

[0080] Call time: The timestamp of recording the API call.

[0081] Response Time: Records the time it takes for the API to respond.

[0082] Status code: indicates the result status of the API call (such as 200 for success and 500 for server error).

[0083] For example, a log record might look like this:

[0084] 2024-08-01 12:00:00,Microservice01,API-01,200,150ms.

[0085] 2024-08-01 12:00:02,Microservice 02,API-01,500,300ms.

[0086] The log collection module can be used to collect the generated logs from each microservice instance. You can use log collection tools such as Flume or Logstash to centrally transfer log data to a message middleware such as Kafka. Using Kafka as a message middleware, the collected API call log data can be efficiently transmitted and distributed. Each log record is sent as a Kafka message to a specified Kafka topic.

[0087] In the log message module, consume API call logs from Kafka, parse each log record, and extract API call information. You can use a real-time computing framework (such as Apache Flink) for data stream processing.

[0088] The extracted API call information is stored in a database or used in a real-time computing module for further analysis and dynamic adjustment of the rate limiting rules. The real-time computing module can determine the optimal rate limiting of the API based on this information, calculate the API call rate limiting rules for each microservice, and store the results in the rate limiting rules database.

[0089] Example description:

[0090] Log generation and collection: Each microservice automatically generates a log file when calling an API. The log file is stored in the specified log directory. For example, the log record generated by microservice '01' when calling API 'API-01' is as follows:

[0091] 2024-08-01 12:00:00,Microservice01,API-01,200,150ms.

[0092] The log collection module (such as Flume) will scan the directory regularly, collect the newly generated log files, and send them to the Kafka message middleware. Kafka will store these log messages in the topic api_logs for subsequent consumption.

[0093] Log parsing and extraction: The module that consumes log messages from Kafka reads each message in the topic 'api_logs' and parses out the specific information of the API call, such as call time, microservice name, API name, status code, and response time. This information will be used by the real-time calculation module to dynamically calculate and adjust the current limiting rules.

[0094] Utilization of API call information: The extracted API call information will be stored in the database and used by the real-time computing module. For example, during peak hours, when the API call frequency reaches the preset current limiting threshold, the real-time computing module will dynamically adjust the current limiting rules to ensure the stability and response speed of the system.

[0095] Through the above implementation, the system can effectively obtain and process the log information generated when the microservice calls the API, thereby providing reliable data support for dynamically adjusting the API call current limiting rules. This method not only improves the stability of the system, but also can make intelligent adjustments according to actual business needs to improve user experience.

[0096] Step S20, determining a real-time computing module, and using the real-time computing module and the API call information to determine an API call current limiting rule for each microservice;

[0097] In this embodiment, the real-time computing module is a system component for processing and analyzing real-time data. In the present invention, the real-time computing module receives and processes information in the API call log, dynamically calculates and determines the API call current limiting rules for each microservice.

[0098] The API call information received from the log message module includes: API name; microservice name; call time; response time; status code.

[0099] The real-time computing module processes and analyzes the API call information: cleans, parses, and formats the received log data to ensure data integrity and consistency; and predicts API call trends over a period of time. This can be achieved through time series analysis or machine learning algorithms. The current system load is evaluated based on the API call frequency and response time. For example, a high frequency of API calls and a long response time may indicate that the system is under high load.

[0100] Based on the processed and analyzed API call information, the real-time computing module calculates the optimal flow limit for each API. This process includes the following steps: Determine the initial flow limit: Set an initial flow limit based on system capacity and business needs; Dynamic adjustment: The real-time computing module dynamically adjusts the flow limit based on the current system load and API call trends. For example, increase the flow limit during peak hours and reduce the flow limit during off-peak hours.

[0101] Then, calculate the API call flow limiting rules for each microservice: The calculation module uses the optimal flow limit, the total number of microservices and the weight of each microservice to calculate the API call flow limiting rules for each microservice. The specific steps may include:

[0102] Get the total number of microservices: Get the total number of microservice instances running in the current system through service registration and discovery mechanisms (such as Eureka and Consul).

[0103] Evaluate microservice weights: Set the weight of each microservice instance based on its resource configuration (such as CPU, memory, etc.) and performance. Microservice weight is generally a relative value used to represent the processing power of each microservice instance in distributed systems and microservice architectures. Weights are usually set based on the resource configuration (such as CPU, memory, etc.) and performance of each microservice instance. The purpose of setting weights is to enable each microservice instance to share the workload fairly according to its processing power in scenarios such as load balancing, current limiting, and resource allocation. Weight setting method: Determine the weight value of each microservice instance by monitoring and evaluating its resource usage and performance. The weight value is usually a decimal between 0 and 1, indicating the relative processing power of the instance in the entire system.

[0104] For example, if there are three microservice instances in a system, each of which is allocated different resources and exhibits different performance, the weights can be set as follows:

[0105] Microservice 01: Weight = 0.5

[0106] Microservice 02: Weight = 0.3

[0107] Microservice 03: Weight = 0.2

[0108] Calculate the flow limit rules: Use the formula (optimal flow limit / total number of microservices)*microservice weight to calculate the flow limit for each microservice.

[0109] Example description:

[0110] Determine the real-time computing module: Assume that Apache Flink is used as the real-time computing framework. Flink can efficiently process streaming data and is suitable for large-scale real-time data analysis.

[0111] Get API call information: Consume API call log messages from the Kafka topic api_logs and extract API call information, for example: 2024-08-01 12:00:00, microservice 01, API-01, 200, 150ms.

[0112] Processing and analyzing API call information: The real-time computing module parses and analyzes these logs. For example, by analyzing the API call frequency and response time in the last hour, the current load of the system can be evaluated.

[0113] Determine the optimal traffic limit: Determine the optimal traffic limit for API-01 based on the current system load and historical call data. For example, set the traffic limit to 1000 requests / second during peak hours and 500 requests / second during off-peak hours.

[0114] Calculate the API call flow control rules for each microservice: Assume that there are four microservice instances in the system, namely microservice 01, microservice 02, microservice 03 and microservice 04, and their weights are 0.3, 0.2, 0.3 and 0.2 respectively. The optimal flow control is 1000 requests / second.

[0115] The flow rate limit of microservice 01 = (1000 / 4)*0.3 = 75 requests / second;

[0116] The flow limit of microservice 02 = (1000 / 4)*0.2 = 50 requests / second;

[0117] The flow limit of microservice 03 = (1000 / 4)*0.3 = 75 requests / second;

[0118] The flow limit of microservice 04 = (1000 / 4)*0.2 = 50 requests / second.

[0119] Step S30: When a microservice calls the API, it is determined whether the call triggers the API call current limiting rule of the microservice. If not, the microservice is allowed to call the API.

[0120] In this embodiment, when a microservice instance attempts to call an API, the system needs to determine whether the call will trigger the preset API call limit rules. If the limit rules are not triggered, the system will allow the microservice instance to continue calling the API; if the limit rules are triggered, the system will reject the call or take other restrictive measures. The specific steps may include:

[0121] Get the current rate limiting rules: Get the rate limiting rules of the current API, which include the maximum request rate and frequency limit of each microservice instance. For example, for API API-01, the rate limiting rules may stipulate that the rate limit of microservice 01 is 800 requests / second and the rate limit of microservice 02 is 400 requests / second.

[0122] Monitoring API calls: The system monitors the API calls of each microservice instance in real time, including call frequency, response time, status code, etc. With this data, the system can evaluate the current call status of each microservice instance.

[0123] Determine whether the current limiting rule is triggered: The system compares the current API call situation with the current limiting rule to determine whether the current limiting rule is triggered. For example, if the call frequency of microservice 01 exceeds 800 requests / second within a certain time window, it is considered that the current limiting rule is triggered.

[0124] Processing API calls: If the result is that the current limiting rules are not triggered, the system allows the microservice instance to continue calling the API. If the result is that the current limiting rules are triggered, the system can take the following measures: Reject the API call and return the corresponding error message (such as HTTP 429 Too Many Requests). Record logs for subsequent analysis. Dynamically adjust the current limiting rules to deal with sudden traffic.

[0125] Example description:

[0126] Assume that there are two microservice instances in the system: Microservice 01 and Microservice 02. The current limiting rules for calling API 'API-01' are as follows:

[0127] Microservice 01 traffic limit: 800 requests / second

[0128] Microservice 02’s traffic limit: 400 requests / second

[0129] At a certain point in time, the system reads the above current limiting rules from the current limiting rule database and starts monitoring the API calls of the two microservice instances.

[0130] Monitoring the API calls of microservice 01: The system finds that microservice 01 has sent 750 requests in the past second. Compare the current number of requests with the current limiting rule: 750 < 800, the current limiting rule is not triggered. The system allows microservice 01 to continue calling the API.

[0131] Monitoring the API call of microservice 02: The system finds that microservice 02 has sent 450 requests in the past second. Compare the current number of requests with the current limiting rule: 450>400, triggering the current limiting rule. The system rejects the call of microservice 02 and returns an HTTP 429 error.

[0132] Through the above steps, the system can effectively monitor and manage the API calls of each microservice instance, ensure the reasonable allocation of system resources under high load conditions, and improve system stability and user experience.

[0133] The present invention relates to an intelligent current limiting method for API calls, which aims to solve the problem that the existing technology cannot dynamically adjust API current limiting rules to cope with real-time business needs. The present invention obtains the API call logs generated when the microservice calls the API, and obtains the API call information based on these logs; at the same time, a real-time calculation module is determined, and the module and the API call information are used to dynamically determine the API call current limiting rules for each microservice; when a microservice calls the API, it is determined whether the call triggers the current limiting rules of the microservice, and if not, the microservice is allowed to call the API. By dynamically adjusting the current limiting rules, the present invention can effectively cope with traffic fluctuations during business peaks and avoid system overloads. At the same time, it makes full use of system resources during business troughs to improve the stability and intelligence level of the system.

[0134] Furthermore, a second embodiment of the API call intelligent current limiting method of the present invention is proposed. In the above step S20, the step of using the real-time computing module and the API call information to determine the API call current limiting rules for each microservice includes:

[0135] Step a1, determining the optimal flow limit of the API according to the API call information, and obtaining the total number of microservices and the weight of each microservice;

[0136] Step a2, using the real-time calculation module to calculate the API call flow limiting rules for each microservice according to the optimal flow limiting, the total number of microservices and the weight of each microservice;

[0137] Step a3: Store the API call current limiting rules of each microservice in the current limiting rules database.

[0138] In this embodiment, the real-time computing module and API call information are used to determine the API call limiting rules for each microservice, including determining the optimal limiting flow of the API, obtaining the total number of microservices and the weight of each microservice, calculating the API call limiting rules for each microservice, and storing the limiting rules.

[0139] Among them, the optimal flow limit refers to the optimal call rate of a certain API under the current system resources and business needs to ensure the stability and performance of the system; the total number of microservices refers to the number of microservice instances running in the current system; the microservice weight refers to the relative processing power of each microservice instance, which is set according to resource configuration and performance.

[0140] The specific steps to determine the optimal flow limit can be as follows:

[0141] Analyze API call information: By analyzing API call information, you can understand the performance of the API in different time periods and find the system's carrying capacity, which can include: Peak period analysis: determine the peak period of API calls, and analyze the call frequency, response time, and error rate during the peak period; Trough period analysis: determine the trough period of API calls, and analyze the call frequency, response time, and error rate during the trough period; Trend analysis: analyze the long-term trend of API calls, including seasonal changes and business growth trends.

[0142] Calculate the optimal flow rate limit: Combine the analysis results of the API call information to calculate the optimal flow rate limit of the API. The specific steps can be as follows: Based on the analyzed API call information, determine the maximum carrying capacity of the system under different load conditions. Determine the business demand coefficient based on the key performance indicators of the API (such as response time, error rate, etc.). Consider burst traffic and system fault tolerance, and set a safety factor. Use the following formula to calculate the optimal flow rate limit: Optimal flow rate limit = (maximum carrying capacity × business demand coefficient) / safety factor.

[0143] Example description:

[0144] Analyze API call information: Through data analysis, it is found that the call frequency of API-01 reaches 2000 requests / second during the peak period of each day and 100 requests / second during the trough period. During the peak period, the average response time of the API is 300ms and the error rate is 2%; during the trough period, the response time is 150ms and the error rate is 0.5%.

[0145] Calculate the optimal flow rate limit: According to the analysis of API call information, the maximum carrying capacity of the system during peak hours is 2000 requests / second. According to business needs, it is set to 0.8 (reserving 20% ​​of the capacity). According to system fault tolerance requirements, it is set to 1.2. Optimal flow rate limit = (2000 × 0.8) / 1.2 ≈ 1333 requests / second.

[0146] Then, the API call flow limiting rules for each microservice are calculated based on the optimal flow limiting of the API. The specific steps may include:

[0147] Get the total number of microservices and the weight of each microservice: The system obtains the total number of currently running microservice instances through service registration and discovery mechanisms (such as Eureka, Consul). Set the weight of each microservice according to its resource configuration (such as CPU, memory, etc.) and performance. For example, the total number of microservice instances running in the current system is 4, namely 'Microservice 01', 'Microservice 02', 'Microservice 03' and 'Microservice 04'. The weights of these microservices are 0.4, 0.2, 0.3 and 0.1, respectively, indicating the processing capacity of each microservice relative to the overall system.

[0148] Calculate the API call limit rules for each microservice: Calculate the API call limit for each microservice based on the optimal limit, the total number of microservices, and the weight of each microservice. The limit for each microservice = (optimal limit / total number of microservices)*microservice weight.

[0149] Example description:

[0150] For API 'API-01', the optimal rate limit is 1000 requests / second. The rate limit rules for the microservice instance are calculated as follows:

[0151] The flow rate limit of microservice 01 = (1000 / 4)*0.4 = 100 requests / second;

[0152] The flow limit of microservice 02 = (1000 / 4)*0.2 = 50 requests / second;

[0153] The flow limit of microservice 03 = (1000 / 4)*0.3 = 75 requests / second;

[0154] The flow limit of microservice 04 = (1000 / 4)*0.1 = 25 requests / second.

[0155] Through the above steps, this embodiment can use the real-time computing module and API call information to dynamically determine the API call current limiting rules for each microservice. This not only improves the stability of the system, but also can make intelligent adjustments according to actual business needs, optimize resource utilization, and improve user experience.

[0156] Furthermore, a third embodiment of the API call intelligent current limiting method of the present invention is proposed. In the above step S30, before the step of determining whether the call triggers the API call current limiting rule of the microservice, it also includes:

[0157] Step b1, judging whether the API call current limiting rule of the microservice has changed according to the current limiting rule database;

[0158] Step b2: If not, execute the following steps: determine whether the call triggers the API call current limiting rule of the microservice;

[0159] Step b3: If yes, determine whether to allow the microservice to call the API based on the changed API call current limiting rules.

[0160] In this embodiment, before determining whether an API call triggers the API call current limiting rules of a microservice, the system first needs to check whether the current limiting rules of the microservice have changed. If the current limiting rules have not changed, it is directly determined whether the current limiting rules are triggered; if the current limiting rules have changed, it is necessary to determine based on the latest current limiting rules. The specific steps may include:

[0161] Check whether the current limiting rules have changed: The system reads the API call current limiting rules of the current microservice from the current limiting rules database. Compare the current current limiting rules with the current limiting rules in the cache to determine whether there have been changes. For example, the system reads the current limiting rules of API-01 of microservice 01 and finds that the current limit is set to 100 requests / second. The system compares the current limiting rule with the previously cached current limiting rule (80 requests / second) and finds that the current limit has changed.

[0162] Determine whether the current limiting rule is triggered: If the current limiting rule has not changed, the system will directly determine whether the current API call triggers the current limiting rule. If the current limiting rule has changed, the system will first update the current limiting rule, and then determine whether the current limiting rule is triggered. For example, if the current limiting rule has not changed: the system monitors the number of API API-01 calls of microservice 01 in the past 1 second, which is recorded as 75 times. The current limiting rule is 100 requests / second. 75 calls did not trigger the current limiting rule, and continued calls are allowed. If the current limiting rule has changed: the system updates the current limiting rule of microservice 01 to 100 requests / second. The system monitors the number of API API-01 calls of microservice 01 in the past 1 second, which is recorded as 90 times. The updated current limiting rule is 100 requests / second. 90 calls did not trigger the current limiting rule, and continued calls are allowed.

[0163] Update current limiting rules: If a change in the current limiting rules is detected, the system will update the current limiting rules in the cache to ensure the accuracy of subsequent judgments. After the current limiting rules are updated, the system will use the new current limiting rules for judgment. For example, the system reads the current limiting rule database and finds that the current limiting rule of API API-01 of microservice 01 is updated to 100 requests / second. The system updates the current limiting rules in the cache to the latest value, that is, 100 requests / second. Subsequent API call judgments will be based on the latest current limiting rules.

[0164] Example description:

[0165] Assume that there are two microservice instances in the system: Microservice 01 and Microservice 02. The current limiting rules for them to call API API-01 are as follows:

[0166] Microservice 01 flow limit: 80 requests / second (previously cached flow limit rules)

[0167] Microservice 02 flow limit: 50 requests / second

[0168] Step 1: Check whether the current limiting rules have changed:

[0169] The system reads the current flow limiting rules of microservice 01 from the flow limiting rules database and finds that the flow limit has been updated to 100 requests / second.

[0170] The system compares the new rule with the cached throttling rules to determine if a change has occurred.

[0171] Step 2: Determine whether the current limiting rule is triggered:

[0172] Update the current limit rule to 100 requests / second.

[0173] The system monitors the number of API API-01 calls made by microservice 01 in the past second, which is recorded as 90 times.

[0174] According to the updated rate limiting rule (100 requests / second), 90 calls did not trigger the rate limiting rule, and continued calls were allowed.

[0175] Step 3: Update the current limiting rules:

[0176] The system updates the current limiting rules in the cache to the latest value of 100 requests / second to ensure that the latest rules are used in subsequent judgments.

[0177] Through the above steps, this embodiment can effectively determine whether the API call triggers the current limiting rule and ensure the real-time update of the current limiting rule. This method not only improves the stability and accuracy of the system, but also adapts to the changes in real-time business needs and provides intelligent current limiting management.

[0178] Furthermore, a fourth embodiment of the API call intelligent current limiting method of the present invention is proposed, and before the above step b1, it also includes:

[0179] Step c1, the real-time calculation module obtains real-time API call information, dynamically adjusts the optimal flow limit of the API according to the real-time API call information, and updates the API call flow limit rules of each microservice in the flow limit rule database according to the adjusted optimal flow limit.

[0180] In this embodiment, before determining whether a certain API call triggers a flow-limiting rule, the system needs to first obtain real-time API call information through the real-time calculation module, dynamically adjust the optimal flow-limiting rule of the API, and store the updated flow-limiting rule in the flow-limiting rule database. This process ensures that the system dynamically optimizes the flow-limiting rule according to real-time business needs and system load conditions. Specific steps may include:

[0181] Get real-time API call information: The real-time computing module obtains the latest API call information from the log system or message middleware. This information includes API call frequency, response time, error rate, etc. Through real-time monitoring, the system can keep track of the actual situation of the current API call at any time.

[0182] Dynamically adjust the optimal API traffic limit: Based on the real-time API call information, the real-time calculation module analyzes the current system load and business needs, and dynamically adjusts the optimal API traffic limit. Combined with historical data and current trends, a new optimal traffic limit is determined to ensure that the system can still run stably under high load.

[0183] Update the current limiting rule database: store the adjusted optimal current limiting rate and the corresponding current limiting rules in the current limiting rule database to ensure that the latest current limiting rules can be used for subsequent API call judgments and current limiting operations.

[0184] Determine whether the current limiting rules have changed: Read the API call current limiting rules of the current microservice from the current limiting rules database, compare them with the current limiting rules in the cache, and determine whether they have changed. If the current limiting rules have not changed, continue to use the existing rules; if the current limiting rules have changed, update the current limiting rules in the cache

[0185] Determine whether the current limiting rules are triggered: According to the latest current limiting rules, determine whether the current API call triggers the current limiting. If the current limiting rules are not triggered, the call is allowed to continue; if the current limiting rules are triggered, the call is rejected or other restrictive measures are taken.

[0186] Example description:

[0187] Assume that there are two microservice instances in the system: Microservice 01 and Microservice 02. The current limiting rules for calling API 'API-01' are as follows:

[0188] Microservice 01’s traffic limit: 100 requests / second (previously cached traffic limit rules)

[0189] Microservice 02 flow limit: 50 requests / second

[0190] Step 1: Get real-time API call information:

[0191] The system consumes the log data of API 'API-01' from the Kafka topic 'api_logs' and obtains information such as the number of calls, average response time, and error rate in the past minute.

[0192] Step 2: Dynamically adjust the optimal API flow limit:

[0193] By analyzing the API 'API-01' call information in the past minute, the real-time calculation module adjusts the optimal flow rate limit from 1000 requests / second to 1200 requests / second.

[0194] Step 3: Update the current limiting rules database:

[0195] The system updates the adjusted optimal flow rate limit of API 'API-01' (1200 requests / second) to the flow rate limit rule database.

[0196] Step 4: Determine whether the current limiting rules have changed:

[0197] The system reads the current rate limiting rule of API 'API-01' of microservice 01 and finds that the rate limiting rule has been updated from 100 requests / second to 120 requests / second. By comparing the cached rate limiting rule (100 requests / second), it is determined that the rule has changed.

[0198] Step 5: Determine whether the current limiting rule is triggered:

[0199] The system monitors the number of API 'API-01' calls made by microservice 01 in the past second, which is recorded as 110. According to the updated current limiting rule (120 requests / second), 110 calls did not trigger the current limiting rule and continued calls were allowed.

[0200] Through the above steps, this embodiment can effectively obtain real-time API call information, dynamically adjust the optimal API flow limit, and timely update the flow limit rule database. This process ensures the real-time and accuracy of the flow limit rules, improves the stability and performance of the system, and adapts to the ever-changing business needs.

[0201] Furthermore, a fifth embodiment of the API call intelligent flow limiting method of the present invention is proposed. In the above step a1, the step of determining the optimal flow limiting of the API according to the API call information includes:

[0202] Step d1, determining the optimal flow limit of the API based on the API call information, system capacity and business requirements.

[0203] In this embodiment, the optimal flow rate refers to the optimal call rate that a certain API can stably process under the current system resources and business requirements. This rate can ensure that the system can still operate normally under high load conditions, while improving resource utilization and user experience. The step of determining the optimal flow rate includes calculating the optimal flow rate using API call information, system capacity and business requirements. The specific steps may include:

[0204] Collect API call information: Collecting API call information is the first step in determining the optimal flow control. The following are the detailed steps for collecting API call information: Call frequency: Record the number of API calls in each time period (such as per second, per minute). Response time: Record the response time of each API call, including the average response time and percentile response time (such as 95%, 99% response time). Error rate: Record the error rate of API calls, including different types of errors (such as 4xx, 5xx errors). Business data: Collect key indicators (KPIs) related to the business, such as user activity, transaction volume, etc.

[0205] Analyze API call information: By analyzing API call information, you can understand the performance of the API in different time periods and find the system's carrying capacity. The specific analysis steps are as follows: Peak period analysis: Determine the peak period of API calls, and analyze the call frequency, response time, and error rate during the peak period. Valley period analysis: Determine the valley period of API calls, and analyze the call frequency, response time, and error rate during the valley period. Trend analysis: Analyze the long-term trend of API calls, including seasonal changes and business growth trends.

[0206] Evaluate system capacity: Evaluating system capacity is a key step in determining the optimal flow rate. System capacity includes the usage of hardware resources (such as CPU, memory, network bandwidth, etc.) and software resources (such as thread pool, connection pool, etc.). The specific steps are as follows: Hardware resource evaluation: Use stress testing and monitoring tools to evaluate the system's hardware resource usage under different load conditions. Software resource evaluation: By analyzing the usage of software resources, determine the maximum number of requests that the system can handle without affecting other business functions.

[0207] Combine business needs: Combine business needs and service level agreements (SLAs) to determine the performance indicators that the API needs to achieve. The specific steps are as follows: Performance indicators: Determine the key performance indicators (KPIs) of the API, such as maximum response time, minimum availability, etc. Business growth: Consider factors such as business growth and seasonal fluctuations, and reserve a certain amount of capacity to cope with sudden traffic.

[0208] Calculate the optimal flow rate limit: Combine API call information, system capacity assessment results, and business needs to calculate the optimal flow rate limit for the API. The specific steps are as follows: Determine the maximum carrying capacity: Based on the analyzed API call information, determine the maximum carrying capacity of the system under different load conditions. Determine the business demand coefficient: Determine the business demand coefficient based on the key performance indicators of the API (such as response time, error rate, etc.). Determine the safety factor: Consider burst traffic and system fault tolerance and set the safety factor. Use the following formula to calculate the optimal flow rate limit:

[0209] Optimal flow limit = (maximum carrying capacity × business demand factor) / safety factor

[0210] Example description:

[0211] Collect API call information: Collect API 'API-01' call data in the past month from the log system, including call frequency, response time, and error rate.

[0212] Analyze API call information: Through data analysis, it is found that the call frequency of API 'API-01' reaches 2000 requests / second during the peak period of each day and 100 requests / second during the trough period. During the peak period, the average response time of the API is 300ms and the error rate is 2%; during the trough period, the response time is 150ms and the error rate is 0.5%.

[0213] Evaluate system capacity: The current system configuration is 8-core CPU, 16GB memory, and 1Gbps network bandwidth. Through stress testing, it is determined that the system can carry a maximum of 2500 requests / second without affecting other services.

[0214] Combined with business requirements: Business requirements require that the response time of API 'API-01' should not exceed 200ms and the error rate should not exceed 1%. Considering the business growth trend and the possibility of sudden traffic, 20% of the capacity is reserved.

[0215] Calculate the optimal flow limit:

[0216] Optimal flow limit = (system maximum carrying capacity × business demand coefficient) / safety factor

[0217] The maximum carrying capacity of the system is 2500 requests / second, the business demand coefficient is 0.8 (reserving 20% ​​of the capacity), and the safety factor is 1.2. Optimal flow limit = (2500×0.8) / 1.2≈1667 requests / second

[0218] Through the above steps, this embodiment can effectively obtain real-time API call information, dynamically adjust the optimal API flow limit, and timely update the flow limit rule database. This process ensures the real-time and accuracy of the flow limit rules, improves the stability and performance of the system, and adapts to the ever-changing business needs.

[0219] Furthermore, a sixth embodiment of the API call intelligent current limiting method of the present invention is proposed. In the above step S10, the step of obtaining API call information according to the API call log includes:

[0220] Step e1, sending the API call log to a log collection module, and the log collection module extracts the API call information from the API call log.

[0221] In this embodiment, the specific steps may include:

[0222] Generate API call logs: Each microservice generates log records containing key information when calling the API. These log records usually include the following:

[0223] API Name: Indicates the specific API being called.

[0224] Microservice name: indicates the microservice instance that calls the API.

[0225] Call time: The timestamp of recording the API call.

[0226] Response Time: Records the time it takes for the API to respond.

[0227] Status code: indicates the result status of the API call (such as 200 for success and 500 for server error)

[0228] Log collection: The log collection module is responsible for collecting the generated logs from each microservice instance. This can be done using log collection tools such as Flume or Logstash. The log collection module periodically scans the log file directory and collects new log files when they are found.

[0229] Log transmission: Use message middleware (such as Kafka) to efficiently transmit and distribute the collected log data. Each log record will be sent as a Kafka message to the specified Kafka topic.

[0230] Log parsing: The log parsing module consumes API call logs from Kafka, parses each log record, and extracts API call information. The parsing process includes splitting the log string into different fields and extracting information such as API name, microservice name, call time, response time, and status code.

[0231] Extract API call information: Store the extracted API call information in a database or real-time computing module for further analysis and dynamic adjustment of flow control rules. The real-time computing module uses this API call information to calculate the optimal flow control and flow control rules.

[0232] Example description:

[0233] Assume that there are two microservice instances in the system: Microservice 01 and Microservice 02. The log records of their calls to API 'API-01' are as follows:

[0234] 2024-08-01 12:00:00,Microservice 01,API-01,200,150ms;

[0235] 2024-08-01 12:00:02,Microservice 02,API-01,500,300ms.

[0236] Step 1: Generate API call log: Microservice 01 generates a log record when calling API API-01, which contains information such as API name, microservice name, call time, response time, and status code.

[0237] Step 2: Log collection: The log collection module (such as Flume) regularly scans the log file directory and collects the newly generated log files.

[0238] Step 3: Log transmission: Use Kafka to send the collected log data to the Kafka topic api_logs.

[0239] Step 4: Log parsing: The log parsing module reads log messages from the Kafka topic api_logs, parses them into a structured data format, and extracts API call information.

[0240] Step 5: Extract API call information: The extracted API call information is stored in the real-time computing module for further analysis and dynamic adjustment of current limiting rules.

[0241] Through the above steps, this embodiment can effectively send the API call log to the log collection module to extract the API call information. This process ensures that the system can accurately obtain and parse the detailed information of the API call, providing reliable data support for the subsequent calculation and dynamic adjustment of the current limiting rules.

[0242] Furthermore, a seventh embodiment of the API call intelligent current limiting method of the present invention is proposed, which includes, after the above step e1, the following steps:

[0243] Step f1, the log collection module uses the Kafka message middleware to send the API call information to the log message module;

[0244] Step f2, the log message module sends the API call information to the real-time calculation module in real time.

[0245] In this embodiment, an important step is to extract API call information from the API call log and send this information to the log message module through the Kafka message middleware, and finally send it to the real-time computing module in real time by the log message module. This process ensures the efficient transmission and processing of log information, enabling the system to analyze and adjust API call current limiting rules in real time. Specific steps may include:

[0246] Use Kafka to transmit log information: The log collection module uses Kafka message middleware to send the extracted API call information to the specified topic of Kafka (such as api_logs). As a high-throughput distributed messaging system, Kafka can efficiently transmit and process large amounts of log data.

[0247] Example description:

[0248] Send the extracted API call information as a message to the Kafka topic:

[0249] Timestamp: 2024-08-01 12:00:00

[0250] Microservices: Microservices 01

[0251] API Name: API-01

[0252] Status code: 200

[0253] Response time: 150ms.

[0254] Log message module processing: The log message module consumes API call information from Kafka to ensure the real-time and integrity of the information. This module can perform preliminary data processing and filtering, and send the processed data to the real-time computing module in real time.

[0255] Example description: The log message module reads messages from the Kafka topic api_logs and forwards them to the real-time computing module:

[0256] Timestamp: 2024-08-01 12:00:00

[0257] Microservices: Microservices 01

[0258] API Name: API-01

[0259] Status code: 200

[0260] Response time: 150ms.

[0261] Through the above steps, this embodiment can effectively send API call logs to the log collection module, parse and extract API call information, and efficiently transmit it to the log message module through the Kafka message middleware, and finally process and adjust the current limiting rules by the real-time computing module. This process ensures the real-time transmission and processing of log information, and improves the stability and performance of the system.

[0262] The present invention also provides an API calling intelligent current limiting device.

[0263] Reference Figure 3 , Figure 3 This is a functional module diagram of the first embodiment of the API call intelligent current limiting device of the present invention. The API call intelligent current limiting device includes:

[0264] A real-time acquisition module obtains the API call log generated when the microservice calls the API, and obtains the API call information according to the API call log;

[0265] A real-time computing module is used to determine a real-time computing module, and to determine an API call current limiting rule for each microservice by using the real-time computing module and the API call information;

[0266] The current limiting module is called. When a microservice calls the API, it is determined whether the call triggers the API call current limiting rule of the microservice. If not, the microservice is allowed to call the API.

[0267] In addition, an embodiment of the present invention further provides a storage medium.

[0268] An API call intelligent current limiting program is stored on the storage medium. When the API call intelligent current limiting program is executed by the processor, the steps of the API call intelligent current limiting method as described above are implemented.

[0269] The specific implementation of the storage medium of the present invention is basically the same as the embodiments of the above-mentioned API call intelligent current limiting method, and will not be repeated here.

[0270] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims. All equivalent structures or equivalent process changes made using the contents of the specification and drawings of the present invention, or directly or indirectly used in other related technical fields, are protected by the present invention.

[0271] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0272] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk.

[0273] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0274] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. An API call intelligent current limiting method, It is characterized in that The API call intelligent current limiting method includes the following steps: Obtain the API call log generated when the microservice calls the API, and obtain the API call information according to the API call log; Determine a real-time computing module, and use the real-time computing module and the API call information to determine an API call current limiting rule for each microservice; When a microservice calls the API, it is determined whether the call triggers the API call current limiting rule of the microservice. If not, the microservice is allowed to call the API.

2. The API call intelligent current limiting method according to claim 1, It is characterized in that The step of using the real-time computing module and the API call information to determine the API call current limiting rule for each microservice includes: Determine the optimal flow limit of the API according to the API call information, and obtain the total number of microservices and the weight of each microservice; Utilize the real-time calculation module to calculate the API call flow limiting rule for each microservice according to the optimal flow limiting, the total number of microservices, and the weight of each microservice; The API call current limiting rules of each microservice are stored in the current limiting rules database.

3. The API call intelligent current limiting method as claimed in claim 2, It is characterized in that Before the step of determining whether the call triggers the API call current limiting rule of the microservice, the method further includes: Determine whether the API call current limiting rule of the microservice has changed according to the current limiting rule database; If not, execute the following steps: determine whether the call triggers the API call current limiting rule of the microservice; If so, determine whether to allow the microservice to call the API based on the changed API call current limiting rule.

4. The API call intelligent current limiting method as claimed in claim 3, It is characterized in that Before the step of determining whether the API call current limiting rule of the microservice has changed according to the current limiting rule database, the method further includes: The real-time calculation module obtains real-time API call information, dynamically adjusts the optimal flow limit of the API according to the real-time API call information, and updates the API call flow limit rules of each microservice in the flow limit rule database according to the adjusted optimal flow limit.

5. The API call intelligent current limiting method as described in claim 2, It is characterized in that The step of determining the optimal flow limit of the API according to the API call information comprises: The optimal flow limit of the API is determined based on the API call information, system capacity and business requirements.

6. The API call intelligent current limiting method according to claim 1, It is characterized in that The step of obtaining API call information according to the API call log includes: The API call log is sent to a log collection module, and the log collection module extracts the API call information from the API call log.

7. The API call intelligent current limiting method according to claim 6, It is characterized in that After the step of extracting the API call information from the API call log by the log collection module, the method further includes: The log collection module uses the kafka message middleware to send the API call information to the log message module; The log message module sends the API call information to the real-time calculation module in real time.

8. An API calls intelligent current limiting device, It is characterized in that The API calls the intelligent current limiting device including: A real-time acquisition module obtains the API call log generated when the microservice calls the API, and obtains the API call information according to the API call log; A real-time computing module is used to determine a real-time computing module, and to determine an API call current limiting rule for each microservice by using the real-time computing module and the API call information; The current limiting module is called. When a microservice calls the API, it is determined whether the call triggers the API call current limiting rule of the microservice. If not, the microservice is allowed to call the API.

9. An API calls intelligent current limiting device, It is characterized in that The API call intelligent current limiting device includes a memory, a processor, and an API call intelligent current limiting program stored in the memory and executable on the processor. When the API call intelligent current limiting program is executed by the processor, the steps of the API call intelligent current limiting method as described in any one of claims 1 to 7 are implemented.

10. A storage medium, It is characterized in that The storage medium stores an API call intelligent current limiting program, and when the API call intelligent current limiting program is executed by the processor, the steps of the API call intelligent current limiting method as described in any one of claims 1-7 are implemented.