Current limiting method and device, electronic equipment and storage medium

Through precise comparison and current limit suppression technology, the error limit problem in existing current limiting technology is solved, the business side damage is reduced, and the user experience and the stability of the database system are improved.

CN118940052APending Publication Date: 2024-11-12XINGIN INFORMATION TECH (SHANGHAI) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411063775.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

The existing current limiting technology has error limits, resulting in hard damage to the business side and reduced user experience, and the inability to accurately match the request statements, resulting in unnecessary current limits.

Method used

By obtaining the request statement in the current period and the preset current limit statement for accurate comparison, the remaining throughput is determined based on the preset throughput and the remaining capacity of the waiting queue, and accurately limit the current limit and suppress the unnecessary current limit.

Benefits of technology

Reduces the probability of request error limit, reduces damage to the business side, improves user experience, and ensures the stability of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118940052A_ABST
    Figure CN118940052A_ABST
Patent Text Reader

Abstract

The invention discloses a current limiting method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring M request statements in a current time period Ti; comparing each request statement in the M request statements with a preset traffic limiting statement to obtain a matching statement corresponding to the preset traffic limiting statement in the current time period; based on the preset throughput corresponding to the current time period and the residual throughput THi-1 corresponding to the previous time period Ti-1, determining the residual throughput THi corresponding to the current time period; and based on the residual capacities Pi and THi of the waiting queues corresponding to the current time period, performing current-limiting suppression on the matching statements corresponding to the current time period, thereby reducing the probability of mislimiting the request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of current limiting technology, and in particular to a current limiting method, device, electronic device and storage medium. Background Art

[0002] In order to avoid overloading or crashing the database system, it is necessary to limit the rate at which the database system processes queries or transactions. The main current limiting methods include: first, template matching limiting, which means that as long as the request statement contains template features, current limiting is performed; second, keyword matching limiting, which means that as long as the request statement contains keyword features, current limiting is performed. However, the above limiting methods will directly refuse to execute as long as the request statement contains templates or keywords, which will not only result in mis-limitation, but also cause hardware damage to the business side, thereby reducing the business experience. Summary of the invention

[0003] The present application provides a flow limiting method, device, electronic device and storage medium, which not only reduces the probability of request error limiting, but also reduces the damage to the business side, thereby improving the experience of the business side.

[0004] In a first aspect, the present application provides a current limiting method, the method comprising:

[0005] Get the current time period T i M request statements in it;

[0006] Compare each of the M request statements with the preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period;

[0007] Based on the preset throughput corresponding to the current period and the previous period T i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ;

[0008] Based on the remaining capacity P of the waiting queue corresponding to the current period i , TH i , limit the flow of matching statements corresponding to the current period.

[0009] In a second aspect, the present application provides a current limiting device, the current limiting device comprising: an acquisition unit and a processing unit;

[0010] The acquisition unit is used to obtain the current time period T i M request statements in it;

[0011] A processing unit, configured to compare each of the M request statements with a preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in a current time period;

[0012] The processing unit is further configured to calculate the throughput of the previous time period based on the preset throughput corresponding to the current time period and the T i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ;

[0013] The processing unit is also used to calculate the remaining capacity P of the waiting queue corresponding to the current time period. i , TH i , limit the flow of matching statements corresponding to the current period.

[0014] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory, so that the electronic device performs the method of the first aspect.

[0015] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a computer to execute the method of the first aspect.

[0016] In a fifth aspect, the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and is computer-operable to cause the computer to execute the method of the first aspect.

[0017] Implementing this application has the following beneficial effects:

[0018] This application obtains the current time period T i M request statements in the time period; then compare each request statement in the M request statements with the preset flow limiting statement to obtain the matching statement corresponding to the preset flow limiting statement in the current time period; then based on the preset throughput corresponding to the current time period, the previous time period Ti-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ; Then based on the remaining capacity P of the waiting queue corresponding to the current period i , TH i, the matching statement corresponding to the current time period is limited and suppressed, that is, first, the request statements corresponding to the multiple pending requests in the current time period are compared with the preset limiting statement, and the matching statement corresponding to the current time period is obtained. At this time, the matching statement refers to the same as the limiting statement, that is, the precise matching method of the present application is compared with the fuzzy matching methods such as template matching and keyword matching in the prior art, which avoids the original non-matching statement from being identified as a matching statement, solves the problem of false limiting, and then based on TH i , the matching statements corresponding to the current time period are limited and suppressed, instead of directly limiting the matching statements corresponding to the current time period, which reduces the hard damage to the business side and thus improves the experience of the business side. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 A schematic diagram of a current limiting system provided in an embodiment of the present application;

[0021] Figure 2 A schematic diagram of a current limiting method provided in an embodiment of the present application;

[0022] Figure 3 A schematic diagram of another current limiting method provided in an embodiment of the present application;

[0023] Figure 4 A schematic diagram of another current limiting method provided in an embodiment of the present application;

[0024] Figure 5 A block diagram of the functional units of a current limiting device provided in an embodiment of the present application;

[0025] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0027] The terms "first", "second", "third" and "fourth" etc. in the specification, claims and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0028] Reference to "embodiments" herein means that a particular feature, result, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0029] First, it is explained that there are many types of request statements. The embodiment of the present application mainly takes the request statement as an SQL statement as an example for explanation. The following first explains the relevant technologies and related terms involved in the present application:

[0030] Throttle: Usually used to describe the rate limiting or controlling of systems, network traffic, and programs, such as limiting the rate at which a database system processes queries or transactions to avoid system overload or crash.

[0031] SQL Digest: A tool used to convert SQL statements into a type of fingerprint statement with identification features that can distinguish other categories. For example, the original SQL statement is: select id, name, age from students where id = "3" and name = "Zhang San". The original statement is converted into SQL fingerprint, and the corresponding fingerprint statement is: "select id, name, age from students where id =? and name =?".

[0032] Throughput: It is used to describe the consumption rate of a type of quantifiable resource. In MySQL, throughput can be expressed as the number of requests that can be completed or passed per second (QPS, Queries Per Second), or the number of transactions that can be completed or passed per second (TPS, Transactions Per Second). The initial throughput per second can be pre-configured.

[0033] Slack: refers to the quota (quota) of the throughput resources that have not been consumed in the current period that are allowed to be accumulated to the next period. The slack can be pre-configured. For example, assuming that the initial throughput per second is set to 100qps and Slack is set to 10qps, if it is assumed that only 80qps are passed in the 0th second (that is, 80qps are consumed), then the remaining 20qps resources in the 0th second are allowed to accumulate to the quota of 10qps in the 1st second. At this time, the updated throughput in the 1st second = initial throughput + accumulated quota in the 0th second = 100+10 = 110qps.

[0034] Pending: refers to the number of requests that are allowed to queue for processing when the throughput resources of the current period are less than the number of requests corresponding to the current period. The length or capacity of the waiting queue can be pre-configured. For example, assuming that the throughput per second is set to 100qps and the length of the waiting queue is set to 50, if 200 requests are obtained in the current second, the first 100 requests of the 200 requests are released for processing, 50 requests are added to the waiting queue, and the last 50 requests are directly rejected for processing, that is, current limiting processing.

[0035] Template matching: Assume that the given current limiting template is: select id, name, age from students where name = "Zhang San", and SQL statement 2: select id, name, age from students where name = "Zhang San" and id = "Unique ID"; analyze SQL statement 1 to get the corresponding template 1: select id, name, age from students where name = "Zhang San" and id = "Unique ID"; analyze SQL statement 1 to get the corresponding template 1: select id, name, age from students where name = "Zhang San" and id = "Unique ID"; then match the templates corresponding to the SQL statements with the current limiting templates respectively, and find that both template 1 and template 2 include the features of the current limiting template, then both SQL statement 1 and SQL statement 2 will be current limited. However, template 2 only includes the current limiting template, which is not exactly the same as the current limiting template. In principle, SQL statement 2 should not be current limited, but according to the template matching current limiting method, SQL statement 2 will be current limited, that is, SQL statement 2 is wrongly limited.

[0036] Keyword matching: Assume that the originally planned SQL statement to be restricted is: select*from user_, where "user_" is a sub-table. In fact, it will be routed to specific sub-tables user_01, user_02, user_03, etc. according to the routing rules; the keywords generated for the SQL statement include: select, *, from, user_; now there are SQL statement 3: select*from user_note, SQL statement 4: select*user_from server. It can be seen that SQL statement 3 and SQL statement 4 both contain the keyword features of the restricted statement, so SQL statement 3 and SQL statement 4 will be restricted. However, SQL statement 3 and SQL statement 4 are not the same as the restricted statement, so SQL statement 3 and SQL statement 4 will be restricted by mistake.

[0037] It can be seen from this that the current limiting method in the prior art may have incorrect limiting effects, and as long as the SQL statement matches or conforms to the current limiting feature, it will be directly limited. From the business side, if the user whose request is rejected repeatedly refreshes the request but cannot get the data due to current limiting, the user experience will be reduced, that is, it will cause hard damage to the business side.

[0038] Therefore, the present application obtains a matching statement corresponding to the preset limiting statement in the current time period by comparing the request statement with the limiting statement. The matching statement at this time means that the fingerprint corresponding to the request statement is exactly the same as the fingerprint corresponding to the limiting statement, that is, the present application is an accurate match, which avoids the mis-limitation in the prior art. Then, the remaining throughput of the current time period is determined, and the matching statement corresponding to the current time period is limited based on the remaining capacity of the waiting queue and the remaining throughput of the current time period. That is to say, the existing limiting method directly rejects the matching statement after obtaining the matching statement, while the present application now limits the matching statement based on the remaining throughput of the current time period, so that not all matching statements in the current time period are limited, but the number of matching statements limited is reduced as much as possible, so that even if it is a matching statement, the request corresponding to the matching statement can be passed or released, thereby reducing the hard damage to the business side and improving the experience of the business side.

[0039] See also Figure 1 , Figure 1 A schematic diagram of a current limiting system provided in an embodiment of the present application.

[0040] Figure 1The current limiting system includes a client and a current limiting device, wherein the client can be a smart phone, tablet computer, laptop computer, desktop computer, smart TV, desktop computer, smart watch, smart car and other smart terminals, which is not specifically limited in this application, and the number of clients can be one or more, which is not specifically limited in this application; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, as well as basic cloud computing services such as big data and artificial intelligence platforms, such as the proxy layer Myhub of the MySQL database management system, which is not specifically limited in this application.

[0041] First, in the current time period, if the user performs data access, query and other operations through the corresponding client, the current limiting device receives M request statements from the client. At this time, the number of clients is less than or equal to M, which is equivalent to that the client has concurrently issued M pending requests in the current time period, and the M pending requests correspond to the M request statements one by one; then the current limiting device compares each request statement in the M request statements with the preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period; then the current limiting device calculates the matching statement based on the preset throughput corresponding to the current time period and the T of the previous time period. i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ; Then based on the remaining capacity P of the waiting queue corresponding to the current period i , TH i , limit the flow of matching statements corresponding to the current period.

[0042] The current limiting system in the embodiment of the present application may further include a database management system. When the current limiting device compares each request statement in the M request statements with the preset current limiting statement, it can also obtain the non-matching statement corresponding to the preset current limiting statement in the current time period. After obtaining the non-matching statement corresponding to the current time period, the current limiting device sends the non-matching statement to the database management system, and then the database management system successively parses, optimizes, and executes queries on the non-matching statement to obtain data corresponding to the non-matching statement, and then the database management system returns the data corresponding to the non-matching statement to the client corresponding to the non-matching statement; and the current limiting device performs current limiting suppression on the matching statement corresponding to the current time period. After the judgment, the pending requests corresponding to the matching statements that still need to be limited in the current time period are rejected, and the current limiting device returns a rejection response to the client corresponding to the pending requests that need to be limited; similarly, the current limiting device sends the matching statements that do not need to be limited in the current time period to the database management system, and then the database management system also parses, optimizes, and executes queries on the matching statements that do not need to be limited in turn, and obtains the data corresponding to the matching statements that do not need to be limited, and then the database management system returns the data corresponding to the matching statements that do not need to be limited to the corresponding client, thereby minimizing the hardware damage to the business side as much as possible while ensuring the stability of the database management system.

[0043] Of course, the specific flow limiting business scenarios involved in the flow limiting method of the present application may include, in addition to the above-mentioned user data access and query through the client, but may also include but are not limited to the following scenarios:

[0044] (1) Data skew scenario: This scenario mainly targets data skew caused by popular things. For example, a certain type of product or an event has aroused heated discussions among users. In a short period of time, a large number of comments, likes, and reposts are poured in through the Internet, generating a large number of SQL requests. Correspondingly, a large number of SQL write operations will be given to the same shard of the database management system, which will cause the read and write performance of the shard to decline or even collapse. Therefore, current limiting protection is required. At this time, by using the current limiting method of the present application, on the premise of ensuring the stability of the database management system (i.e., on the premise of throughput capacity), the requests that need to be limited are suppressed and limited as much as possible. This can not only provide current limiting protection for the database management system, but also reduce the hardware damage to the business side.

[0045] (2) For transaction-based "bad SQL" scenarios: For example, multiple SQL statements (SQL1, SQL2, SQL3, and SQL4) belong to the same transaction. That is, the execution of the transaction requires the execution of the four SQL statements in sequence. However, if SQL3 is a "bad SQL", that is, SQL3 is a complex statement that consumes a large amount of resources, when the number of concurrent business requests increases to a certain level, SQL3 needs to be throttled to prevent the database from crashing. However, since transaction processing has consumed a certain amount of resources, if SQL3 is throttled, the transaction needs to be rolled back from SQL1 again. However, rollback is generally not recommended. Therefore, throttling protection is required at this time. Under the premise of ensuring database stability, throttling should be suppressed as much as possible to prevent the transaction from being rolled back.

[0046] (3) Occasional pulse-like surges in traffic: For example, when an event is held, a large number of users open a link to participate in a lottery at the same time in a short period of time. At this time, current limiting protection is also required. However, during the current limiting protection process, the current limiting method of this application can suppress and limit the requests that need to be limited. Under the premise of ensuring the stability of the database, the hard damage on the business side can be reduced as much as possible.

[0047] See also Figure 2 , Figure 2 A schematic diagram of a current limiting method provided in an embodiment of the present application. Figure 2 The method shown is applied to the current limiting device in the above embodiment, and the method includes but is not limited to the following steps S201-S204:

[0048] S201: Get the current time period T i M request statements within.

[0049] In an embodiment of the present application, if a user performs operations such as querying, accessing, etc. that trigger a request through M clients in the current time period, and the M clients concurrently send M request statements to the current limiting device through M threads, the current limiting device correspondingly obtains M request statements from the clients; in addition, the present application does not specifically limit the time length of the current time period.

[0050] S202: Compare each request statement with the preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period.

[0051] In an embodiment of the present application, for each request statement, it is detected whether the current limiting function is currently turned on. If not, each request statement is sent to the database management system to obtain data corresponding to the request statement; if the current limiting function is turned on, each request statement is fingerprinted to obtain a first fingerprint statement corresponding to each request statement, and the preset current limiting statement is fingerprinted to obtain a second fingerprint statement. It should be noted that the principle of fingerprint conversion refers to the above-mentioned existing explanation and will not be repeated here; then each first fingerprint statement is compared with the second fingerprint statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period, wherein the matching statement is exactly the same as the second fingerprint statement.

[0052] S203: Based on the preset throughput corresponding to the current period and the T i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i .

[0053] In the embodiment of the present application, when i=1, TH is determined 1 For the first period T 1 corresponding preset throughput; when i>1, if the number of first request statements corresponding to the previous period is greater than or equal to the remaining throughput TH corresponding to the previous period i-1 , determine TH i is the preset throughput corresponding to the current period; if the number of first request statements corresponding to the previous period is less than TH i-1 , then based on TH i-1 , the number of first request statements corresponding to the previous period, determine TH i , wherein the first request statement corresponding to the previous period may be a matching statement corresponding to the previous period, and optionally, the first request statement corresponding to the previous period may include a matching statement corresponding to the previous period and a request statement in a waiting queue corresponding to the previous period. Exemplary:

[0054] Get the preset maximum slack corresponding to the previous period, where the maximum slack corresponding to each period represents the maximum quota for each period to transfer the remaining throughput of the period to the next period; then determine the TH corresponding to the previous period i-1 The third difference between the number of first request statements corresponding to the previous period; then based on the maximum slack amount third difference, determine TH i For example, if the third difference is less than the maximum relaxation, determine TH i is the sum of the preset throughput corresponding to the current period and the third difference; if the third difference is greater than or equal to the maximum relaxation amount, determine TH i It is the sum of the preset throughput and the maximum slack corresponding to the current period.

[0055] It should be explained that the present application sets the maximum slack corresponding to each time period. When the throughput resources of the current time period are not consumed, that is, the number of requests passed in the current time period is less than the throughput of the current time period, and there are still throughput resources remaining, then by comparing the maximum slack set for the current time period with the number of throughput resources remaining in the current time period, the throughput resource quota that can be transferred to the next time period in the current time period is determined (and the maximum cannot exceed the maximum slack). This is because the size of the maximum slack is set under the premise of ensuring the stability of the database, which is equivalent to the maximum throughput resource corresponding to each time period can only be the sum of the preset throughput corresponding to each time period and the maximum slack corresponding to each time period, which will not exceed the carrying capacity of the database, and the unused resource quota of the current time period can also be given to the next time period for use. For the peak traffic period, it is equivalent to giving the unused resource quota of the low traffic period to the peak traffic period for use, so as to achieve peak shaving and valley filling, which not only realizes the rational use of resources, but also reduces the processing pressure during peak periods.

[0056] S204: Based on the remaining capacity P of the waiting queue corresponding to the current time period i , TH i , limit the flow of matching statements corresponding to the current period.

[0057] After determining the remaining throughput corresponding to the current period, the matching statements corresponding to the current period can be further limited and suppressed based on the remaining throughput corresponding to the current period. For example, if the remaining throughput corresponding to the current period is greater than or equal to the number of matching statements corresponding to the current period, all matching statements corresponding to the current period are passed, that is, the matching statements corresponding to the current period are not limited but released, and then the matching statements corresponding to the current period can be sent to the database management system for corresponding data query; if the remaining throughput corresponding to the current period is less than the number of matching statements corresponding to the current period, the TH in the matching statement corresponding to the current period is i The matching statements are allowed to pass, and the remaining matching statements are directly rejected. For example, the current limiting device sends an error response to the client corresponding to the remaining matching statements, that is, the TH in the matching statement corresponding to the current period is rejected. i The matching statements of the current time period are not subject to flow control, except for TH i The remaining statements outside the matching statements are used to limit the flow.

[0058] In an optional embodiment, step S204 may also be: based on the matching statement corresponding to the current time period, determine the first request statement corresponding to the current time period, wherein the first request statement corresponding to the current time period includes the matching statement corresponding to the current time period and the request statement in the waiting queue corresponding to the previous time period. It should be noted that when i=1, the first time period T iThe corresponding multiple first request statements include the matching statements of the first period, that is, the number of request statements in the waiting queue corresponding to the previous period is 0; then based on P i , TH i , the first request statement corresponding to the current period is limited and suppressed, for example:

[0059] If the number of first request statements corresponding to the current period is less than or equal to TH i , the first request statement corresponding to the current time period is released, that is, the current limiting device sends the first request statement corresponding to the current time period to the database management system, and then the database management system determines the data or response information corresponding to the first request statement based on the first request statement, and then the database management system returns the data or response information corresponding to the first request statement to the client corresponding to the first request statement.

[0060] If the number of first request statements corresponding to the current period is greater than TH i , then based on P i , TH i , the first request statement corresponding to the current period is limited and suppressed, where P i It can be the preset waiting queue capacity, or when i=1, determine the current time period, i.e., the first time period P 1 is the preset maximum capacity of the waiting queue. When i>1, if the number of request statements in the waiting queue corresponding to the previous period in the first request statement corresponding to the current period is less than or equal to the remaining throughput TH of the current period, i , determine P i is the preset maximum capacity of the waiting queue; if the number of request statements in the waiting queue corresponding to the previous period in the first request statement corresponding to the current period is greater than TH i , based on the maximum capacity of the waiting queue, the request statement in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period, TH i , determine the P i For example, determining the number of request statements in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period and the number of request statements in the waiting queue corresponding to the previous time period i The first difference between i It is the difference between the maximum capacity of the waiting queue and the first difference.

[0061] Then, based on P i , TH i , the number of first request statements corresponding to the current period, and the first request statements corresponding to the current period are limited and suppressed. Specifically, the second request statement in the first request statement corresponding to the current period is released, wherein the number of second request statements is equal to THi ; and determine the number of first request statements corresponding to the current period and TH i The second difference between the two, that is, determining the number of remaining statements that have not passed in the first request statement corresponding to the current period; then based on the second difference, P i , current limiting suppression is performed on the third request statement corresponding to the current time period, wherein the third request statement is the request statement in the first request statement except the second request statement, and the number of the third request statements is the second difference value, exemplarily:

[0062] If the second difference is less than or equal to P i , the third request statements are added to the waiting queue corresponding to the current time period, indicating that the number of remaining request statements that have not passed in the first request statement corresponding to the current time period (i.e., the second difference) is less than or equal to the remaining capacity P of the waiting queue corresponding to the current time period. i , all the third request statements corresponding to the current time period can be added to the waiting queue. After adding, the remaining capacity of the waiting queue is updated to the P corresponding to the current time period. i The difference between the second difference (i.e., the remaining capacity of the waiting queue corresponding to the next period P i+1 ); If the second difference is greater than P i , add the fourth request statement in the third request statement to the waiting queue corresponding to the current time period, and reject the fifth request statement in the third request statement, wherein the number of the fourth request statement is P i , the number of the fifth request statement is the second difference and P i The difference between the waiting queue capacity P and the waiting queue capacity P in the current period. i The queue is not large enough to accommodate all the third request statements that have not been passed in the current period (the number is the second difference), so the fourth request statement in the third request statement of the current period can only be added to the waiting queue (the number of the fourth request to be processed is P at this time). i ), and the remaining request statements in the third request statement of the current period that have not been added to the waiting queue (i.e., the fifth request statement) are rejected, that is, they are limited in flow, for example, an error response can be sent to the client corresponding to the fifth request statement.

[0063] In an optional embodiment, when i>1, since the first request statement corresponding to the current time period includes the matching statement corresponding to the current time period and the request statement in the waiting queue corresponding to the previous time period, adhering to the principle of "first in, first out", when the second request statement in the first request statement corresponding to the current time period is released, the sixth request statement is determined from the request statements in the waiting queue corresponding to the previous time period according to the time sequence in which the current limiting device obtains the request statements, and then the sixth request statement is released preferentially, wherein the number of the sixth request statement is less than or equal to the number of the second request statements in the current time period, that is, when the number of the sixth request statement is equal to the number of the second request statement, it means that the number of the request statement in the waiting queue corresponding to the previous time period is greater than or equal to the number of the second request statement (i.e., TH i ), at this time, the sixth request statement is part or all of the request statements in the waiting queue corresponding to the previous time period (when the number of request statements in the waiting queue corresponding to the previous time period is greater than the number of second request statements, it is part, when the number of request statements in the waiting queue corresponding to the previous time period is equal to the number of second request statements, it is all), then the above-mentioned release processing of the second request statement in the first request statement corresponding to the current time period is equivalent to the release processing of the sixth request statement corresponding to the current time period;

[0064] Similarly, when the number of the sixth request statement is less than the number of the second request statement, it means that the number of request statements in the waiting queue corresponding to the previous time period is less than the number of the second request statement. At this time, the sixth request statement is all the request statements in the waiting queue corresponding to the previous time period. Then, the above-mentioned release processing of the second request statement in the first request statement corresponding to the current time period is equivalent to releasing the sixth request statement corresponding to the current time period, and it is also necessary to release the seventh request statement corresponding to the current time period, wherein the seventh request statement is part or all of the matching statement corresponding to the current time period, and the number of the seventh request statement is the difference between the number of the second request statement and the number of the sixth request statement. In short, in an embodiment of the present application, since the request statement will be added to the waiting queue in the previous time period and then given to the current time period for processing, in order to ensure the experience on the business side, the current time period can give priority to processing the request statements in the waiting queue when processing, so as to avoid the waiting time or response time on the business side being too long.

[0065] See also Figure 3 , Figure 3 A schematic diagram of another current limiting method provided in an embodiment of the present application.

[0066] Figure 3 Take SQL request as an example. Figure 3The database management system in the example may be MySQL, the current limiting device corresponds to the proxy layer Myhub of MySQL, and the client is installed with the target application software; Figure 3 , if multiple threads of the client concurrently send multiple SQL statements corresponding to multiple SQL requests to the current limiting device through the software development kit (SDK) of the target application software in the current period, the current limiting device caches and maintains the multiple SQL statements sent by the client through the database connection pool, and then obtains the SQL statements of the current period from the database connection pool through the processing thread, and then detects whether the current limiting function is enabled. If the current limiting function is not enabled, the SQL statements of the current period are sent to the database management system. Accordingly, the database management system determines the corresponding data based on the sent SQL statements and returns it to the corresponding client; if the current limiting function is enabled, the SQL statements of the current period are fingerprinted, and then it is determined whether the statements after fingerprint conversion match the current limiting fingerprint statements. If not, the SQL statements are sent to the database management system; if they match, it is determined whether the number of SQL statements in the current period is greater than the remaining throughput of the current period. If not, the SQL statements of the current period are sent to the database management system, and the determination The difference A between the remaining throughput of the current period and the SQL statements of the current period is determined, and then the throughput quota of the difference A corresponding to the current period is transferred to the next period; if so, the SQL statement of the remaining throughput of the current period is sent to the database management system, and the difference B between the SQL statements of the current period and the remaining throughput of the current period is determined, and then it is determined whether the difference B is greater than the remaining capacity of the waiting queue of the current period. If not, the SQL statement of the difference B is added to the waiting queue; if so, the SQL statement of the remaining capacity of the waiting queue of the current period is added to the waiting queue, and the requests corresponding to the SQL statements of the difference B in the current period except the SQL statements added to the waiting queue are rejected, that is, a rejection response or error message is sent to the client corresponding to the request; similarly, the database management system will determine the data corresponding to the SQL statement based on the SQL statement obtained from the current limiting device side, and return the data to the corresponding client.

[0067] For easier understanding, see Figure 4 , Figure 4 A schematic diagram of another current limiting method provided in an embodiment of the present application. Figure 4 The three time periods T shown 1 , T 2 , T 3 The preset throughputs are all 100. Assuming T 1 A total of 80 request statements were obtained during this period. Since the number of 80 request statements is less than T 1The preset throughput of the time period, then T 1 A total of 80 request statements were passed during this period. 1 There are 20 throughput resources left in the time period, and then the preset maximum slack, Slack (value is 15), is obtained. Since the value of Slack is less than T 1 The amount of throughput resources remaining in the time period, then T 1 The remaining 20 throughput resources in the time period are given to T 2 Time period, then T 2 The throughput of the time period is updated from the preset throughput (value 100) to 115; similarly, assuming T 2 A total of 110 request statements were obtained during this period. Since the 110 request statements are less than T 2 The throughput after the period update (value is 115), indicating that T 2 A total of 110 request statements were passed during the period, so T 2 There are still 5 throughput resources left in the time period. Since the value of Slack is greater than T 2 The amount of throughput resources remaining in the time period, then T 2 The remaining 5 throughput resources in the time period are all given to T 3 Time period, then T 3 The throughput of the time period is updated from the preset throughput (value 100) to 105; similarly, assuming T 3 A total of 115 request statements were obtained during this period. Since the number of 115 request statements is greater than T 3 The throughput after the time period is updated (the value is 105), then T 3 Only 115 request statements can be passed in total during the time period, and 10 request statements are temporarily blocked. At this time, the remaining capacity of the waiting queue (value is 50) is obtained. Since the number of the remaining 10 request statements is less than the remaining capacity of the waiting queue, T 3 The remaining 10 request statements in the time period are added to the waiting queue. Accordingly, the remaining capacity of the waiting queue is updated to 40. Furthermore, at this time, T 3 All request statements in the waiting queue corresponding to the time period need to be given priority processing in the next time period, which will not be repeated here.

[0068] It can be seen that in the embodiments of the present application, the request statement is first compared with the current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period. The matching statement at this time means that the fingerprint corresponding to the request statement is exactly the same as the fingerprint corresponding to the current limiting statement, that is, the present application is an accurate match, which avoids the situation of mis-limitation in the prior art, and determines the throughput resources corresponding to each time period by setting the parameters of the maximum relaxation amount, that is, the throughput resources that have not been consumed in the previous time period can transfer a certain quota to the current time period, then the throughput resources of the current time period are the sum of the preset throughput and the quota transferred in the previous time period, which is equivalent to transferring the unconsumed resources in the low-peak traffic period to the peak traffic period for use, realizing "peak shaving and valley filling", and reasonably adjusting resources dynamically, which can not only reduce the processing pressure in the peak traffic period, but also avoid waste of resources in the low-peak traffic period; then the matching statement corresponding to the current time period is matched based on the remaining capacity of the waiting queue and the remaining throughput in the current time period. That is to say, the existing flow limiting method will directly reject the matching statement after obtaining the matching statement, that is, flow limiting processing, and the present application now performs flow limiting suppression on the matching statement based on the remaining capacity and remaining throughput of the waiting queue in the current time period, that is, if the remaining throughput of the current time period is greater than or equal to the number of requests that have not been processed in the current time period, even if the request statement corresponding to the unprocessed request matches the flow limiting statement, the unprocessed request is still passed. At the same time, the waiting queue parameters are also set to ensure that when the remaining throughput of the current time period is less than the number of requests that have not been processed in the current time period, the requests that still cannot pass are added to the waiting queue for buffering, and then given to the next time period for processing. That is to say, not all matching statements in the current time period are limited, but the number of matching statements that are limited is reduced as much as possible, so as to achieve flow limiting suppression on the matching statements, thereby reducing the hard damage to the business side and improving the experience on the business side.

[0069] See also Figure 5 , Figure 5 A block diagram of the functional units of a current limiting device provided in an embodiment of the present application. The current limiting device 500 includes: an acquisition unit 501 and a processing unit 502;

[0070] Acquisition unit 501, used to obtain the current time period T i M request statements in it;

[0071] The processing unit 502 is used to compare each request statement in the M request statements with the preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period;

[0072] The processing unit 502 is further configured to calculate the throughput of the previous time period based on the preset throughput corresponding to the current time period and the T i-1The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ;

[0073] The processing unit 502 is further configured to calculate the remaining capacity P of the waiting queue corresponding to the current time period. i , TH i , limit the flow of matching statements corresponding to the current period.

[0074] In one embodiment of the present application, based on the remaining capacity P of the waiting queue corresponding to the current time period i , TH i In terms of current limiting and suppressing the matching statements corresponding to the current period, the acquisition unit 501 is specifically used to:

[0075] Based on the matching statement corresponding to the current time period, determining the first request statement corresponding to the current time period, wherein the first request statement corresponding to the current time period includes the matching statement corresponding to the current time period and the request statement in the waiting queue corresponding to the previous time period;

[0076] Based on P i , TH i , limit the flow of the first request statement corresponding to the current time period.

[0077] In one embodiment of the present application, based on P i , TH i In terms of current limiting and suppressing the first request statement corresponding to the current time period, the processing unit 502 is specifically configured to:

[0078] If the number of first request statements corresponding to the current period is less than or equal to TH i , release the first request statement corresponding to the current time period;

[0079] If the number of first request statements corresponding to the current period is greater than TH i , get the remaining capacity P of the waiting queue corresponding to the current period i ;

[0080] Based on P i , TH i , limit the flow of the first request statement corresponding to the current time period.

[0081] In one embodiment of the present application, when obtaining the remaining capacity P of the waiting queue corresponding to the current time period, i In aspect, the processing unit 502 is specifically configured to:

[0082] When i=1, determine P 1 The maximum capacity of the preset waiting queue;

[0083] When i>1, if the number of request statements in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period is less than or equal to TH i , determine P i is the maximum capacity of the waiting queue; if the number of request statements in the waiting queue corresponding to the previous period in the first request statement corresponding to the current period is greater than the TH i , based on the maximum capacity of the waiting queue, the request statements in the waiting queue corresponding to the previous period in the first request statement corresponding to the current period, and the TH i , determine P i .

[0084] In one embodiment of the present application, based on the maximum capacity of the waiting queue, the request statement in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period, the TH i , determine P i In aspect, the processing unit 502 is specifically configured to:

[0085] Determine the number of request statements in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period and TH i The first difference between

[0086] Determine P i It is the difference between the maximum capacity of the waiting queue and the first difference.

[0087] In one embodiment of the present application, based on the P i , the TH i In terms of current limiting and suppressing the first request statement corresponding to the current time period, the processing unit 502 is specifically configured to:

[0088] The second request statements in the first request statements corresponding to the current time period are released, wherein the number of second request statements is equal to TH i ;

[0089] Determine the number of first request statements corresponding to the current period and TH i The second difference between

[0090] Based on the second difference, P i , current limiting suppression is performed on the third request statement corresponding to the current time period, wherein the third request statement is the request statement in the first request statement except the second request statement, and the number of the third request statements is the second difference.

[0091] In one embodiment of the present application, based on the second difference, P i In terms of current limiting and suppressing the third request statement corresponding to the current time period, the processing unit 502 is specifically configured to:

[0092] If the second difference is less than or equal to P i , add the third request statement to the waiting queue corresponding to the current time period;

[0093] If the second difference is greater than P i , add the fourth request statement in the third request statement to the waiting queue corresponding to the current time period, and reject the fifth request statement in the third request statement, wherein the number of the fourth request statement is P i , the number of the fifth request statement is the second difference and P i difference.

[0094] In one embodiment of the present application, in determining the first request statement corresponding to the current time period based on the matching statement corresponding to the current time period, the processing unit 502 is specifically configured to:

[0095] When i=1, the first time period T i The corresponding multiple first request statements include pending requests corresponding to the matching statements in the first time period;

[0096] When i>1, the first request statement corresponding to the current time period includes the matching statement corresponding to the current time period and the pending requests in the waiting queue corresponding to the previous time period.

[0097] In one embodiment of the present application, based on the preset throughput corresponding to the current period, the previous period T i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i In aspect, the processing unit 502 is specifically configured to:

[0098] When i=1, determine TH 1 For the first period T 1 The corresponding preset throughput;

[0099] When i>1, if the number of first request statements corresponding to the previous period is greater than or equal to the remaining throughput TH corresponding to the previous period i-1 , determine TH i is the preset throughput corresponding to the current period; if the number of first request statements corresponding to the previous period is less than TH i-1 , based on TH i-1 , the number of first request statements corresponding to the previous period, determine TH i .

[0100] In one embodiment of the present application, based on TH i-1 , the number of first request statements corresponding to the previous period, determine TH iIn aspect, the processing unit 502 is specifically configured to:

[0101] Obtain the maximum slack corresponding to the preset previous period, wherein the maximum slack corresponding to each period represents the maximum quota of each period for transferring the remaining throughput of the period to the next period;

[0102] Determine TH i-1 a third difference between the number of first request statements corresponding to the previous time period;

[0103] Based on the maximum relaxation and the third difference, determine TH i .

[0104] In one embodiment of the present application, based on the maximum relaxation amount and the third difference, TH is determined. i In aspect, the processing unit 502 is specifically configured to:

[0105] If the third difference is less than the maximum relaxation, determine TH i is the sum of the preset throughput corresponding to the current period and the third difference;

[0106] If the third difference is greater than or equal to the maximum relaxation, determine TH i It is the sum of the preset throughput and the maximum slack corresponding to the current period.

[0107] In a specific implementation, the acquisition unit 501 and the processing unit 502 described in the embodiment of the present invention may execute other implementations described in the embodiment of the current limiting method provided in the embodiment of the present invention, which will not be described in detail here.

[0108] See also Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device 600 includes a transceiver 601, a processor 602 and a memory 603. They are connected via a bus 604. The memory 603 is used to store computer programs and data, and can transmit the data stored in the memory 603 to the processor 602.

[0109] The processor 602 is used to read the computer program in the memory 603 and perform the following operations:

[0110] Control transceiver 601 to obtain the current time period T i M request statements in it;

[0111] Compare each of the M request statements with the preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period;

[0112] Based on the preset throughput corresponding to the current period and the previous period Ti-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ;

[0113] Based on the remaining capacity P of the waiting queue corresponding to the current period i , TH i , limit the flow of matching statements corresponding to the current period.

[0114] Specifically, the transceiver 601 may be Figure 5 The acquisition unit 501 of the current limiting device 500 of the embodiment, the processor 602 may be Figure 5 The processing unit 502 of the current limiting device 500 of the embodiment.

[0115] In a specific implementation, the transceiver 601 and the processor 602 described in the embodiment of the present invention may also execute other implementations described in the embodiment of the current limiting method provided in the embodiment of the present invention, which will not be described in detail here.

[0116] It should be understood that the electronic device in this application can be a current limiting device, which can be a server, such as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and basic cloud computing services such as big data and artificial intelligence platforms. This application does not make specific limitations. The above electronic devices are only examples, not exhaustive, and include but are not limited to the above electronic devices.

[0117] It should be understood that an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement part or all of the steps of any current limiting method recorded in the above method embodiments.

[0118] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any current limiting method recorded in the above method embodiments.

[0119] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0120] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0121] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0122] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0123] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.

[0124] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a current limiting device or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0125] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.

[0126] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A current limiting method, characterized in that: The method comprises: Get the current time period T i M request statements in it; Compare each of the M request statements with a preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period; Based on the preset throughput corresponding to the current period and the previous period T i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ; Based on the remaining capacity P of the waiting queue corresponding to the current period i , the TH i , limit the flow of matching statements corresponding to the current period.

2. The method according to claim 1, characterized in that The remaining capacity P of the waiting queue corresponding to the current time period i , the TH i , limit the flow of matching statements corresponding to the current period, including: Based on the matching statement corresponding to the current time period, determining the first request statement corresponding to the current time period, wherein the first request statement corresponding to the current time period includes the matching statement corresponding to the current time period and the request statement in the waiting queue corresponding to the previous time period; Based on the P i , the TH i , limit the flow of the first request statement corresponding to the current time period.

3. The method according to claim 2, characterized in that Based on the P i , the TH i , current limiting and suppression are performed on the first request statement corresponding to the current period, including: If the number of first request statements corresponding to the current time period is less than or equal to the TH i , release the first request statement corresponding to the current time period; If the number of first request statements corresponding to the current period is greater than the TH i , based on the P i , the TH i , limit the flow of the first request statement corresponding to the current time period.

4. The method according to claim 2 or 3, characterized in that: When i=1, P1 is determined to be the preset maximum capacity of the waiting queue; When i>1, if the number of request statements in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period is less than or equal to the TH i , determine the P i is the maximum capacity of the waiting queue; If the number of request statements in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period is greater than the TH i , based on the maximum capacity of the waiting queue, the request statements in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period, the TH i , determine the P i .

5. The method according to claim 4, characterized in that The method is based on the maximum capacity of the waiting queue, the request statement in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period, and the TH i , determine the P i ,include: Determine the number of request statements in the waiting queue corresponding to the previous time period in the first request statement corresponding to the current time period and the number of request statements in the waiting queue corresponding to the previous time period i The first difference between Determine the P i It is the difference between the maximum capacity of the waiting queue and the first difference.

6. The method according to any one of claims 3 to 5, characterized in that: Based on the P i , the TH i , current limiting and suppression are performed on the first request statement corresponding to the current period, including: The second request statement in the first request statement corresponding to the current time period is released, wherein the number of the second request statements is equal to the number of the TH i ; Determine the number of first request statements corresponding to the current period and the TH i The second difference between Based on the second difference, the P i , current limiting suppression is performed on the third request statement corresponding to the current time period, wherein the third request statement is the request statement in the first request statement except the second request statement, and the number of the third request statements is the second difference.

7. The method according to claim 6, characterized in that The method based on the second difference, the P i , the third request statement corresponding to the current period is limited and suppressed, including: If the second difference is less than or equal to the P i , adding the third request statement to the waiting queue corresponding to the current time period; If the second difference is greater than the P i , add the fourth request statement in the third request statement to the waiting queue corresponding to the current time period, and reject the fifth request statement in the third request statement, wherein the number of the fourth request statement is the number of the P i , the number of the fifth request statement is the sum of the second difference and the P i difference.

8. The method according to any one of claims 2 to 7, characterized in that: The preset throughput corresponding to the current period, the previous period T i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ,include: When i=1, TH1 is determined to be the preset throughput corresponding to the first time period T1; When i>1, if the number of first request statements corresponding to the previous period is greater than or equal to the TH i-1 , determine the TH i is the preset throughput corresponding to the current period; if the number of first request statements corresponding to the previous period is less than the TH i-1 , based on the TH i-1 , the number of first request statements corresponding to the previous period, and determine the TH i .

9. The method according to claim 8, characterized in that Based on the TH i-1 , the number of first request statements corresponding to the previous period, and determine the TH i ,include: Obtain the maximum slack corresponding to the preset previous period, wherein the maximum slack corresponding to each period represents the maximum quota of each period for transferring the remaining throughput of the period to the next period; Determine the TH i-1 a third difference between the number of first request statements corresponding to the previous time period; Based on the maximum relaxation amount and the third difference, the TH is determined. i .

10. The method according to claim 9, characterized in that The TH is determined based on the maximum relaxation amount and the third difference. i ,include: If the third difference is less than the maximum relaxation amount, determine the TH i is the sum of the preset throughput corresponding to the current period and the third difference; If the third difference is greater than or equal to the maximum relaxation amount, determine the TH i It is the sum of the preset throughput corresponding to the current period and the maximum relaxation amount.

11. A current limiting device, characterized in that: The current limiting device comprises: an acquisition unit and a processing unit; The acquisition unit is used to acquire the current time period T i M request statements in it; The processing unit is used to compare each request statement in the M request statements with a preset current limiting statement to obtain a matching statement corresponding to the preset current limiting statement in the current time period; The processing unit is further configured to calculate the throughput of the previous time period based on the preset throughput corresponding to the current time period and the T i-1 The corresponding remaining throughput TH i-1 , determine the remaining throughput TH corresponding to the current period i ; The processing unit is further configured to calculate the remaining capacity P of the waiting queue corresponding to the current time period based on the i , the TH i , limit the flow of matching statements corresponding to the current period.

12. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method as described in any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 10.

Citation Information

Cited By

  • Method, device and equipment for limiting flow of SQL (Structured Query Language) statement and distributed database

    CN120492479A

  • Methods, devices, equipment, and distributed databases for rate limiting of SQL statements

    CN120492479B