CN111262795B - Service interface-based current limiting method and device, electronic equipment and storage medium - Google Patents

Service interface-based current limiting method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111262795B
CN111262795B CN202010019040.6A CN202010019040A CN111262795B CN 111262795 B CN111262795 B CN 111262795B CN 202010019040 A CN202010019040 A CN 202010019040A CN 111262795 B CN111262795 B CN 111262795B
Authority
CN
China
Prior art keywords
interface
calling
time
called
threshold value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010019040.6A
Other languages
Chinese (zh)
Other versions
CN111262795A (en
Inventor
刘瑞东
程建波
彭南博
张德
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Technology Holding Co Ltd
Original Assignee
Jingdong Technology Holding Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingdong Technology Holding Co Ltd filed Critical Jingdong Technology Holding Co Ltd
Priority to CN202010019040.6A priority Critical patent/CN111262795B/en
Publication of CN111262795A publication Critical patent/CN111262795A/en
Application granted granted Critical
Publication of CN111262795B publication Critical patent/CN111262795B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/22Traffic shaping
    • H04L47/225Determination of shaping rate, e.g. using a moving window
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • User Interface Of Digital Computer (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The application relates to a service interface-based current limiting method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: determining a calling threshold value of an interface to be called in a sliding time window; determining a first time interval according to the current time stamp and the sliding time window; counting the first calling times of the interface to be called in the first time interval; and when the first calling times are larger than the calling threshold value, executing the current limiting operation. According to the technical scheme, through the design of the sliding time window, the calling times of interfaces in two adjacent time periods can not exceed a preset calling threshold, and the calling times of any time interval in the two time periods can not exceed the preset calling threshold, so that smooth current limiting is achieved. In addition, the current limiting method provided by the application can also be used for coping with burst flow and accurately limiting the current.

Description

Service interface-based current limiting method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a service interface-based current limiting device, an electronic device, and a storage medium.
Background
Sudden high concurrency scenarios often occur in daily life, such as: the reduced price promotion of some popular merchandise during the course of a shopping session, resulting in hundreds of thousands, millions, or even tens of millions of accesses to the platform's service interface, creates a large volume of traffic, where each query inventory request is focused on the database, resulting in inefficiency. In the process of implementing the present invention, the inventor finds that the current limiting measures cannot perform smooth current limiting, and a spike phenomenon can occur, so that network congestion is caused, and user experience is low. The following defects exist in the current limiting measures:
the counter current limiting method has the defects that:
the counter current limit is typically controlled by controlling the number of requests that can pass one second, for example qps is 1000, the algorithm is implemented by counting from the first request, and in the next second, the counter value is incremented by 1 for each request, and if the accumulated number reaches 1000, the subsequent requests are rejected. After one second is finished, the counter value is restored to 0, and counting is restarted. The disadvantage of this algorithm is that if 1000 requests are made for the first 10ms in a second of unit time, then the request will be denied for the next 990ms, resulting in "spurs" and no smooth restriction.
The leakage bucket current limiting method has the defects that:
the leakage Bucket (leakage Bucket) algorithm realizes the thought that water (request) firstly enters the leakage Bucket, the leakage Bucket outputs water at a certain speed (the interface has response rate), when the water flowing speed is too high, the water directly overflows (the access frequency exceeds the interface response rate), then the request is refused, and the leakage Bucket algorithm can be seen to forcibly limit the data transmission rate. Since the leakage bucket always discharges water at a constant speed, it is impossible to cope with a burst flow in a short time.
The token bucket throttling method has the defects that:
the Token Bucket algorithm (Token Bucket) is more easily understood than an algorithm with the same effect but opposite direction as the leak Bucket. Over time, the system will add Token to the bucket at constant 1/QPS intervals (1 ms if qps=1000), and will not add if the bucket is full. The new requests are made temporarily, each take one Token away, and block or deny service if no Token is available. The token bucket algorithm is an improvement to the leaky bucket algorithm, and the bucket algorithm can limit the rate of request calls, and the token bucket algorithm can also allow a certain degree of burst calls while limiting the average rate of calls. The Rate Limit in the tool library provided by Google guava is implemented based on the token bucket algorithm, but this is limited to a single node, and if the system is a distributed system, the QPS of each node is the same, and if the request amount reaches the service interface, the QPS is the same. This approach is not applicable in the distributed case.
The current limiting scheme of the Redis-based String data structure has the defects that:
the interface name can be used as key, the initial value is 1, and the expiration time is set for current limiting; i.e. (key, expire time, 1)) when accessed, if there is the key, the value is increased by 1; (i.e., incr (key)) if not present, a default value of 1 is set; although this method solves the problem of current limiting in the distributed mode, current limiting is performed for a period of time, so that there are two periods of time that do not exceed a threshold value, respectively, but there may be a case where a period of time between the two periods of time exceeds a threshold value, and precise current limiting cannot be performed.
Disclosure of Invention
In order to solve the technical problems or at least partially solve the technical problems, the application provides a service interface-based current limiting method, a service interface-based current limiting device, an electronic device and a storage medium.
In a first aspect, the present application provides a service interface-based current limiting method, including:
determining a calling threshold value of an interface to be called in a sliding time window;
determining a first time interval according to the current time stamp and the sliding time window;
counting the first calling times of the interface to be called in the first time interval;
and when the first calling times are larger than the calling threshold value, executing the current limiting operation.
Optionally, the method further comprises:
acquiring an ordered set in a cache;
and determining the sliding time window according to the weight values in the ordered set.
Optionally, the determining the call threshold of the interface to be called in the sliding time window includes:
acquiring an interface identifier of the interface to be called;
and inquiring the calling threshold value of the interface to be called in each sliding time window from the cache according to the interface identification.
Optionally, the method further comprises:
when the calling threshold value of the interface to be called does not exist in the cache, reading the calling threshold value of the interface to be called from a database according to the interface identifier;
synchronizing the calling threshold value to the cache, and distributing expiration time for the calling threshold value.
Optionally, the counting the first call times of the interface to be called in the first time interval includes:
determining a second time interval from the start time to the current timestamp;
acquiring second calling times of the interface to be called in the second time interval;
calculating a third time interval obtained by subtracting the first time interval from the second time interval;
counting the third calling times of the interface to be called in the third time interval;
and calculating the difference value between the second calling times and the third calling times, and determining the first calling times according to the difference value.
Optionally, the performing a current limiting operation includes:
refusing the call request;
or alternatively, the first and second heat exchangers may be,
and placing the call request into a queue, and sequencing according to the priority of the call request.
Optionally, the method further comprises:
when the first calling times are smaller than or equal to the calling threshold value, the interface identification of the interface to be called is used as a key name to be added to an ordered set in a cache, and a weight value and a key value corresponding to the interface identification are updated to be the current timestamp in the ordered set.
In a second aspect, the present application provides a service interface-based current limiting device, including:
the determining module is used for determining a calling threshold value of the interface to be called in the sliding time window;
the acquisition module is used for determining a first time interval according to the current time stamp and the sliding time window;
the statistics module is used for counting the first calling times of the interface to be called in the first time interval;
and the execution module is used for executing the current limiting operation when the first calling times are larger than the calling threshold value.
In a third aspect, the present application provides an electronic device, including: the device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the above-mentioned method steps when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the above-mentioned method steps.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: by adopting the design of the sliding time window, the calling times of interfaces in two adjacent time periods can not exceed a preset calling threshold, and the calling times of any time interval in the two time periods can not exceed the preset calling threshold, so that smooth current limiting is achieved. In addition, the current limiting method provided by the application can also be used for coping with burst flow and accurately limiting the current.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, and it will be obvious to a person skilled in the art that other drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a flowchart of a service interface-based current limiting method according to an embodiment of the present application;
fig. 2 is a schematic diagram of a storage structure of an interface identifier and a call threshold provided in an embodiment of the present application;
FIG. 3 is a schematic diagram of a sliding time window according to an embodiment of the present disclosure;
fig. 4 is a block diagram of a service interface-based current limiting device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present application based on the embodiments herein.
The application provides a service interface-based current limiting method, a service interface-based current limiting device, electronic equipment and a storage medium. The method provided by the embodiment of the invention can be applied to any needed electronic equipment, for example, the electronic equipment can be a server, a terminal and the like, is not particularly limited, and is convenient to describe and is called as the electronic equipment for short hereinafter.
The following first describes a service interface-based current limiting method provided by an embodiment of the present invention.
Fig. 1 is a flowchart of a service interface-based current limiting method according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
step S11, determining a calling threshold value of an interface to be called in a sliding time window;
step S12, determining a first time interval according to the current time stamp and the sliding time window;
step S13, counting first calling times of interfaces to be called in a first time interval;
step S14, when the first calling times are larger than the calling threshold value, the current limiting operation is executed.
In this embodiment, by adopting the design of the sliding time window, the number of calls of the interface in two adjacent time periods is not more than the preset call threshold, and the number of calls in any time period in the two time periods is not more than the preset call threshold.
For example: the first time period is 0-1min, the second time period is 1-2min, the calling threshold value of the interface in each time period is 100 times/min, the calling times are 20 times and the calling times are 70 times when the first time period is 0-0.5min, and the calling times are 0.5-1 min. And when the second time period is 1-1.5min, the calling times are 60 times, and the calling times of 0.5-1 min are 30 times. Therefore, the calling times in two adjacent time periods do not exceed the calling threshold, but the calling times in the time period of 0.5-1.5min are larger than the calling threshold, so that the database is congested in a short time. However, by designing the sliding time window, smooth flow restriction can be performed in any time period, burst flow can be handled, and accurate flow restriction can be performed.
In this embodiment, a call request is received, and the call request may be initiated by the client. And determining a service interface to be called according to the call request, and determining a call threshold value of the interface to be called in each sliding time window.
The ordered set (zset) data structure in the Redis cache (Remote Dictionary Server remote dictionary service) utilized by the present embodiment includes: a weight value (score), an interface identifier (key) and a key value (value), and setting a sliding time window corresponding to each interface through the weight value (score).
In this embodiment, an interface identifier of an interface to be invoked is determined, and an invocation threshold value of the interface to be invoked in each sliding time window is queried from a cache according to the interface identifier. Specifically, fig. 2 is a schematic diagram of a storage structure of an interface identifier and a call threshold provided in an embodiment of the present application, as shown in fig. 2, in this embodiment, the interface identifier and the call threshold are stored in a list form, first, according to an interface to be called, a matched interface identifier is queried from a header of a list, and then, the call threshold corresponding to the interface identifier is used as a call threshold of the interface to be called in a sliding time window.
For example: m1 is the interface identifier of the payment interface, the call threshold value n1 of which in the sliding time window is 500 times, m2 is the interface identifier of the order generation interface, the call threshold value n2 in the sliding time window is 550 times, m3 is the interface identifier of the store collection interface, and the call threshold value n3 in the sliding time window is 300 times.
In this embodiment, when there is no call threshold of the interface to be called in the cache, the call threshold of the interface to be called is read from the database according to the interface identifier, the call threshold of the interface to be called is synchronized to the cache, and an expiration time is allocated to the call threshold. According to the embodiment of the application, the pressure of the database can be reduced by accessing the cache first, and the database is prevented from being jammed due to the fact that the database is accessed simultaneously. In addition, assigning an expiration time to the call threshold can prevent the cached content from being excessively occupied.
In order to perform accurate current limiting, the current time stamp is acquired by the method and the device in a microsecond unit, and then a first time interval between the current time stamp and a current time window is determined, wherein the time length of the first time interval is equal to that of the sliding time window.
And then counting the calling times of the interface to be called in the first time interval. Fig. 3 is a schematic diagram of a sliding time window provided in the embodiment of the present application, as shown in fig. 3, the current timestamp is now Tu, and a first time interval between the current timestamp and the sliding time window is now Tu-period 1000×1000—now Tu.
Optionally, counting the number of times of calling the interface to be called in the first time interval is specifically implemented in the following manner: determining a second time interval from the start time to the current timestamp; acquiring second calling times of interfaces to be called in a second time interval; calculating a third time interval obtained by subtracting the first time interval from the second time interval; counting the third calling times of the interface to be called in a third time interval; and calculating the difference value between the second calling times and the third calling times, and determining the first calling times according to the difference value.
Taking a payment interface as an example, a second time interval from the start time to the current time stamp is 0-now Tu, a second call number (i.e. a total call number) of the payment interface in the second time interval is 1600, and then a third time interval obtained by subtracting the first time interval from the second time interval is calculated to be 0-now Tu-period 1000. Counting to obtain the third calling times of the payment interface in the third time interval as 1000 times, wherein the difference between the second calling times and the third calling times is 1600-1000 times, and determining the obtained difference as the first calling times of the payment interface in the first time interval, namely 600 times.
As in the example above, 600 times greater than 500 times, i.e., when the first number of invocations is confirmed to be greater than the invocation threshold, the current limit operation is performed.
Optionally, the current limiting operation is performed, which may be: and obtaining a third calling number which is larger than a calling threshold value in the first calling number, and rejecting the calling requests with the number corresponding to the third calling number. For example: the call request corresponding to the call times of 501-600 is rejected.
Or, putting the call requests with the number corresponding to the third call times into a queue, and sequencing according to the priority of the call requests. As in the above example, call requests corresponding to call times 501-600 are placed in a queue, and the priority of the call requests is determined, where the priority may be ordered by time, or it may be determined that the call requests correspond to member information, such as a member level, etc.
In this embodiment, when the first call number is less than or equal to the call threshold, the interface identifier of the interface to be called is added as a key name to the ordered set in the cache, and the weight value and the key value corresponding to the interface identifier are updated to be the current timestamp in the ordered set. And adding expiration time for the interface identification of the interface to be called. The interface is prevented from being not called for a period of time, so that the memory of the cache is prevented from being too high.
In this embodiment, the interface identifier of the interface to be called is added as a key name to the ordered set in the cache, and the weight value and the key value corresponding to the interface identifier are updated to be the current timestamp in the ordered set. The time interval during which the current limit is performed and the time interval during which the current limit is not performed can be counted according to the ordered set (zset) later. Specifically, the weight value in the ordered set may be determined to be the time interval in which the current limiting operation is not performed and the time interval in which the current limiting operation is performed.
As one example, the call threshold for some service interfaces to slide a time window over a particular period of time may be determined by counting the weight values (score) of the ordered set (zset).
For example: through counting the weight value (score) of the ordered set (zset), it is determined that 90% of the sliding time window corresponding to the payment interface in 21:00-22:00 is subjected to the current limiting operation, so that the calling threshold corresponding to the sliding time window of the payment interface in 21:00-22:00 can be increased, and the user experience is ensured.
As an example, it may also be determined by counting the weight values (score) in the ordered set (zset) that certain service interfaces do not set the sliding time window for a certain period of time, or increase the length of time of the sliding time window during that period of time.
For example: by counting the weight values (score) in the ordered set (zset) over 24 hours, it can be determined that the commodity collection interface does not perform a current limit operation for 98% of the sliding time windows in the range of 2:00am-11:00 am. Thus, the length of the sliding time window of the commodity collection interface in the period of 2:00am-11:00am can be increased, or the sliding time window is not set for the commodity collection interface in the period of 2:00am-11:00 am.
As one example, it may also be determined that some service interfaces shorten the length of the sliding time window for a particular period of time by analyzing the weight values (score) in the ordered set (zset).
For example: the method has the advantages that the time length of a sliding time window of interfaces such as commodity collection, shopping cart addition, payment, order generation and the like is shortened in the early morning of shopping, and under the condition that the calling threshold value is unchanged, so that burst flow can be dealt with, and effective flow limiting is performed.
Fig. 4 is a block diagram of a service interface-based current limiting device according to an embodiment of the present application, where the device may be implemented as part or all of an electronic device by software, hardware, or a combination of both. As shown in fig. 4, the apparatus includes:
a determining module 41, configured to determine a call threshold of the interface to be called within the sliding time window;
an obtaining module 42, configured to determine a first time interval according to the current timestamp and the sliding time window;
a statistics module 43, configured to count a first number of calls of the interface to be called in a first time interval;
and an execution module 44, configured to execute the current limiting operation when the first call number is greater than the call threshold.
The embodiment of the application further provides an electronic device, as shown in fig. 5, the electronic device may include: the device comprises a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502 and the memory 1503 are in communication with each other through the communication bus 1504.
A memory 1503 for storing a computer program;
the processor 1501, when executing the computer program stored in the memory 1503, implements the steps of the above embodiments.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, pi) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also Digital signal processors (Digital SignalProcessing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
The present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the above steps.
It should be noted that, with respect to the apparatus, electronic device, and computer-readable storage medium embodiments described above, since they are substantially similar to the method embodiments, the description is relatively simple, and reference should be made to the description of the method embodiments for relevant points.
It is further noted that relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing is only a specific embodiment of the invention to enable those skilled in the art to understand or practice the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (9)

1. A service interface-based current limiting method, comprising:
determining a calling threshold value of an interface to be called in a sliding time window;
determining a first time interval according to the current time stamp and the sliding time window;
counting the first calling times of the interface to be called in the first time interval;
when the first calling times are larger than the calling threshold value, executing current limiting operation;
the method further comprises the steps of:
when the first calling times are smaller than or equal to the calling threshold value, an interface identifier of the interface to be called is used as a key name to be added into an ordered set in a cache, a weight value corresponding to the interface identifier and the key value are updated into the current timestamp in the ordered set, the weight value in the ordered set is used for determining a time duty ratio of a service interface which does not execute a current limiting operation in a specific time period, and the time duty ratio is used for updating the calling threshold value of a sliding time window corresponding to the service interface;
and determining that the service interface does not set the sliding time window in a specific time period by counting the weight values in the ordered set, or increasing the time length of the sliding time window in the specific time period, or shortening the time length of the sliding time window in the specific time period.
2. The method according to claim 1, wherein the method further comprises:
acquiring an ordered set in a cache;
and determining the sliding time window according to the weight values in the ordered set.
3. The method of claim 1, wherein determining a call threshold for the interface to be invoked within a sliding time window comprises:
acquiring an interface identifier of the interface to be called;
and inquiring the calling threshold value of the interface to be called in each sliding time window from the cache according to the interface identification.
4. A method according to claim 3, characterized in that the method further comprises:
when the calling threshold value of the interface to be called does not exist in the cache, reading the calling threshold value of the interface to be called from a database according to the interface identifier;
synchronizing the calling threshold value to the cache, and distributing expiration time for the calling threshold value.
5. The method of claim 1, wherein counting the first number of calls of the interface to be called in the first time interval comprises:
determining a second time interval from the start time to the current timestamp;
acquiring second calling times of the interface to be called in the second time interval;
calculating a third time interval obtained by subtracting the first time interval from the second time interval;
counting the third calling times of the interface to be called in the third time interval;
and calculating the difference value between the second calling times and the third calling times, and determining the first calling times according to the difference value.
6. The method of claim 1, wherein the performing a current limiting operation comprises:
refusing the call request;
or alternatively, the first and second heat exchangers may be,
and placing the call request into a queue, and sequencing according to the priority of the call request.
7. A service interface-based current limiting device, comprising:
the determining module is used for determining a calling threshold value of the interface to be called in the sliding time window;
the acquisition module is used for determining a first time interval according to the current time stamp and the sliding time window;
the statistics module is used for counting the first calling times of the interface to be called in the first time interval;
the execution module is used for executing the current limiting operation when the first calling times are larger than the calling threshold value;
the execution module is further configured to:
when the first calling times are smaller than or equal to the calling threshold value, an interface identifier of the interface to be called is used as a key name to be added into an ordered set in a cache, a weight value corresponding to the interface identifier and the key value are updated into the current timestamp in the ordered set, the weight value in the ordered set is used for determining a time duty ratio of a service interface which does not execute a current limiting operation in a specific time period, and the time duty ratio is used for updating the calling threshold value of a sliding time window corresponding to the service interface;
and determining that the service interface does not set the sliding time window in a specific time period by counting the weight values in the ordered set, or increasing the time length of the sliding time window in the specific time period, or shortening the time length of the sliding time window in the specific time period.
8. An electronic device, comprising: the device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor being adapted to carry out the method steps of any one of claims 1-6 when the computer program is executed.
9. A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, carries out the method steps of any of claims 1-6.
CN202010019040.6A 2020-01-08 2020-01-08 Service interface-based current limiting method and device, electronic equipment and storage medium Active CN111262795B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010019040.6A CN111262795B (en) 2020-01-08 2020-01-08 Service interface-based current limiting method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010019040.6A CN111262795B (en) 2020-01-08 2020-01-08 Service interface-based current limiting method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111262795A CN111262795A (en) 2020-06-09
CN111262795B true CN111262795B (en) 2024-02-06

Family

ID=70951136

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010019040.6A Active CN111262795B (en) 2020-01-08 2020-01-08 Service interface-based current limiting method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111262795B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111741016B (en) * 2020-07-23 2020-12-08 南京梦饷网络科技有限公司 Method, computing device, and computer storage medium for managing application interfaces
CN114640700B (en) * 2020-11-30 2023-04-07 腾讯科技(深圳)有限公司 Calling frequency control method and device
CN113242184A (en) * 2021-06-10 2021-08-10 京东科技控股股份有限公司 Flow control method of distributed architecture and related equipment
CN114189478B (en) * 2021-12-01 2024-04-16 浪潮云信息技术股份公司 Distributed current limiting implementation method and system based on sliding window algorithm
CN114513461A (en) * 2022-02-11 2022-05-17 联仁健康医疗大数据科技股份有限公司 Current limiting method and device, electronic equipment and storage medium
CN114679452A (en) * 2022-03-01 2022-06-28 北京金山云网络技术有限公司 Interface calling method and device, electronic equipment and storage medium
CN114844835B (en) * 2022-07-04 2022-09-20 眉山环天智慧科技有限公司 Self-adaptive dynamic current limiting method and device
CN115022244A (en) * 2022-07-20 2022-09-06 中国工商银行股份有限公司 Current limiting method and device, processor and electronic equipment
CN115543622B (en) * 2022-10-11 2024-03-12 天道金科股份有限公司 Resource use controller with counting time stamp in distributed environment and control method

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9325597B1 (en) * 2012-11-19 2016-04-26 Cox Communications, Inc. Bandwidth upgrade recommendation
CN107220856A (en) * 2017-06-02 2017-09-29 武汉大学 A kind of system and method for mobile consumption group identification
CN108073465A (en) * 2017-12-29 2018-05-25 中国平安人寿保险股份有限公司 Dynamic current limiting method, Nginx servers, storage medium and device
CN108306874A (en) * 2018-01-29 2018-07-20 口碑(上海)信息技术有限公司 Service interface accesses current-limiting method and device
CN108416591A (en) * 2018-02-28 2018-08-17 四川新网银行股份有限公司 A kind of method that transaction active current limliting is realized by api interface in financial transaction
CN108572898A (en) * 2017-03-07 2018-09-25 北京京东尚科信息技术有限公司 A kind of method, apparatus of control interface, equipment and storage medium
CN109257390A (en) * 2018-11-27 2019-01-22 杭州安恒信息技术股份有限公司 Detection method, device and the electronic equipment of CC attack
CN109714264A (en) * 2018-09-03 2019-05-03 天翼电子商务有限公司 The implementation method of sliding window current limliting based on buffer queue
CN110166371A (en) * 2019-05-16 2019-08-23 北京达佳互联信息技术有限公司 Flow control methods, device, electronic equipment and storage medium
CN110471944A (en) * 2018-05-11 2019-11-19 北京京东尚科信息技术有限公司 Indicator-specific statistics method, system, equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080005391A1 (en) * 2006-06-05 2008-01-03 Bugra Gedik Method and apparatus for adaptive in-operator load shedding
US10616271B2 (en) * 2017-01-03 2020-04-07 Microsemi Frequency And Time Corporation System and method for mitigating distributed denial of service attacks
US10581745B2 (en) * 2017-12-11 2020-03-03 International Business Machines Corporation Dynamic throttling thresholds

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9325597B1 (en) * 2012-11-19 2016-04-26 Cox Communications, Inc. Bandwidth upgrade recommendation
CN108572898A (en) * 2017-03-07 2018-09-25 北京京东尚科信息技术有限公司 A kind of method, apparatus of control interface, equipment and storage medium
CN107220856A (en) * 2017-06-02 2017-09-29 武汉大学 A kind of system and method for mobile consumption group identification
CN108073465A (en) * 2017-12-29 2018-05-25 中国平安人寿保险股份有限公司 Dynamic current limiting method, Nginx servers, storage medium and device
CN108306874A (en) * 2018-01-29 2018-07-20 口碑(上海)信息技术有限公司 Service interface accesses current-limiting method and device
CN108416591A (en) * 2018-02-28 2018-08-17 四川新网银行股份有限公司 A kind of method that transaction active current limliting is realized by api interface in financial transaction
CN110471944A (en) * 2018-05-11 2019-11-19 北京京东尚科信息技术有限公司 Indicator-specific statistics method, system, equipment and storage medium
CN109714264A (en) * 2018-09-03 2019-05-03 天翼电子商务有限公司 The implementation method of sliding window current limliting based on buffer queue
CN109257390A (en) * 2018-11-27 2019-01-22 杭州安恒信息技术股份有限公司 Detection method, device and the electronic equipment of CC attack
CN110166371A (en) * 2019-05-16 2019-08-23 北京达佳互联信息技术有限公司 Flow control methods, device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
微服务接口限流的设计、思考;蹲在角落数蚂蚁;《CSDN》;第1-7页 *

Also Published As

Publication number Publication date
CN111262795A (en) 2020-06-09

Similar Documents

Publication Publication Date Title
CN111262795B (en) Service interface-based current limiting method and device, electronic equipment and storage medium
CN109936511B (en) Token obtaining method, device, server, terminal equipment and medium
CN110162270B (en) Data storage method, storage node and medium based on distributed storage system
CN110188990B (en) Resource request and fund request splitting method, device and equipment
CN108306874B (en) Service interface access current limiting method and device
CN108647240B (en) Method and device for counting access amount, electronic equipment and storage medium
CN110716794B (en) Information processing method, device, system and readable storage medium
CN111381988A (en) Request speed limiting method and device, electronic equipment and storage medium
CN111835536B (en) Flow prediction method and device
WO2017211265A1 (en) Speed limiting method and apparatus, and storage medium
CN114422439A (en) Interface current limiting method and device, computer equipment and storage medium
CN108920326B (en) Method and device for determining time-consuming abnormity of system and electronic equipment
US20190268271A1 (en) Dynamic rate limiting for networked resources
CN116737084A (en) Queue statistics method and device, electronic equipment and storage medium
CN115277588B (en) Fusing current limiting system based on middle platform system
CN110750498B (en) Object access method, device and storage medium
CN111324477A (en) Processing method and device for distributed fusing
CN110377533B (en) Cache replacement method and device for cloud computing and edge computing
CN112667396A (en) Access request processing method, device and system
CN110955681B (en) Information processing method and device, electronic equipment and storage medium
CN113467924A (en) Resource allocation method, device, server and computer readable storage medium
CN113630332B (en) Distributed multistage dynamic current limiting method and system
CN113572824B (en) Dynamic updating method and device for timeout duration, electronic equipment and storage medium
CN111026734B (en) Database management method, system, device and storage medium
CN114844838B (en) Flow control method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Digital Technology Holding Co.,Ltd.

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Digital Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant