WO2023036188A1 - 访问限流方法、装置、设备、存储介质及计算机程序产品 - Google Patents

访问限流方法、装置、设备、存储介质及计算机程序产品 Download PDF

Info

Publication number
WO2023036188A1
WO2023036188A1 PCT/CN2022/117590 CN2022117590W WO2023036188A1 WO 2023036188 A1 WO2023036188 A1 WO 2023036188A1 CN 2022117590 W CN2022117590 W CN 2022117590W WO 2023036188 A1 WO2023036188 A1 WO 2023036188A1
Authority
WO
WIPO (PCT)
Prior art keywords
access
interface
access request
request
target access
Prior art date
Application number
PCT/CN2022/117590
Other languages
English (en)
French (fr)
Inventor
陈录城
官祥臻
孙来超
刘杰
杨轩
张永庆
Original Assignee
海尔数字科技(青岛)有限公司
卡奥斯工业智能研究院(青岛)有限公司
海尔卡奥斯物联科技有限公司
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 海尔数字科技(青岛)有限公司, 卡奥斯工业智能研究院(青岛)有限公司, 海尔卡奥斯物联科技有限公司 filed Critical 海尔数字科技(青岛)有限公司
Publication of WO2023036188A1 publication Critical patent/WO2023036188A1/zh
Priority to US18/233,197 priority Critical patent/US20230388235A1/en

Links

Images

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/12Avoiding congestion; Recovering from congestion
    • 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/20Traffic policing

Definitions

  • the present application relates to communication technology, and in particular to an access limiting method, device, equipment, storage medium and computer program product.
  • the current limiting components of existing network requests are all positive current limiting, that is, when the traffic exceeds a certain amount, the current limiting starts, so as to limit the speed of concurrent requests within a time window to protect the communication system.
  • the rate of all requests is limited within the time window, the success rate of the user accessing the interface is low.
  • the present application provides an access current limiting method, device, equipment, storage medium and computer program product, which can improve the success rate of user access interface while ensuring the stable operation of the system.
  • the present application provides a method for limiting access, including:
  • the target access request is sent to the access interface.
  • judging the number of target access requests received within a preset time period includes:
  • the target access request is not a request for accessing the access interface for the first time, then determine the number of times the target access request is received within a preset time period.
  • the method further includes:
  • the access interface is prohibited from receiving the target access request.
  • the method further includes:
  • intercepting the target access request sent by the terminal device outside the access interface includes:
  • the target access request is intercepted outside the access interface.
  • an access limiting device including:
  • An interception module configured to, for each terminal device, intercept target access requests sent by the terminal device outside the access interface when it is detected that the number of access requests sent by multiple terminal devices to the access interface exceeds a first preset value
  • a judging module configured to judge the number of target access requests received within a preset time period
  • a sending module configured to send the target access request to the access interface when the number of times is greater than the second preset value.
  • the judging module is specifically used for:
  • the target access request is not a request for accessing the access interface for the first time, then determine the number of times the target access request is received within a preset time period.
  • the sending module is also used to:
  • the target access request is a request to access the access interface for the first time, it is used to send the target access request to the access interface.
  • the device further includes: a processing module
  • a processing module configured to prohibit the access interface from receiving target access requests when the number of times is not greater than a second preset value.
  • the device further includes: an update module
  • An update module configured to update the number of times the target access request is received.
  • the interception module is specifically used for:
  • the target access request is intercepted outside the access interface.
  • the embodiment of the present application also provides a server, where the server may include a processor and a memory; wherein,
  • Memory used to store computer programs.
  • the processor is configured to read the computer program stored in the memory, and execute the access current limiting method in any possible implementation manner of the first aspect above according to the computer program in the memory.
  • the embodiment of the present application also provides a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and when the processor executes the computer-executable instructions, any possible solution of the above-mentioned first aspect can be realized.
  • the access limit method in the implementation mode is not limited to.
  • the embodiment of the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, implements the access restriction method in any possible implementation manner of the above-mentioned first aspect.
  • the access current limiting method, device, device, storage medium, and computer program product provided in the embodiments of the present application, when the number of access requests sent by multiple terminal devices to the access interface exceeds the first preset value, for each terminal The device intercepts the target access request sent by the terminal device outside the access interface, and then judges the number of times the target access request is received within a preset time period, and if the number of times is greater than the second preset value, sends the target access request to the access interface.
  • a current limiting component will be set outside the access interface, and the target access request sent by the terminal device will be intercepted through the current limiting method.
  • the target access request exceeds the second within the preset time
  • the default value indicates that the user urgently needs to access the access interface.
  • the current limiting component will release the access request to call the access interface. This can prevent the system from rejecting all access requests due to frequent access requests sent by individuals, thereby improving the success rate of user access on the premise of stable system operation.
  • FIG. 1 is a system architecture diagram of the access current limiting method provided by the embodiment of the present application.
  • FIG. 2 is a schematic flow diagram of an access limiting method provided in an embodiment of the present application.
  • Fig. 3 is a schematic diagram of the process of the server intercepting the target access request outside the access interface
  • FIG. 4 is a schematic diagram of a process of receiving an access request through a sliding window provided in an embodiment of the present application
  • FIG. 5 is a schematic flowchart of a method for limiting the flow of an access interface provided by an embodiment of the present application
  • FIG. 6 is a schematic structural diagram of an access current limiting device provided in an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a server provided by an embodiment of the present application.
  • Current limiting refers to limiting the rate of data traffic. It is a network traffic management technology of a computer network, thereby delaying some or all data packets to make it comply with the network traffic rules required by users.
  • Current limiting component refers to a component that includes a certain current limiting method or rule to limit the frequency of interface access to reduce the pressure on the server.
  • the access current limiting method provided in the embodiment of the present application can be applied to a scenario where a high-concurrency business system encounters a large number of frequent requests and needs to perform current limiting.
  • Existing current limiting methods mainly include leaky bucket method, token bucket method, counter method and sliding window method, etc.
  • the leaky bucket method assumes that the server’s ability to process requests is a bucket. When a request comes, the request is first placed in the bucket, and the server processes the request by taking out the request from the bucket at a fixed rate for corresponding processing. If the bucket is full, that is, the processing capacity of the server is reached, the new incoming request is refused to be served. In the face of burst traffic, the leaky bucket algorithm will cause a large number of request failures.
  • the token bucket method is to add tokens to the bucket at a constant speed, and no longer add tokens when the bucket is full.
  • the service When the service receives the request, it tries to take out a token from the bucket, and if the token can be obtained, it continues to execute subsequent business logic. If the token is not obtained, directly return the error code or page that the access frequency exceeds the limit, etc., and do not continue to execute subsequent business logic.
  • the idea of the counter algorithm is to count requests within a fixed time window, and compare it with the threshold to determine whether current limiting is required. Once the time critical point is reached, the counter will be cleared to zero. There is a "time critical point" defect, causing the system to appear instantaneously. Crash due to double traffic.
  • the sliding window method is to divide a large time window into multiple small windows, each time the large window slides a small window backward, and ensures that the flow in the large window will not exceed the maximum value to achieve current limiting.
  • the current limiting starts after the number of access requests exceeds the processing capacity of the server, and during the current limiting process, the server will refuse to receive all access requests sent by all users, resulting in The success rate of users accessing service interfaces is low, resulting in poor user experience.
  • the terminal device will call the third-party logistics interface to refresh the logistics status.
  • the access requests sent will be restricted by the third-party interface, and all access requests sent by users will be denied service for a period of time thereafter, resulting in the logistics of all users
  • the status cannot be queried and refreshed, which will lead to a low success rate of users accessing the service interface and bring users a bad user experience.
  • the embodiment of the present application proposes an access limiting method, device, equipment, storage medium, and computer program product.
  • the access current limiting method provided by the embodiment of the present application, in this method, when multiple users use terminal devices and send access requests to the access interface concurrently, the access requests of each terminal device are limited.
  • the access interface is allowed to be called, otherwise, the access flow limit is implemented.
  • the deficiencies of the leaky bucket and the token bucket in the prior art can be made up for, and the impact of a large number of access requests in a short period of time can be resisted.
  • the flow of access requests is limited by the number of access requests within a preset time period, so as to provide a stable and efficient flow control for access requests in the network and improve the success rate of user access interfaces.
  • FIG. 1 is a system architecture diagram of an access limiting method provided by an embodiment of the present application.
  • the system includes a terminal device 11 , a terminal device 12 , a terminal device 13 and a server 15 .
  • the network 14 provides a communication link medium between the terminal device 11 , the terminal device 12 , the terminal device 13 and the server 15 .
  • the user can use the terminal device 11 , the terminal device 12 , and the terminal device 13 to interact with the server 15 through the network 14 to receive or send messages and the like.
  • the user can log in to the application operation interface on each terminal device through the terminal device 11, terminal device 12 or terminal device 13 to send various instructions or information to each terminal device, and each terminal device is based on the instructions or information sent by the user. , and send an access request to the server 15.
  • the server 15 If the server 15 receives the number of access requests sent by the terminal device 11, terminal device 12 or terminal device 13 at the same time within a preset period of time exceeding the first preset value, the server 15 will send the access request to the access interface. Intercept access requests sent by each terminal device. After the interception, the server 15 will determine the number of access requests received from each terminal device within the preset time period. Assuming that the number of access requests sent by the terminal device 11 exceeds the second preset value, it means that the user corresponding to the terminal device 11 has an urgent need to access the access interface. At this time, the target access request will be sent to the access interface. Moreover, the server intercepts the access requests sent by the terminal devices whose number of access requests does not exceed the second preset value, so as to achieve the purpose of current limiting.
  • the number of users, terminal equipment 11, terminal equipment 12, terminal equipment 13, network 14 and server 15 in the above system architecture is only exemplary, and more or less numbers all belong to the scope of protection of this application .
  • the terminal device 11, the terminal device 12, and the terminal device 13 may be, for example, a personal computer, a server, a tablet, a mobile phone, a PDA, a notebook, or any other computing device with a networking function.
  • the server 15 can be realized by using a server or server group with stronger processing capability and higher security.
  • the network 14 used between them can include various types of wired and wireless networks, such as but not limited to: Internet, local area network, WIFI, WLAN, cellular communication network (GPRS, CDMA, 2G/3G/4G/5G cellular network), satellite communication network, etc.
  • wired and wireless networks such as but not limited to: Internet, local area network, WIFI, WLAN, cellular communication network (GPRS, CDMA, 2G/3G/4G/5G cellular network), satellite communication network, etc.
  • FIG. 2 is a schematic flow diagram of an access current limiting method provided by the embodiment of the present application.
  • the embodiment of the present application provides an access current limiting method, which can be executed by any device that implements the access current limiting method, and the device can Implemented by software and/or hardware.
  • the device may be integrated in the server 15 shown in FIG. 1 .
  • the access current limiting method provided by the embodiment of the present application includes the following steps:
  • Step 201 When it is detected that the number of access requests sent by multiple terminal devices to the access interface exceeds a first preset value, for each terminal device, intercept the target access requests sent by the terminal device outside the access interface.
  • the first preset value may be set according to the number of access requests that the server can handle, and the embodiment of the present application does not make any limitation on the specific value of the first preset value.
  • the server intercepts the target access request sent by the terminal device before the target access request is sent to the access interface.
  • the interception usually uses the added flow limiting method or rule to prevent the newly generated access request from directly calling the access interface.
  • FIG 3 is a schematic diagram of the server intercepting target access requests outside the access interface.
  • the server when the server receives access requests sent by multiple users using terminal devices at the same time, the server will create an ID for each terminal device with a different id. Isolated sliding window.
  • the access request in the sliding window will pass through the current limiting component, and the current limiting component will judge whether to pass the target access request to call the access interface according to the internal access current limiting method and rules.
  • the current limiting component includes the set access current limiting methods and rules.
  • the sliding window refers to dividing a period of time window into a plurality of small grids with equal time intervals, maintaining a counter in each small grid, and moving a small grid backward every interval of a small grid.
  • the isolated sliding window means that each terminal device with a different id has a sliding window independent of each other, that is, to prevent all the sliding windows of other id terminal devices from being consumed and occupying the sliding window of the id terminal device.
  • Each sliding window stores the access requests sent by the terminal device received by the server, and the number of access requests that the sliding window can accept is certain, for example, a time window is 60s.
  • the access requests received by the server are stored in the sliding window shown in FIG. 3 .
  • the process of receiving access requests by the sliding window shown in FIG. 3 will be described in conjunction with the embodiment shown in FIG. 4 .
  • a period of time window is set.
  • the period of time window is divided into time periods with equal time intervals, and the length of the sliding window is the same as the length of the period of time window.
  • the number of access requests to the access interface cannot exceed the threshold for processing requests by the server.
  • a dotted line box 401 represents a sliding window
  • a solid line box 402 represents a small time unit
  • a small time unit 403 filled with oblique lines represents an access request received within this time unit
  • the arrow 404 represents the moving direction of the sliding window.
  • the length of the window for a period of time is N, and the time window is divided into several small time units at equal intervals.
  • the length of one time unit is n, and every time unit n, the sliding window moves forward for one hour. unit.
  • the number of processing requests in a sliding window is certain, and access requests exceeding the number of processing access requests in a sliding window will be subject to access restriction.
  • the size of a period of time window is set to 60 seconds, and the time window is divided into 4 small time units, each of which is 15 seconds, and the number of access requests to the access interface in any sliding window of 60 seconds is equal to Cannot be greater than 1000 requests.
  • 1000 requests can also be split and enter the sliding window in batches. For example, in the first 60-second time window, 400 access requests are entered in a small time unit of 15 seconds, and 600 access requests are entered in a small time unit of 45 seconds, then after 15 seconds, the sliding window moves forward for a one-time unit. 400 access requests can be received again.
  • the sliding window can realize the process of receiving new requests.
  • intercepting the target access request sent by the terminal device outside the access interface may be to obtain the interface configuration information of the access interface when it is detected that the terminal device sends the target access request to the access interface, and determine whether the interface configuration information includes Current limiting configuration information, if the interface configuration information includes current limiting configuration information, the target access request will be intercepted outside the access interface.
  • FIG. 5 can be used to describe the process of whether the access interface requires current limiting.
  • the specific process is as follows:
  • Step 501 Obtain interface configuration information of an access interface.
  • Step 502 Determine whether the access interface configuration information includes current limiting configuration information.
  • Step 503 If the access interface configuration information includes current limiting configuration information, intercept the target access request outside the access interface.
  • Step 504 If the access interface configuration information does not include current limiting configuration information, do not intercept the target access request.
  • the configuration information in the access interface is the configuration contained in the access interface, for example, the configuration information of the access interface includes current limiting configuration information.
  • the configuration information of the access interface includes current limiting configuration information.
  • Step 202 Determine the number of target access requests received within a preset time period.
  • the preset time period usually includes a sliding time window.
  • the server when the user accesses the interface through the terminal device, after receiving the target access request sent by the terminal device, the server will determine the number of times the target access request is received within the aforementioned preset time period.
  • the number of times the server receives target access requests within a preset time period can also be understood as the number of times the terminal device sends target access requests to the server within a preset time period.
  • the server may acquire the number of times of the target access request locally, or may acquire the number of times of the target access request from the flow limiting server.
  • the server can first judge whether the target access request is a request for a non-first access interface, if the target access request is a non-first access request for the access interface , then determine the number of times the target access request is received within the preset time period; if the target access request is the first access request to the access interface, then send the target access request to the access interface.
  • the server will create an independent sliding window corresponding to the user, and the request needs to pass through the current limiting component before accessing the access interface.
  • the component can directly let go the target access request according to its internally added flow limiting method or rule, so that the target access request can access the above access interface once.
  • the user's access request at this time is not a request for accessing the access interface for the first time. Firstly, if there is not enough request processing capacity in the sliding window, the request will be directly rejected; if there is sufficient request processing capacity in the sliding window, after receiving the request, start the counter to count the number of times the request access interface is requested within the preset time.
  • the current limiting component can judge whether to release the target access request access interface based on the counted times.
  • judging whether it is the first request to access the access interface can ensure that each user can successfully access the access interface under the condition that multiple users make concurrent requests at the same time, so as to avoid the problem caused by one Users frequently send access requests and block the system, causing the system to limit traffic and reject all access requests, further improving the success rate of user access and improving user experience.
  • Step 203 If the number of times is greater than the second preset value, send the target access request to the access interface.
  • the second preset value refers to the maximum number of access interfaces set by the current limiting method or rule contained in the current limiting component within the preset time period, and its value can be set according to the actual situation or experience.
  • the specific value of the value is not limited in this embodiment of the present application.
  • the server receives and processes the access request sent by the terminal device, and the server's ability to handle concurrent access requests is measured by throughput, so any server has a threshold of its ability to handle concurrent access requests.
  • the current limiting method or rule set in the current limiting component can be set at the first time in the sliding window. Two default values.
  • the flow limit The component executes the release rule so that the target access request visits the access interface once, that is, the server will send the target access request to the access interface, and at the same time reset or update the number of times the target access request is received in the sliding window, so that the user can be guaranteed After successfully accessing the access interface, the system will not limit the current due to repeated calls to the access interface, thereby further improving the access success rate of each user and saving system resources.
  • the access interface When the number of times the target access request is received within a sliding window time is not greater than the second preset value, the access interface is prohibited from receiving the target access request, that is, the access of the target access request to the access interface is intercepted, and the downgrading method is executed, and The number of times the target access request is received is incremented by 1. It should be noted that, if the number of requests made by the target access request to the access interface does not exceed the second preset value after the set sliding window time has elapsed, the access requests within the sliding window are deleted.
  • the downgrading method is to specify different levels of access requests, and perform different processing in the face of different exception levels.
  • service mode service can be refused, service can be delayed, and sometimes service can be random.
  • used sliding windows will always exist in system resources, and in order to protect system resources, it is also necessary to destroy unnecessary sliding windows. For example, when it is determined that a sliding window has not been used for a long time, a custom event is sent to the custom spring event listener, and the listener is responsible for removing the sliding window instance.
  • the access current limiting method, device, device, storage medium, and computer program product provided in the embodiments of the present application, when the number of access requests sent by multiple terminal devices to the access interface exceeds the first preset value, for each terminal The device intercepts the target access request sent by the terminal device outside the access interface, and then judges the number of times the target access request is received within a preset time period, and if the number of times is greater than the second preset value, sends the target access request to the access interface.
  • a current limiting component will be set outside the access interface, and the target access request sent by the terminal device will be intercepted through the current limiting method.
  • the target access request exceeds the second within the preset time
  • the default value indicates that the user urgently needs to access the access interface.
  • the current limiting component will release the access request to call the access interface. This can prevent the system from rejecting all access requests due to frequent access requests sent by individuals, thereby improving the success rate of user access on the premise of stable system operation.
  • FIG. 6 is a schematic structural diagram of an access current limiting device 60 provided in an embodiment of the present application.
  • the access current limiting device 60 may include:
  • the interception module 601 is configured to, for each terminal device, intercept the target access request sent by the terminal device outside the access interface when it is detected that the number of access requests sent by multiple terminal devices to the access interface exceeds a first preset value;
  • Judging module 602 configured to judge the number of times target access requests are received within a preset time period
  • a sending module 603, configured to send the target access request to the access interface when the number of times is greater than a second preset value.
  • the judging module 602 is specifically configured to:
  • the target access request is not a request for accessing the access interface for the first time, then determine the number of times the target access request is received within a preset time period.
  • the sending module 603 is specifically configured to:
  • the target access request is a request to access the access interface for the first time, it is used to send the target access request to the access interface.
  • the device further includes: a processing module 604;
  • the processing module 604 is configured to prohibit the access interface from receiving the target access request when the number of times is not greater than the second preset value.
  • the device further includes: an update module 605;
  • An update module 605, configured to update the number of times the target access request is received.
  • the interception module 601 is specifically used for:
  • the target access request is intercepted outside the access interface.
  • the access current limiting device 60 provided in the embodiment of the present application can implement the technical solution of the access current limiting method in any of the above embodiments, and its implementation principle and beneficial effects are similar to those of the access current limiting method. The implementation principle and beneficial effect of the current limiting method will not be repeated here.
  • FIG. 7 is a schematic structural diagram of a server 70 provided in an embodiment of the present application.
  • the server may include a processor 701 and a memory 702 . in,
  • the memory 702 is used for storing computer programs.
  • the processor 701 is configured to read the computer program stored in the memory 702, and execute the technical solution of the access restriction method in any of the above-mentioned embodiments according to the computer program in the memory 702.
  • the memory 702 can be independent or integrated with the processor 701 .
  • the server may further include: a bus for connecting the memory 702 and the processor 701 .
  • this embodiment further includes: a communication interface, where the communication interface may be connected to the processor 701 through a bus.
  • the processor 701 may control the communication interface to implement the functions of acquiring and sending from the server.
  • the server shown in the embodiment of the present application can implement the technical solution of the access current limiting method in any of the above embodiments, and its implementation principle and beneficial effect are similar to those of the access current limiting method. Please refer to the access current limiting method The realization principle and beneficial effect of the method will not be repeated here.
  • the embodiment of the present application also provides a computer-readable storage medium.
  • Computer-executable instructions are stored in the computer-readable storage medium. When the computer-executable instructions are executed by a processor, they are used to implement the access current limiting method in any of the above-mentioned embodiments.
  • Technical solutions are provided.
  • the embodiment of the present application also provides a computer program product, including a computer program.
  • a computer program product including a computer program.
  • the computer program When the computer program is executed by a processor, it realizes the technical solution of the access current limiting method in any of the above embodiments, and its implementation principle and beneficial effects are similar to those of access
  • the implementation principle and beneficial effects of the current limiting method are similar, and reference may be made to the implementation principle and beneficial effects of the access current limiting method, which will not be repeated here.
  • the disclosed devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be combined or integrated. to another system, or some features may be ignored, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • a unit described as a separate component may or may not be physically separated, and a component shown as a unit may or may not be a physical unit, that is, it may be located in one place, or may also be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware, or in the form of hardware plus software functional units.
  • the above-mentioned integrated modules implemented in the form of software function modules can be stored in a computer-readable storage medium.
  • the above-mentioned software function modules are stored in a storage medium, and include several instructions to enable a computer device (which may be a personal computer, server, or network device, etc.) or a processor (English: processor) to execute the methods of the various embodiments of the present application. partial steps.
  • processor can be a central processing unit (English: Central Processing Unit, referred to as: CPU), and can also be other general-purpose processors, digital signal processors (English: Digital Signal Processor, referred to as: DSP), dedicated Integrated circuit (English: Application Specific Integrated Circuit, referred to as: ASIC), etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the method disclosed in conjunction with the invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.
  • the storage may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk storage, and may also be a U disk, a mobile hard disk, a read-only memory, a magnetic disk, or an optical disk.
  • NVM non-volatile storage
  • the bus can be an Industry Standard Architecture (Industry Standard Architecture, ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus, etc.
  • ISA Industry Standard Architecture
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • the bus can be divided into address bus, data bus, control bus and so on.
  • the buses in the drawings of the present application are not limited to only one bus or one type of bus.
  • the above-mentioned computer-readable storage medium can be realized by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM) , Erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic Disk or Optical Disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read-only memory
  • EPROM Erasable Programmable Read Only Memory
  • PROM Programmable Read Only Memory
  • ROM Read Only Memory
  • Magnetic Memory Flash Memory
  • Magnetic Disk Magnetic Disk
  • Optical Disk Optical Disk

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Storage Device Security (AREA)

Abstract

本申请提供一种访问限流方法、装置、设备、存储介质及计算机程序产品。该方法包括:当检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在访问接口外拦截终端设备发送的目标访问请求;判断预设时间段内接收到目标访问请求的次数;若次数大于第二预设值,则将目标访问请求发送给访问接口。本申请能够提高用户访问接口的成功率。

Description

访问限流方法、装置、设备、存储介质及计算机程序产品
本申请要求于2021年09月09日提交中国专利局、申请号为202111056431.6、申请名称为“访问限流方法、装置、设备、存储介质及计算机程序产品”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及通信技术,尤其涉及一种访问限流方法、装置、设备、存储介质及计算机程序产品。
背景技术
在互联网应用中经常会出现突发流量洪峰的情况,而任何系统的处理能力均有上限,当请求量超过系统处理能力时,通常会引起排队,造成响应时间迅速提升。如果对服务占用的资源量没有约束,还可能因为系统资源占用过多而宕机。为了保证系统在遭遇突发请求时能够稳定运行,业界通常采用的手段有缓存、限流或降级,其中,限流是当请求流量超过系统的瓶颈时,可进行拒绝服务、排队或等待、降级等处理的方式。
现有网络请求的限流组件均为正向限流,即当流量超过一定数量后开始进行限流,从而对一个时间窗口内的并发请求进行限速,以保护通信系统。然而在上述方法中,由于在该时间窗口内会对所有的请求均会限速,导致用户访问接口的成功率较低。
发明内容
本申请提供一种访问限流方法、装置、设备、存储介质及计算机程序产品,可以在保证系统稳定运行的同时,提高用户访问接口的成功率。
第一方面,本申请提供一种访问限流方法,包括:
当检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在访问接口外拦截终端设备发送的目标访问请求;
判断预设时间段内接收到目标访问请求的次数;
若次数大于第二预设值,则将目标访问请求发送给访问接口。
在一种可能的实现方式中,判断预设时间段内接收到目标访问请求的次数,包括:
判断目标访问请求是否为非首次访问访问接口的请求;
若目标访问请求为非首次访问访问接口的请求,则判断预设时间段内接收到目标访问请求的次数。
在一种可能的实现方式中,方法还包括:
若次数不大于第二预设值,则禁止访问接口接收目标访问请求。
在一种可能的实现方式中,将目标访问请求发送给访问接口之后,方法还包括:
更新接收到目标访问请求的次数。
在一种可能的实现方式中,在访问接口外拦截所述终端设备发送的目标访问请求,包括:
获取访问接口的接口配置信息;
判断接口配置信息中是否包括限流配置信息;
若接口配置信息中包括限流配置信息,则在访问接口外拦截目标访问请求。
第二方面,本申请提供一种访问限流装置,包括:
拦截模块,用于在检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在访问接口外拦截终端设备发送的目标访问请求;
判断模块,用于判断预设时间段内接收到目标访问请求的次数;
发送模块,用于在次数大于第二预设值时,将目标访问请求发送给访问接口。
在一种可能的实现方式中,判断模块,具体用于:
判断目标访问请求是否为非首次访问访问接口的请求;
若目标访问请求为非首次访问访问接口的请求,则判断预设时间段内接收到目标访问请求的次数。
在一种可能的实现方式中,发送模块,还用于:
若目标访问请求为首次访问访问接口的请求,用于将目标访问请求发送给访问接口。
在一种可能的实现方式中,该装置还包括:处理模块;
处理模块,用于在次数不大于第二预设值时,禁止访问接口接收目标访问请求。
在一种可能的实现方式中,该装置还包括:更新模块;
更新模块,用于更新接收到目标访问请求的次数。
在一种可能的实现方式中,拦截模块,具体用于:
获取访问接口的接口配置信息;
判断接口配置信息中是否包括限流配置信息;
若接口配置信息中包括限流配置信息,则在访问接口外拦截目标访问请求。
第三方面,本申请实施例还提供了一种服务器,该服务器可以包括处理器和存储器;其中,
存储器,用于存储计算机程序。
处理器,用于读取存储器存储的计算机程序,并根据存储器中的计算机程序执行上述第一方面任一种可能的实现方式中的访问限流方法。
第四方面,本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,当处理器执行计算机执行指令时,实现上述第一方面任一种可能的实现方式中的访问限流方法。
第五方面,本申请实施例还提供了一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时,实现上述第一方面任一种可能的实现方式的访问限流方法。
本申请实施例提供的访问限流方法、装置、设备、存储介质及计算机程序产品,通过检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在访问接口外拦截终端设备发送的目标访问请求,然后判断预设时间段内接收到目标访问请求的次数,若次数大于第二预设值,则将目标访问请求发送给访问接口。在大批量并发访问请求的场景下,会针对每一个终端设备,在 访问接口外设置限流组件,通过限流方法拦截终端设备发送的目标访问请求,在预设时间内目标访问请求超过第二预设值,表示用户迫切需求访问该访问接口,此时限流组件会放行访问请求去调用访问接口。这样可以避免因个人频繁发送访问请求,导致系统开启限流而拒绝所有访问请求,从而在系统稳定运行的前提下提高用户访问的成功率。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。附图为:
图1为本申请实施例提供的访问限流方法的系统架构图;
图2为本申请实施例提供的一种访问限流方法的流程示意图;
图3为服务器在访问接口外拦截目标访问请求的过程示意图;
图4为本申请实施例提供的一种滑动窗口接收访问请求的过程示意图;
图5为本申请实施例提供的一种对访问接口是否限流的方法的流程示意图;
图6为本申请实施例提供的一种访问限流装置的结构示意图;
图7为本申请实施例提供的一种服务器的结构示意图。
通过上述附图,已示出本申请明确的实施例,后文中将有更详细的描述。这些附图和文字描述并不是为了通过任何方式限制本申请构思的范围,而是通过参考特定实施例为本领域技术人员说明本申请的概念。
具体实施方式
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。
为了帮助本领域技术人员更好地理解本申请的技术方案,下面将对本申请技术方案中涉及的相关内容进行介绍。
限流:是指限制数据流量的速率。是一个计算机网络的网络交通管理技术,从而延缓部分或所有数据包,使之符合用户所需的网络交通规则。
限流组件:是指包含某种限流方法或规则,对接口访问的频次进行限制,以减轻服务器压力的组件。
本申请实施例提供的访问限流方法,可以应用于高并发业务系统在遭遇大量频繁请求而需要进行限流的场景中。在高并发场景下,可以通过限流的方式对一个时间窗口内的并发请求进行限速,从而达到保护系统的目的。
现有的限流方法主要包括漏桶方法、令牌桶方法、计数器方法以及滑动窗口方法等。其中漏桶方法是将服务器处理请求的能力假设为一个桶,当有请求到来时,先将请求放到木桶中,服务器处理请求是以固定的速率从木桶中取出请求进行相应的处理。如果木桶满了,即到达了服务器的处理能力则拒绝服务新到的请求。在面对突发流量时,漏桶算法会出现大量请求失败的问题。令牌桶方法是以恒定的速度往木桶里加入令牌,木桶满了则不再加入令牌。服务收到请求时尝试从木桶中取出一个令牌,如果能够得到令牌则继续执行后续的业务逻辑。如果没有得到令牌,直接返回访问频率超限的错误码或页面等,不继续执行后续的业务逻辑。计数器算法其思想是在固定时间窗口内对请求进行计数,与阀值进行比较判断是否需要限流,一旦到了时间临界点,将计数器清零,存在“时间临界点”缺陷,导致系统出现瞬时双倍流量而崩溃。滑动窗口方法则是将一个大的时间窗口分成多个小窗口,每次大窗口向后滑动一个小窗口,并保证大的窗口内流量不会超出最大值以实现限流。
然而,不论是上述的哪一种限流方法,均是在访问请求的数量超过服务器处理能力后开始进行限流,而且在限流过程中,服务器将拒绝接收所有用户发送的所有访问请求,造成用户访问业务接口的成功率较低,导致用户体验较差。
以购物系统中用户需在购物应用程序(Application,APP)的订单列表中查看物流状态信息为例,当用户通过终端设备访问自己的订单列表时,若订单中已经添加了物流单号,但是后台还没有刷新到该订单的物流状态时,终端设备将会调用第三方物流接口刷新物流状态。 在这个过程中,当用户访问频率太过频繁时,发送的访问请求将会被第三方接口限制,而且在此后的一段时间内所有用户发出的访问请求都被拒绝服务,从而导致所有用户的物流状态都无法查询及刷新,将会导致用户访问业务接口的成功率较低,给用户带来不好的用户体验。有鉴于此,本申请实施例提出了一种访问限流方法、装置、设备、存储介质及计算机程序产品。
本申请实施例提供的访问限流方法,在该方法中,当多用户使用终端设备并发向访问接口发出访问请求时,会对每一个终端设备的访问请求进行限流。当在一个预设时间段内,统计滑动窗口内接收到目标访问请求的次数,当次数大于设定的预设值便允许调用访问接口,否则便执行访问限流。
通过这种方式,能够弥补现有技术中漏桶和令牌桶的不足,抵御短时间内的大量访问请求冲击。通过在预设时间段内访问请求的次数来对访问请求进行限流,从而为网络中访问请求提供一个稳定、高效的流量控制,提高用户访问接口的成功率。
图1为本申请实施例提供的一种访问限流方法的系统架构图,如图1所示,该系统中包括终端设备11、终端设备12、终端设备13与服务器15。其中,网络14为终端设备11、终端设备12、终端设备13和服务器15之间提供通信链路介质。用户可以使用终端设备11、终端设备12、终端设备13通过网络14与服务器15交互,以接收或发送消息等。
示例性的,用户可以通过终端设备11、终端设备12或终端设备13登录各终端设备上的应用操作界面,以向各终端设备发送各种指令或者信息,各终端设备基于用户发送的指令或者信息,向服务器15发送访问请求。
若服务器15在预设时间段内,同时接收到终端设备11、终端设备12或终端设备13发送的访问请求的数量超过第一预设值时,服务器15将会在访问请求发送至访问接口之前拦截各终端设备发送的访问请求。拦截之后,服务器15将判断在该预设时间段内接收到各个终端设备发送的访问请求的次数。假设终端设备11发送访问请求的次数超过第二预设值,则说明终端设备11对应的用户访问该访问接口的需求非常急迫,此时,会将目标访问请求发送给访问接口。并且,服务器将 访问请求的次数未超过第二预设值的终端设备发送的访问请求进行拦截,从而得到限流的目的。
应该理解,在上述系统架构中的用户、终端设备11、终端设备12、终端设备13、网络14与服务器15的数目仅仅是示例性的,更多或更少的数量都属于本申请的保护范畴。并且,在上述系统中,终端设备11、终端设备12、终端设备13例如可以是个人计算机、服务器、平板、手机、PDA、笔记本或其它任何具有联网功能的计算设备。而服务器15则可以利用具有更强大处理能力和更高安全性的一个服务器或服务器组来实现。而它们之间所使用的网络14可以包括各种类型的有线和无线网络,例如但不局限于:互联网、局域网、WIFI、WLAN、蜂窝通信网络(GPRS、CDMA、2G/3G/4G/5G蜂窝网络)、卫星通信网络等等。
下面以具体地实施例对本申请的技术方案以及本申请的技术方案如何解决上述技术问题进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例中不再赘述。下面将结合附图,对本申请的实施例进行描述。
图2为本申请实施例提供的一种访问限流方法的流程示意图,本申请实施例提供了一种访问限流方法,该方法可以由任意执行访问限流方法的装置来执行,该装置可以通过软件和/或硬件实现。本实施例中,该装置可以集成在如图1所示的服务器15中。如图2所示,本申请实施例提供的访问限流方法包括如下步骤:
步骤201:当检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在访问接口外拦截终端设备发送的目标访问请求。
在本实施例中,在预设时间段内,若多个终端设备同时向访问接口发送访问请求,也即多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,为了防止系统发生崩溃,通常此时需要进行限流操作。其中,第一预设值可以根据服务器能够处理的访问请求的数量进行设置,对于第一预设值的具体取值,本申请实施例在此不做任何限制。
针对每一个终端设备,服务器会在该终端设备发送的目标访问请求发送至访问接口之前,拦截该目标访问请求。其中,拦截通常是使用添加的限流方法或规则对新产生的访问请求阻止直接调用访问接口。
具体的,当用户通过终端设备发送访问请求去调用访问接口时,服务器会接收到终端设备发送的目标访问请求,并在访问接口外先拦截该目标访问请求。图3是服务器在访问接口外拦截目标访问请求的示意图,如图3所示,当服务器同时接收到多个用户使用终端设备发送的访问请求时,服务器会为每一个不同id的终端设备创建一个隔离的滑动窗口。同时滑动窗口内的访问请求会经过限流组件,限流组件会根据内部的访问限流方法和规则判断是否放过目标访问请求以调用访问接口。其中,限流组件中包含了设定的访问限流方法和规则。
其中,滑动窗口是指,将一段时间窗口划分为等时间间隔的多个小格,每个小格中分别维护一个计数器,每隔一个小格的时间便会向后移动一个小格。
隔离的滑动窗口是指,每一个不同id的终端设备含有彼此相互独立的滑动窗口,即避免其他id的终端设备的滑动窗口被全部消耗而占用该id终端设备的滑动窗口。每一个滑动窗口中储存着服务器接收到终端设备发送的访问请求,滑动窗口能接受的访问请求的数量是一定的,例如一个时间窗口为60s。
在图3所示的滑动窗口中存放了服务器接收的访问请求。下面为了对滑动窗口接收访问请求的过程作深入的了解,将结合图4所示的实施例,对图3所示滑动窗口接收访问请求的过程进行说明。
在本申请的一些具体实施方式中,设定一段时间窗口,一般情况下,将该段时间窗口划分为等时间间隔的时间段,且滑动窗口的长度与一段时间窗口的长度相同,且在该段时间窗口内,访问接口的访问请求次数均不能超过服务器处理请求的阈值。例如图4滑动窗口接收访问请求过程40中,虚线框401代表一个滑动窗口,一个实线框402代表了一个小时间单元,斜线填满的小时间单元403代表此时间单元内接收到访问请求,箭头404代表滑动窗口移动的方向。其一段时间窗口时间长度为N,将该段时间窗口分为若干个等间隔的小时间单元,一小时间单元长度为n,每隔一小时间单元n,滑动窗口便向前移动一个小时间单元。同时一个滑动窗口内处理请求的数目是一定的,超过 一个滑动窗口处理访问请求数目的访问请求会被执行访问限流。例如,一段时间窗口的大小设定为60秒,并将该时间窗口划分为4个小时间单元,一个小时间单元分别为15秒,任意一个60秒的滑动窗口内访问接口的访问请求次数均不能大于1000个请求。如果1000个请求并发进入,在第一个60秒时间窗口内,当在15秒的小时间单元内突发1000个访问请求,此时已经超过服务器处理的阈值,则出现的新的访问请求将会被拒绝服务、排队或等待;15秒后滑动窗口向前移动一小格便可重新接收新的1000个请求。
进一步的,1000个请求也可以拆分,分批进入滑动窗口。例如在第一个60秒时间窗口内,15秒的小时间单元内进入400个访问请求,45秒小时间单元内进入600个访问请求,那么15秒后滑动窗口向前移动一小时间单元便可重新接收400个访问请求。以此类推,便可实现滑动窗口接收新请求的过程。
示例性的,在访问接口外拦截终端设备发送的目标访问请求,可以是当检测到终端设备向访问接口发送目标访问请求时,获取访问接口的接口配置信息,并判断该接口配置信息中是否包括限流配置信息,若接口配置信息中包括限流配置信息,则在访问接口外拦截目标访问请求。
在访问接口外拦截终端设备发送的目标访问请求前,需要先获取该访问接口的配置信息,判断该访问接口配置信息中是否包含有限流配置信息,从而决定是否执行访问限流。
具体的,可通过图5,对访问接口是否需要限流的过程进行说明。具体的过程如下:
步骤501:获取访问接口的接口配置信息。
步骤502:判断访问接口配置信息中是否包括限流配置信息。
步骤503:若访问接口配置信息中包括限流配置信息,则在访问接口外拦截目标访问请求。
步骤504:若访问接口配置信息中不包括限流配置信息,则不对目标访问请求进行拦截处理。
具体的,访问接口中的配置信息是访问接口包含的配置,例如:访问接口配置信息中包含限流配置信息。在访问接口外拦截目标访问请求前,首先需要判断该访问接口是否包含限流配置信息,若包含限 流配置信息,便会针对每一个终端用户,在访问接口外拦截终端设备发送的目标访问请求。
在本实施例中,在申请拦截访问请求前,在访问接口的配置信息中查看是否包含限流配置信息,可以提前确认访问接口是否包含限流方法,从而保证系统的稳定性。
步骤202:判断预设时间段内接收到目标访问请求的次数。
其中,预设时间段通常包括一个滑动时间窗口。
示例性的,当用户通过终端设备访问接口时,服务器在接收到该终端设备发送的目标访问请求后,会判断在上述预设时间段内,接收到目标访问请求的次数。服务器在预设时间段内接收到目标访问请求的次数,也可以理解为终端设备在预设时间段内向服务器发送目标访问请求的次数。其中,服务器可以在本地获取该目标访问请求的次数,也可以从限流服务器中获取该目标访问请求的次数。
进一步的,为了提高每一个用户的访问成功率,服务器在拦截目标访问请求后,还可以先判断目标访问请求是否为非首次访问接口的请求,若目标访问请求为非首次访问该访问接口的请求时,再判断预设时间段内接收到目标访问请求的次数;若目标访问请求为首次访问该访问接口的请求,则将目标访问请求发送给访问接口。
具体的,如果该用户通过终端设备发送目标访问请求,以首次访问该访问接口,则服务器会创建一个与该用户对应的独立滑动窗口,请求在访问该访问接口前需要通过限流组件,限流组件可以根据其内部添加的限流方法或规则直接放过该目标访问请求,使该目标访问请求访问一次上述访问接口。在接下来设定的一段时间窗口内,若该用户继续通过终端设备发送访问请求时,此时该用户的访问请求为非首次访问该访问接口的请求。首先若滑动窗口内没有足够的请求处理能力时便直接拒绝请求;若滑动窗口内有足够的请求处理能力时,接收请求后并开始启动计数器统计预设时间内请求访问接口的次数。
更进一步的,滑动窗口内统计到的预设时间内请求访问该访问接口的次数后,限流组件便可以依据统计到的次数判断是否要放行该目标访问请求访问接口。
在本实施例中,对接收到的目标访问请求,判断是否为首次访问访问接口的请求可以在多用户同时并发请求的情况下,保障每一位用户 均可成功的访问访问接口,避免因一个用户频繁发送访问请求而堵塞系统,导致系统限流而拒绝所有访问请求,进一步提高用户的访问成功率,提升用户体验感。
步骤203:若次数大于第二预设值,则将目标访问请求发送给访问接口。
其中,第二预设值是指预设时间段内,限流组件中含有的限流方法或规则设定的最高访问接口次数,其值可以根据实际情况或者经验进行设置,对于第二预设值的具体取值,本申请实施例在此不做限制。
示例性的,服务器对终端设备发送的访问请求进行接收并处理,服务器能够处理并发访问请求的能力是通过吞吐率来衡量的,所以任何服务器都有其处理并发访问请求能力的阈值。为了能够保证系统稳定的运行,使得在大批量并发访问请求情况下保证每个用户均可成功访问到访问接口,可根据限流组件中设定的限流方法或规则设定在滑动窗口内第二预设值。
进一步的,当用户为非首次请求访问接口时,统计预设时间段内接收到目标访问请求的次数,当预设时间段内接收到目标访问请求的次数超过第二预设值,则限流组件执行放行规则,使得该目标访问请求访问一次访问接口,也即服务器会将该目标访问请求发送给访问接口,同时重置或者更新滑动窗口内接收到目标访问请求的次数,这样可以保证该用户在成功访问到访问接口后,不会再重复调用访问接口而导致系统限流,从而进一步的提高每一个用户的访问成功率,节省系统资源。
当一段滑动窗口时间内接收到目标访问请求的次数不大于第二预设值,则禁止访问接口接收目标访问请求,也即拦截该目标访问请求对访问接口的访问,并执行降级方法,并将目标访问请求的接收的次数加1。需要注意是,若超过设定的滑动窗口时间后,该目标访问请求对访问接口的请求次数仍未超过第二预设值,则删除该滑动窗口内的访问请求。
其中,降级方法是指定访问请求为不同的级别,面临不同的异常等级执行不同的处理,根据服务方式:可以拒绝服务,可以延迟服务,也有时候可以随机服务。
更进一步的,使用过的滑动窗口会一直存在于系统资源中,为了保护系统资源,还有必要销毁不需要的滑动窗口。例如当判断某个滑动窗口已经很久没有使用时,发送一个自定义事件给自定义的spring事件监听器,由监听器负责移除该滑动窗口实例。
本申请实施例提供的访问限流方法、装置、设备、存储介质及计算机程序产品,通过检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在访问接口外拦截终端设备发送的目标访问请求,然后判断预设时间段内接收到目标访问请求的次数,若次数大于第二预设值,则将目标访问请求发送给访问接口。在大批量并发访问请求的场景下,会针对每一个终端设备,在访问接口外设置限流组件,通过限流方法拦截终端设备发送的目标访问请求,在预设时间内目标访问请求超过第二预设值,表示用户迫切需求访问该访问接口,此时限流组件会放行访问请求去调用访问接口。这样可以避免因个人频繁发送访问请求,导致系统开启限流而拒绝所有访问请求,从而在系统稳定运行的前提下提高用户访问的成功率。
图6为本申请实施例提供的一种访问限流装置60的结构示意图,示例的,请参见图6所示,该访问限流装置60可以包括:
拦截模块601,用于在检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在访问接口外拦截终端设备发送的目标访问请求;
判断模块602,用于判断预设时间段内接收到目标访问请求的次数;
发送模块603,用于在次数大于第二预设值时,将目标访问请求发送给访问接口。
在一种可能的实现方式中,判断模块602,具体用于:
判断目标访问请求是否为非首次访问访问接口的请求;
若目标访问请求为非首次访问访问接口的请求,则判断预设时间段内接收到目标访问请求的次数。
在一种可能的实现方式中,发送模块603,具体用于:
若目标访问请求为首次访问访问接口的请求,用于将目标访问请求发送给访问接口。
在一种可能的实现方式中,该装置还包括:处理模块604;
处理模块604,用于在次数不大于第二预设值时,禁止访问接口接收目标访问请求。
在一种可能的实现方式中,该装置还包括:更新模块605;
更新模块605,用于更新接收到目标访问请求的次数。
在一种可能的实现方式中,拦截模块601,具体用于:
获取访问接口的接口配置信息;
判断接口配置信息中是否包括限流配置信息;
若接口配置信息中包括限流配置信息,则在访问接口外拦截目标访问请求。
本申请实施例提供的访问限流装置60,可以执行上述任一实施例中访问限流方法的技术方案,其实现原理以及有益效果与访问限流方法的实现原理及有益效果类似,可参见访问限流方法的实现原理及有益效果,此处不再进行赘述。
图7为本申请实施例提供的一种服务器70的结构示意图,示例的,请参见图7所示,该服务器可以包括处理器701和存储器702。其中,
存储器702,用于存储计算机程序。
处理器701,用于读取存储器702存储的计算机程序,并根据存储器702中的计算机程序执行上述任一实施例中的访问限流方法的技术方案。
可选地,存储器702既可以是独立的,也可以跟处理器701集成在一起。当存储器702是独立于处理器701之外的器件时,服务器还可以包括:总线,用于连接存储器702和处理器701。
可选地,本实施例还包括:通信接口,该通信接口可以通过总线与处理器701连接。处理器701可以控制通信接口来实现上述服务器的获取和发送的功能。
本申请实施例所示的服务器,可以执行上述任一实施例中的访问限流方法的技术方案,其实现原理以及有益效果与访问限流方法的实现原理及有益效果类似,可参见访问限流方法的实现原理及有益效果,此处不再进行赘述。
本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,计算机执行指令被处理器执行时用于实现上述任一实施例中的访问限流方法的技术方案。
本申请实施例还提供了一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时,实现上述任一实施例中的访问限流方法的技术方案,其实现原理以及有益效果与访问限流方法的实现原理及有益效果类似,可参见访问限流方法的实现原理及有益效果,此处不再进行赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所展示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元展示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
上述以软件功能模块的形式实现的集成的模块,可以存储在一个计算机可读取存储介质中。上述软件功能模块存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(英文:processor)执行本申请各个实施例方法的部分步骤。
应理解的是,上述处理器可以是中央处理单元(英文:Central Processing Unit,简称:CPU),还可以是其他通用处理器、数字信号处理器(英文:Digital Signal Processor,简称:DSP)、专用集成电路(英文:Application Specific Integrated Circuit,简称:ASIC)等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。 结合发明所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。
存储器可能包含高速RAM存储器,也可能还包括非易失性存储NVM,例如至少一个磁盘存储器,还可以为U盘、移动硬盘、只读存储器、磁盘或光盘等。
总线可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互连(Peripheral Component,PCI)总线或扩展工业标准体系结构(Extended Industry Standard Architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,本申请附图中的总线并不限定仅有一根总线或一种类型的总线。
上述计算机可读存储介质可以是由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。存储介质可以是通用或专用计算机能够存取的任何可用介质。
最后应说明的是:以上各实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述各实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。

Claims (10)

  1. 一种访问限流方法,其特征在于,包括:
    当检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在所述访问接口外拦截所述终端设备发送的目标访问请求;
    判断预设时间段内接收到所述目标访问请求的次数;
    若所述次数大于第二预设值,则将所述目标访问请求发送给所述访问接口。
  2. 根据权利要求1所述的方法,其特征在于,所述判断预设时间段内接收到所述目标访问请求的次数,包括:
    判断所述目标访问请求是否为非首次访问所述访问接口的请求;
    若所述目标访问请求为非首次访问所述访问接口的请求,则判断预设时间段内接收到所述目标访问请求的次数。
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:
    若所述目标访问请求为首次访问所述访问接口的请求,则将所述目标访问请求发送给所述访问接口。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    若所述次数不大于所述第二预设值,则禁止所述访问接口接收所述目标访问请求。
  5. 根据权利要求1-3任一项所述的方法,其特征在于,所述将所述目标访问请求发送给所述访问接口之后,所述方法还包括:
    更新接收到所述目标访问请求的次数。
  6. 根据权利要求1-4任一项所述的方法,其特征在于,所述在所述访问接口外拦截所述终端设备发送的目标访问请求,包括:
    获取所述访问接口的接口配置信息;
    判断所述接口配置信息中是否包括限流配置信息;
    若所述接口配置信息中包括所述限流配置信息,则在所述访问接口外拦截所述目标访问请求。
  7. 一种访问限流装置,包括:
    拦截模块,用于在检测到多个终端设备向访问接口发送的访问请求的数量超过第一预设值时,针对每一终端设备,在所述访问接口外拦截所述终端设备发送的目标访问请求;
    判断模块,用于判断预设时间段内接收到所述目标访问请求的次数;
    发送模块,用于在所述次数大于第二预设值时,将所述目标访问请求发送给所述访问接口。
  8. 一种服务器,其特征在于,包括:存储器,处理器;
    所述存储器,用于存储计算机程序;
    所述处理器,用于读取所述存储器存储的计算机程序,并根据所述存储器中的计算机程序执行上述权利要求1-6任一项所述的访问限流方法。
  9. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机执行指令,所述计算机执行指令被处理器执行时用于实现上述权利要求1-6任一项所述的访问限流方法。
  10. 一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时,实现上述权利要求1-6中任一项所述的方法。
PCT/CN2022/117590 2021-09-09 2022-09-07 访问限流方法、装置、设备、存储介质及计算机程序产品 WO2023036188A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/233,197 US20230388235A1 (en) 2021-09-09 2023-08-11 Access traffic limiting method and apparatus, device, storage medium, and computer program product

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111056431.6 2021-09-09
CN202111056431.6A CN113726683B (zh) 2021-09-09 2021-09-09 访问限流方法、装置、设备、存储介质及计算机程序产品

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/233,197 Continuation US20230388235A1 (en) 2021-09-09 2023-08-11 Access traffic limiting method and apparatus, device, storage medium, and computer program product

Publications (1)

Publication Number Publication Date
WO2023036188A1 true WO2023036188A1 (zh) 2023-03-16

Family

ID=78682853

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/117590 WO2023036188A1 (zh) 2021-09-09 2022-09-07 访问限流方法、装置、设备、存储介质及计算机程序产品

Country Status (3)

Country Link
US (1) US20230388235A1 (zh)
CN (1) CN113726683B (zh)
WO (1) WO2023036188A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116800689A (zh) * 2023-08-17 2023-09-22 浙江飞猪网络技术有限公司 一种流量控制方法、节点、分布式系统及存储介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113726683B (zh) * 2021-09-09 2023-08-15 海尔数字科技(青岛)有限公司 访问限流方法、装置、设备、存储介质及计算机程序产品
CN114338639A (zh) * 2021-12-20 2022-04-12 上海万物新生环保科技集团有限公司 一种Nginx流量限制预警的方法及设备
CN114513461A (zh) * 2022-02-11 2022-05-17 联仁健康医疗大数据科技股份有限公司 限流方法、装置、电子设备及存储介质
CN115086234B (zh) * 2022-05-09 2024-04-26 阿里巴巴(中国)有限公司 消息处理方法及系统、设备及存储介质
CN115277128B (zh) * 2022-07-13 2024-02-23 上海砾阳软件有限公司 一种非法请求的处理方法、装置及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018088680A1 (ko) * 2016-11-09 2018-05-17 주식회사 수산아이앤티 차단된 사이트로의 접속 요청을 처리하는 보안 시스템 및 방법
CN110535777A (zh) * 2019-08-12 2019-12-03 新华三大数据技术有限公司 访问请求控制方法、装置、电子设备以及可读存储介质
CN112099979A (zh) * 2020-11-18 2020-12-18 数字广东网络建设有限公司 一种访问控制方法、装置、计算机设备和存储介质
CN112615792A (zh) * 2020-12-10 2021-04-06 北京房天下嘉居网络技术有限公司 接口限流方法及装置
CN113726683A (zh) * 2021-09-09 2021-11-30 海尔数字科技(青岛)有限公司 访问限流方法、装置、设备、存储介质及计算机程序产品

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104978335B (zh) * 2014-04-04 2018-12-07 阿里巴巴集团控股有限公司 数据访问控制方法和装置
CN105282047B (zh) * 2015-09-25 2020-04-14 小米科技有限责任公司 访问请求处理方法及装置
CN105763561B (zh) * 2016-04-15 2019-06-28 新华三技术有限公司 一种攻击防御方法和装置
CN107436835B (zh) * 2017-06-21 2020-09-08 北京星选科技有限公司 访问控制方法和装置
CN108683604B (zh) * 2018-04-03 2021-11-26 平安科技(深圳)有限公司 并发访问控制方法、终端设备及介质
CN109257293B (zh) * 2018-08-01 2022-02-18 北京明朝万达科技股份有限公司 一种用于网络拥堵的限速方法、装置及网关服务器
CN110808914A (zh) * 2019-09-29 2020-02-18 北京淇瑀信息科技有限公司 一种访问请求处理方法、装置及电子设备
CN111625859A (zh) * 2020-05-20 2020-09-04 北京百度网讯科技有限公司 一种资源的访问控制方法、装置、电子设备和存储介质
CN111949979A (zh) * 2020-07-29 2020-11-17 山东英信计算机技术有限公司 一种网络端口保护方法、系统、电子设备及存储介质
CN113285883A (zh) * 2021-05-25 2021-08-20 挂号网(杭州)科技有限公司 一种访问请求的限流方法及装置、电子设备、存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018088680A1 (ko) * 2016-11-09 2018-05-17 주식회사 수산아이앤티 차단된 사이트로의 접속 요청을 처리하는 보안 시스템 및 방법
CN110535777A (zh) * 2019-08-12 2019-12-03 新华三大数据技术有限公司 访问请求控制方法、装置、电子设备以及可读存储介质
CN112099979A (zh) * 2020-11-18 2020-12-18 数字广东网络建设有限公司 一种访问控制方法、装置、计算机设备和存储介质
CN112615792A (zh) * 2020-12-10 2021-04-06 北京房天下嘉居网络技术有限公司 接口限流方法及装置
CN113726683A (zh) * 2021-09-09 2021-11-30 海尔数字科技(青岛)有限公司 访问限流方法、装置、设备、存储介质及计算机程序产品

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116800689A (zh) * 2023-08-17 2023-09-22 浙江飞猪网络技术有限公司 一种流量控制方法、节点、分布式系统及存储介质
CN116800689B (zh) * 2023-08-17 2024-01-09 浙江飞猪网络技术有限公司 一种流量控制方法、节点、分布式系统及存储介质

Also Published As

Publication number Publication date
CN113726683B (zh) 2023-08-15
US20230388235A1 (en) 2023-11-30
CN113726683A (zh) 2021-11-30

Similar Documents

Publication Publication Date Title
WO2023036188A1 (zh) 访问限流方法、装置、设备、存储介质及计算机程序产品
WO2018028717A1 (zh) 无线网络的接入控制方法及装置
US10554531B2 (en) Enforcing parameters for quality of data link service at a future time
WO2019237813A1 (zh) 一种服务资源的调度方法及装置
US11537304B2 (en) Data verification method and apparatus, and storage medium
CN109067571B (zh) 电子装置及其网络配置方法、存储介质
CN107689901B (zh) 一种监控业务报文流量的方法及装置
US9756524B2 (en) Method and system for signaling saving on radio access networks using early throttling mechanism for communication devices
CN108023829B (zh) 报文处理方法及装置、存储介质、电子设备
US20230153264A1 (en) Data transmission method, chip, and device
WO2021068205A1 (zh) 访问控制方法、装置、服务器和计算机可读介质
US9473985B2 (en) UE selective control of downlink data
CN110838987B (zh) 队列限流方法、存储介质
CN111371697A (zh) 面向系统间访问的精确流量控制方法及装置
WO2021129742A1 (zh) 网络数据的恢复方法、装置及移动终端
CN110650182A (zh) 网络缓存方法、装置、计算机设备及存储介质
US20230180104A1 (en) Fine grained access barring of aggressive cellular devices
WO2023011233A1 (zh) 流量管理方法、装置、设备及计算机可读存储介质
US10154150B2 (en) Network switching detection for toll-free data service provision
CN110661722B (zh) 一种流量控制的方法及装置
CN108804152B (zh) 配置参数的调节方法及装置
US20210004308A1 (en) Data processing method and system
US11650993B2 (en) Information query method for terminal and terminal
US10244046B2 (en) Managing traffic at a node within a wireless communication network upon the node entering service
US20230300082A1 (en) Flow control method, apparatus, and device, and computer-readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22866651

Country of ref document: EP

Kind code of ref document: A1