Traffic limiting method and device and computer readable storage medium

By determining the target API interface in the API gateway and updating the URL address, and determining the current limiting strategy in the access time, the problem of difficult to achieve interface-level fine-grained traffic flow restriction in the existing technology is solved, and the precise statistics of the number of calls to the API interface and the accurate application of the current limiting strategy is realized.

CN119652826APending Publication Date: 2025-03-18SHENZHEN QIANHAI EVOC ASIA-PACIFIC ELECTRONIC EQUIP TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411751891.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

The prior art is difficult to implement interface-level fine-grained traffic flow restriction in API gateways, especially in interfaces with parameters in URL paths, and it is impossible to effectively count and associate the number of calls of different URLs.

Method used

By obtaining the request method, URL address and access time when receiving the access request, the target API interface is determined in the database based on this information, the preset field parameters in the URL address are updated to obtain the target URL address, and finally the current limiting strategy is determined based on the target URL address and access time, so as to achieve accurate statistics on the current limiting and number of calls of the API interface.

Benefits of technology

The interface-level fine-grained traffic flow restriction is realized in the API gateway, which can accurately count the number of calls of the API interface, and improve the accuracy and effectiveness of the current limit.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119652826A_ABST
    Figure CN119652826A_ABST
Patent Text Reader

Abstract

The invention discloses a flow limiting method and device and a computer readable storage medium, and the method comprises the steps: obtaining a request method, a URL address and an access moment corresponding to an access request when the access request is received; based on the request method and the URL address, determining a target API interface corresponding to the access request in each API interface of a database; updating a field parameter of a preset field in the URL address based on the target API interface to obtain a target URL address; and determining a flow limiting strategy corresponding to the access request based on the target URL address and the access moment. According to the method and the device, the flow limiting of the API interface is realized according to the target URL address, the calling times of the API interface can be counted through the target URL address, the accurate calling statistics of the calling times of the API interface is realized, and the flow limiting of interface-level fine granularity is realized at the API gateway.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a flow limiting method, device and computer-readable storage medium. Background Art

[0002] Usually, the user's access behavior is directed to a certain URL. There may be a large number of users who access the URL in a concentrated manner, causing problems with the traffic service of the URL, such as slow response, server crash, etc. At this time, current limiting processing is required. In the related technology, a counter can be used for current limiting processing. Specifically, the number of requests is tracked within a certain time window. When the number of requests exceeds the set threshold, subsequent requests are rejected until the next time window starts. Current limiting can be supported by different time units such as seconds, minutes, hours, days, weeks, months and years, and can be used in combination, such as setting the maximum number of requests per second and the maximum number of requests per day.

[0003] For interfaces with parameters in the URL path, take the user details interface "GET / api / user / {userId}" as an example. Since the user parameters are uncertain when the user's traffic request reaches the API gateway, the actual URL link of the traffic request in the API gateway may be: / api / user / 1, / api / user / 2, / api / user / 3 or / api / user / xxx. The counter method can count the number of calls to / api / user / 1, / api / user / 2, etc. However, since it is impossible to know whether different URLs belong to the same interface, the counted times cannot be effectively associated, and it is difficult to count the number of times the user details interface is called.

[0004] Therefore, how to implement fine-grained traffic limiting at the interface level in the API gateway is a problem that needs to be solved urgently. Summary of the invention

[0005] The main purpose of this application is to provide a traffic limiting method, device and computer-readable storage medium, aiming to solve the technical problem of how to implement fine-grained traffic limiting at the interface level in an API gateway.

[0006] To achieve the above object, the present application provides a flow limiting method, which comprises the following steps:

[0007] When receiving an access request, obtaining the request method, URL address and access time corresponding to the access request;

[0008] Based on the request method and the URL address, determine the target API interface corresponding to the access request in each API interface of the database;

[0009] Based on the target API interface, the field parameters of the preset fields in the URL address are updated to obtain the target URL address;

[0010] Based on the target URL address and the access time, a current limiting strategy corresponding to the access request is determined.

[0011] Furthermore, the step of determining the target API interface corresponding to the access request in each API interface of the database based on the request method and the URL address includes:

[0012] Obtaining the preset request method and preset matching string corresponding to each API interface in the database;

[0013] Based on the request method, the URL address, the preset request methods corresponding to the respective API interfaces, and the preset matching strings, a target API interface corresponding to the access request is determined in the respective API interfaces.

[0014] Furthermore, the step of determining a target API interface corresponding to the access request in each API interface based on the request method, the URL address, a preset request method corresponding to each API interface, and a preset matching string includes:

[0015] The request method and the URL address are matched with the preset request method and the preset matching string of each API interface respectively to determine the target API interface, wherein the preset request method of the target API interface matches the request method, and the preset matching string of the target API interface matches the URL address.

[0016] Furthermore, the step of updating the field parameters of the preset fields in the URL address based on the target API interface to obtain the target URL address includes:

[0017] Obtaining an interface identifier corresponding to the target API interface in the database;

[0018] Based on the interface identifier corresponding to the target API interface, the field parameters of the preset fields in the URL address are updated to obtain the target URL address.

[0019] Furthermore, the step of determining a current limiting strategy corresponding to the access request based on the target URL address and the access time includes:

[0020] Determine an access time period corresponding to the access request based on the access time, and update a first access count corresponding to the target API interface within the access time period based on the target URL address;

[0021] Based on the first access number, a current limiting strategy corresponding to the access request is determined.

[0022] Furthermore, the step of determining a current limiting strategy corresponding to the access request based on the first access count includes:

[0023] Based on the first access count, determining a total access count of the access time period corresponding to a preset time interval, wherein the preset time interval includes the access time period;

[0024] A current limiting strategy corresponding to the access request is determined based on the total number of accesses.

[0025] Furthermore, the step of determining the total number of visits corresponding to the preset time interval in the visit time period based on the first number of visits includes:

[0026] Obtaining the second number of visits corresponding to each visit time period within the preset time interval before the visit moment;

[0027] Based on the first access number and the second access number, a total access number corresponding to the preset time interval is determined.

[0028] Furthermore, the step of determining a current limiting strategy corresponding to the access request based on the total number of accesses includes:

[0029] Determine whether the total number of visits is greater than a preset number corresponding to the target URL address;

[0030] If the total number of accesses is greater than a preset number, the current limiting strategy is determined to reject the access request.

[0031] In addition, to achieve the above-mentioned purpose, the present application also provides a flow limiting device, which includes: a memory, a processor, and a flow limiting program stored in the memory and executable on the processor, and the flow limiting program implements the steps of the aforementioned flow limiting method when executed by the processor.

[0032] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which a traffic limiting program is stored, and when the traffic limiting program is executed by a processor, the steps of the aforementioned traffic limiting method are implemented.

[0033] The present application obtains the request method, URL address and access time corresponding to the access request when an access request is received; then, based on the request method and the URL address, determines the target API interface corresponding to the access request in each API interface in the database; then, based on the target API interface, updates the field parameters of the preset fields in the URL address to obtain the target URL address; then, based on the target URL address and the access time, determines the current limiting strategy corresponding to the access request, updates the URL address of the access request through the target API interface corresponding to the access request, determines the current limiting strategy corresponding to the access request according to the updated target URL address and the access time, and then implements current limiting of the API interface according to the target URL address. The number of calls to the API interface can be counted through the target URL address, and accurate call statistics of the number of calls to the API interface can be implemented, so as to implement fine-grained traffic limiting at the interface level in the API gateway. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0036] Figure 1 A flow chart showing the flow of the flow limiting method according to the present invention;

[0037] Figure 2 This is a schematic diagram of the module structure of the flow limiting device according to an embodiment of the present application.

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

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

[0040] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0041] The main solution of the present application is: when an access request is received, the request method, URL address and access time corresponding to the access request are obtained; based on the request method and the URL address, the target API interface corresponding to the access request is determined in each API interface of the database; based on the target API interface, the field parameters of the preset fields in the URL address are updated to obtain the target URL address; based on the target URL address and the access time, the current limiting strategy corresponding to the access request is determined.

[0042] At present, users usually visit a certain URL. A large number of users may visit the URL in a concentrated manner, causing problems with the traffic service of the URL, such as slow response and server crash. At this time, current limiting is required. In related technologies, current limiting can be performed by using a counter. Specifically, the number of requests is tracked within a certain time window. When the number of requests exceeds the set threshold, subsequent requests are rejected until the next time window begins. Current limiting can be performed by different time units such as seconds, minutes, hours, days, weeks, months and years, and can be used in combination, such as setting the maximum number of requests per second and the maximum number of requests per day.

[0043] For interfaces with parameters in the URL path, take the user details interface GET / api / user / {userId} as an example. Since the user parameters are uncertain when the user's traffic request reaches the API gateway, the actual URL link of the traffic request in the API gateway may be: / api / user / 1, / api / user / 2, / api / user / 3 or / api / user / xxx. The counter method can count the number of calls to / api / user / 1, / api / user / 2, etc. However, since it is impossible to know whether different URLs belong to the same interface, the counted times cannot be effectively associated, and it is difficult to count the number of times the user details interface is called.

[0044] Therefore, how to implement fine-grained traffic limiting at the interface level in the API gateway is a problem that needs to be solved urgently.

[0045] This application updates the URL address of the access request through the target API interface corresponding to the access request, determines the current limiting strategy corresponding to the access request according to the updated target URL address and the access time, and then implements the current limiting of the API interface according to the target URL address. The number of calls to the API interface can be counted through the target URL address, and accurate call statistics of the number of calls to the API interface can be achieved, so as to implement fine-grained traffic limiting at the interface level in the API gateway.

[0046] It should be noted that the execution subject of this embodiment can be a flow limiting device, or a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a flow limiting device capable of realizing the above functions, etc., and this embodiment does not specifically limit this. The following takes the flow limiting device as the execution subject as an example to illustrate this embodiment and the following embodiments.

[0047] Based on this, this application proposes a flow limiting method of the first embodiment, please refer to Figure 1 The flow limiting method includes steps S101 to S104:

[0048] Step S101, upon receiving an access request, obtaining a request method, URL address and access time corresponding to the access request;

[0049] It should be noted that, according to the traffic limiting method of this embodiment, an interface plug-in with a parameter path can be set in the API gateway.

[0050] In this embodiment, when an access request is received, the request method, URL address and access time corresponding to the access request are obtained. For example, when the current interface request (access request) passes through the interface plug-in with a parameter path, the current time is recorded as the access time, and the request method and URL address corresponding to the access request are parsed through the interface plug-in. Taking the user details interface GET / api / user / {userId} as an example, the request method parsed by the interface plug-in is "GET", and the URL address is " / api / user / {userId}". For example, for the user details interface GET / api / user / 01, its request method is "GET", and its URL address is " / api / user / 01".

[0051] Step S102, based on the request method and the URL address, determining the target API interface corresponding to the access request from various API interfaces in the database;

[0052] It should be noted that before executing the traffic limiting of this embodiment, the interface parameters of the API interface that needs to be limited are stored in the database, where the interface parameters include interface identifier, request method, request url and preset matching string, the request url is the URL address, and the interface identifier is the unique identifier of the API interface.

[0053] For each API interface that needs to be limited, the part with parameters in the request url is replaced with a preset character such as * to obtain a preset matching string, that is, the preset matching string * is used as a placeholder for character matching, and can match any string. For example, the request url corresponding to the API interface is " / api / user / {userId}", and the preset matching string match_partner is " / api / user / *". For example, the interface parameters of multiple API interfaces stored in the database are shown in Table 1 below, where api_id is the interface identifier, method is the request method, url is the URL address, and match_partner is the preset matching string. If the preset matching string in Table 1 is empty, it means that the traffic limiting method of this embodiment is not used to limit the flow of the API interface, and the current limiting method in the relevant technology can be used to limit the flow of the API interface through "method" and "url".

[0054] Table 1: API interface parameters

[0055] api_id method url match_partner 0001 GET / api / user / {userId} / api / user / * 0002 POST / api / user / list 0003 POST / api / user / add 0004 GET / api / user / pages 0005 GET / api / user / info 0006 GET / api / user / {merchant} / info / api / user / * / info

[0056] In this embodiment, after obtaining the request method, URL address and access time corresponding to the access request, the target API interface corresponding to the access request is determined in each API interface in the database according to the request method and URL address. Specifically, the preset request method and preset matching string corresponding to each API interface are obtained in the database, and the request method and URL address of the access request are matched with the preset request method and preset matching string of each API interface respectively to determine the target API interface. The preset request method of the target API interface matches the request method, and the preset matching string of the target API interface matches the URL address, that is, the preset request method of the target API interface matches the request method. The request method is the same as the request method, and the preset matching string of the target API interface is the same as the URL address. For example, for the user details interface GET / api / user / 01 of the access request, the request method is "GET" and the URL address is " / api / user / 01". The interface identifier api_id of the target API interface corresponding to the access request is 0001, that is, the request method of the access request is the same as the method "GET" corresponding to the API interface with api_id 0001, and the URL address of the access request is the same as the match_partner " / api / user / *" corresponding to the API interface with api_id 0001.

[0057] Step S103, updating the field parameters of the preset fields in the URL address based on the target API interface to obtain the target URL address;

[0058] In this embodiment, after obtaining the target API interface, the field parameters of the preset fields in the URL address are updated based on the target API interface to obtain the target URL address. Specifically, the interface identifier corresponding to the target API interface is obtained in the database, and then based on the interface identifier corresponding to the target API interface, the field parameters of the preset fields in the URL address are updated to obtain the target URL address. For example, for the user details interface GET / api / user / 01 of the access request, the interface identifier of the corresponding target API interface is "0001". Replace "01" in the URL address of the access request with "0001", and the obtained target URL address is " / api / user / 0001".

[0059] Step S104: determining a current limiting strategy corresponding to the access request based on the target URL address and the access time.

[0060] In this embodiment, after obtaining the target URL address, the current limiting strategy corresponding to the access request is determined based on the target URL address and the access time. Specifically, the access time period to which the access time belongs is determined, and the first number of accesses corresponding to the target URL address within the access time period, that is, the first number of accesses corresponding to the target API interface, is counted. According to the first number of accesses, the current limiting strategy corresponding to the access request is determined. For example, according to the first number of accesses and the number of accesses in multiple time periods before the access time period, the total number of accesses within a period of time (preset time interval) is counted. If the total number of accesses is greater than the preset number, the access request is rejected, that is, the current limiting strategy is to reject the access request. Otherwise, the subsequent access process of the access request is executed.

[0061] The traffic limiting method proposed in this embodiment obtains the request method, URL address and access time corresponding to the access request when an access request is received; then, based on the request method and the URL address, determines the target API interface corresponding to the access request in each API interface in the database; then, based on the target API interface, updates the field parameters of the preset fields in the URL address to obtain the target URL address; then, based on the target URL address and the access time, determines the limiting strategy corresponding to the access request, updates the URL address of the access request through the target API interface corresponding to the access request, determines the limiting strategy corresponding to the access request according to the updated target URL address and the access time, and then implements limiting of the API interface according to the target URL address. The number of calls to the API interface can be counted through the target URL address, and accurate call statistics of the number of calls to the API interface can be implemented, so as to implement fine-grained traffic limiting at the interface level in the API gateway.

[0062] In a feasible implementation, step S102 may include steps S1021 to S1022:

[0063] Step S1021, obtaining a preset request method and a preset matching string corresponding to each API interface in the database;

[0064] Step S1022: Based on the request method, the URL address, the preset request methods corresponding to the respective API interfaces, and the preset matching strings, a target API interface corresponding to the access request is determined in the respective API interfaces.

[0065] In this embodiment, after obtaining the request method, URL address and access time corresponding to the access request, the preset request method and preset matching string corresponding to each API interface are obtained in the database. For example, as shown in Table 1, each API interface includes interface identifiers "0001", "0002", "0003", "0004", "0005" and "0006". Since only the interfaces with interface identifiers "0001" and "0006" have preset matching strings, the preset request method and preset matching string corresponding to the interfaces with interface identifiers "0001" and "0006" can be obtained.

[0066] After obtaining the preset request method and the preset matching string, based on the request method, the URL address, the preset request method and the preset matching string, the target API interface corresponding to the access request is determined in each API interface. Further, in a feasible implementation, step S1022 may include step a:

[0067] Step a, matching the request method and the URL address with the preset request method and the preset matching string of each API interface respectively to determine the target API interface, wherein the preset request method of the target API interface matches the request method, and the preset matching string of the target API interface matches the URL address.

[0068] In this embodiment, after obtaining the preset request method and the preset matching string, the request method and the URL address of the access request are matched with the preset request method and the preset matching string of each API interface respectively to determine the target API interface. The preset request method of the target API interface matches the request method, and the preset matching string of the target API interface matches the URL address, that is, the preset request method of the target API interface is the same as the request method, and the preset matching string of the target API interface is the same as the URL address, so that the target API interface can be accurately determined to improve the accuracy of current limiting on the API interface.

[0069] For example, for the user details interface GET / api / user / 01 of the access request, the request method is "GET", and the URL address is " / api / user / 01". The interface identifier api_id of the target API interface corresponding to the access request is 0001, that is, the request method of the access request is the same as the method "GET" corresponding to the API interface with api_id 0001, and the URL address of the access request is the same as the match_partner " / api / user / *" corresponding to the API interface with api_id 0001.

[0070] The traffic limiting method proposed in this embodiment obtains the preset request method and preset matching string corresponding to each API interface in the database; then based on the request method, the URL address, the preset request method and preset matching string corresponding to each API interface, determines the target API interface corresponding to the access request in each API interface, and matches the API interface according to the request method and the URL address to improve the accuracy of the target API interface, thereby further improving the accuracy of limiting the API interface.

[0071] In a feasible implementation, step S103 may include steps S1031 to S1032:

[0072] Step S1031, obtaining the interface identifier corresponding to the target API interface in the database;

[0073] Step S1032: based on the interface identifier corresponding to the target API interface, update the field parameters of the preset fields in the URL address to obtain the target URL address.

[0074] In this embodiment, after obtaining the target API interface, the interface identifier corresponding to the target API interface is obtained in the database; for example, for the user details interface GET / api / user / 01 of the access request, the interface identifier of the corresponding target API interface is "0001".

[0075] After obtaining the interface identifier, based on the interface identifier corresponding to the target API interface, update the field parameters of the preset fields in the URL address, that is, replace the field parameters with the interface identifier to obtain the target URL address. For example, for the user details interface GET / api / user / 01 of the access request, the interface identifier of the corresponding target API interface is "0001". Replace "01" in the URL address of the access request with "0001", and the obtained target URL address is " / api / user / 0001".

[0076] The traffic limiting method proposed in this embodiment obtains the interface identifier corresponding to the target API interface in the database; then, based on the interface identifier corresponding to the target API interface, updates the field parameters of the preset fields in the URL address to obtain the target URL address. The URL address can be updated according to the interface identifier, so as to count the number of calls of the API interface according to the updated target URL address, and realize accurate call statistics of the number of calls of the API interface, so as to realize fine-grained traffic limiting at the interface level in the API gateway.

[0077] In a feasible implementation, step S104 may include steps S1041 to S1042:

[0078] Step S1041, determining an access time period corresponding to the access request based on the access time, and updating a first access count corresponding to the target API interface within the access time period based on the target URL address;

[0079] Step S1042: Determine a current limiting strategy corresponding to the access request based on the first access count.

[0080] It should be noted that when the AIP interface needs to be current limited, a preset time interval and a current limiting threshold (preset number of times) are set according to the current limiting time period of the AIP interface. To facilitate the statistics of the number of calls to the AIP interface within the current limiting time period, the current limiting time period can be divided into multiple small time periods (access time periods). For example, when the current limiting time period is 1 second, it can be divided into 10 time periods of 100ms (access time periods).

[0081] In this embodiment, after obtaining the target URL address, the access time period corresponding to the access request is determined based on the access time, and the first access count corresponding to the target API interface within the access time period is updated based on the target URL address, that is, the first access count is increased by 1 to obtain the updated first access count.

[0082] After obtaining the first access count, a current limiting strategy corresponding to the access request is determined based on the first access count. Further, in a feasible implementation, step S1042 may include steps b to c:

[0083] Step b, based on the first access count, determining the total access count of the access time period corresponding to a preset time interval, wherein the preset time interval includes the access time period;

[0084] Step c: determining a current limiting strategy corresponding to the access request based on the total number of accesses.

[0085] In this embodiment, after obtaining the first access count, the total access count of the access time period corresponding to the preset time interval is determined based on the first access count. Specifically, in a feasible implementation, step b may include steps b1 to b2:

[0086] Step b1, obtaining the second access number corresponding to each access time period within the preset time interval before the access moment;

[0087] Step b2: determining a total number of visits corresponding to the preset time interval based on the first number of visits and the second number of visits.

[0088] In this embodiment, after obtaining the first access count, the second access count corresponding to each access time period within the preset time interval is obtained before the access moment. For example, if the current limiting time period is 1 second and the access time period is 100ms, the second access count of the 9 access time periods before the current access time period is obtained, and based on the first access count and the second access count, the total access count corresponding to the preset time interval is determined, that is, the total access count is the sum of the first access count and the second access count, and the total access count can be accurately obtained to achieve accurate current limiting of the API interface.

[0089] After the total number of accesses is obtained, a current limiting strategy corresponding to the access request is determined based on the total number of accesses. Further, in a feasible implementation, step c may include steps c1 to c2:

[0090] Step c1, determining whether the total number of visits is greater than the preset number corresponding to the target URL address;

[0091] Step c2: If the total number of accesses is greater than a preset number, determine that the current limiting strategy is to reject the access request.

[0092] In this embodiment, after obtaining the total number of accesses, it is determined whether the total number of accesses is greater than the preset number corresponding to the target URL address. If the total number of accesses is greater than the preset number, the current limiting strategy is determined to deny the access request. For example, a prompt message corresponding to the network congestion is fed back to the client corresponding to the access request. If the total number of accesses is less than or equal to the preset number, the subsequent access process of the access request is executed.

[0093] The traffic limiting method proposed in this embodiment determines the access time period corresponding to the access request based on the access time, and updates the first access count corresponding to the target API interface within the access time period based on the target URL address; then determines the current limiting strategy corresponding to the access request based on the first access count, which can accurately implement the current limiting of the API interface corresponding to the access request according to the first access count, further improving the accuracy of current limiting on the API interface, so as to implement fine-grained traffic limiting at the interface level in the API gateway.

[0094] The flow limiting device provided in the embodiment of the present application adopts the flow limiting method in the above embodiment, which can solve the technical problem of how to implement fine-grained flow limiting at the interface level in the API gateway. Compared with the prior art, the beneficial effects of the flow limiting device provided in the embodiment of the present application are the same as the beneficial effects of the flow limiting method provided in the above embodiment, and the other technical features in the flow limiting device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0095] The present application provides a flow limiting device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the flow limiting method in the above-mentioned embodiment one.

[0096] Reference below Figure 2 , which shows a schematic diagram of the structure of a flow rate limiting device suitable for implementing the embodiment of the present application. The flow rate limiting device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 2 The flow limiting device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0097] like Figure 2As shown, the flow limiting device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the flow limiting device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the flow limiting device to communicate with other devices wirelessly or wired to exchange data. Although the flow limiting device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided alternatively.

[0098] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0099] The flow limiting device provided by the present application adopts the flow limiting method in the above embodiment, which can solve the technical problem of how to implement fine-grained flow limiting at the interface level in the API gateway. Compared with the prior art, the beneficial effects of the flow limiting device provided by the present application are the same as the beneficial effects of the flow limiting method provided by the above embodiment, and the other technical features in the flow limiting device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0100] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

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

[0102] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the flow limiting method in the above-mentioned embodiment.

[0103] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0104] The computer-readable storage medium may be included in the flow limiting device; or may exist independently without being assembled into the flow limiting device.

[0105] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the traffic limiting device, the traffic limiting device: upon receiving an access request, obtains the request method, URL address and access time corresponding to the access request; based on the request method and the URL address, determines the target API interface corresponding to the access request in each API interface of the database; based on the target API interface, updates the field parameters of the preset fields in the URL address to obtain the target URL address; based on the target URL address and the access time, determines the traffic limiting strategy corresponding to the access request.

[0106] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0107] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0108] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0109] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned traffic limiting method, and can solve the technical problem of how to implement fine-grained traffic limiting at the interface level in the API gateway. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the traffic limiting method provided in the above-mentioned embodiment, and will not be repeated here.

[0110] An embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the above-mentioned flow limiting method when executed by a processor.

[0111] The computer program product provided in this application can solve the technical problem of how to implement fine-grained flow control at the interface level in the API gateway. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of this application are the same as the beneficial effects of the flow control method provided in the above embodiment, which will not be repeated here.

[0112] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A flow limiting method, characterized in that: The flow limiting method comprises the following steps: When receiving an access request, obtaining the request method, URL address and access time corresponding to the access request; Based on the request method and the URL address, determine the target API interface corresponding to the access request in each API interface of the database; Based on the target API interface, the field parameters of the preset fields in the URL address are updated to obtain the target URL address; Based on the target URL address and the access time, determine the current limiting strategy corresponding to the access request.

2. The flow limiting method according to claim 1, characterized in that: The step of determining the target API interface corresponding to the access request in each API interface in the database based on the request method and the URL address includes: Obtaining the preset request method and preset matching string corresponding to each API interface in the database; Based on the request method, the URL address, the preset request methods corresponding to the respective API interfaces, and the preset matching strings, a target API interface corresponding to the access request is determined in the respective API interfaces.

3. The flow limiting method according to claim 2, characterized in that: The step of determining the target API interface corresponding to the access request in each API interface based on the request method, the URL address, the preset request method corresponding to each API interface, and the preset matching string includes: The request method and the URL address are matched with the preset request method and the preset matching string of each API interface respectively to determine the target API interface, wherein the preset request method of the target API interface matches the request method, and the preset matching string of the target API interface matches the URL address.

4. The flow limiting method according to claim 1, characterized in that: The step of updating the field parameters of the preset fields in the URL address based on the target API interface to obtain the target URL address includes: Obtaining an interface identifier corresponding to the target API interface in the database; Based on the interface identifier corresponding to the target API interface, the field parameters of the preset fields in the URL address are updated to obtain the target URL address.

5. The flow limiting method according to any one of claims 1 to 4, characterized in that: The step of determining the current limiting strategy corresponding to the access request based on the target URL address and the access time includes: Determine an access time period corresponding to the access request based on the access time, and update a first access count corresponding to the target API interface within the access time period based on the target URL address; Based on the first access number, a current limiting strategy corresponding to the access request is determined.

6. The flow limiting method according to claim 5, characterized in that: The step of determining the current limiting strategy corresponding to the access request based on the first access number includes: Based on the first access count, determining a total access count of the access time period corresponding to a preset time interval, wherein the preset time interval includes the access time period; A current limiting strategy corresponding to the access request is determined based on the total number of accesses.

7. The flow limiting method according to claim 6, characterized in that: The step of determining the total number of visits corresponding to the preset time interval in the visit time period based on the first number of visits comprises: Obtaining the second number of visits corresponding to each visit time period within the preset time interval before the visit moment; Based on the first access number and the second access number, a total access number corresponding to the preset time interval is determined.

8. The flow limiting method according to claim 6, characterized in that: The step of determining the current limiting strategy corresponding to the access request based on the total number of accesses includes: Determine whether the total number of visits is greater than a preset number corresponding to the target URL address; If the total number of accesses is greater than a preset number, the current limiting strategy is determined to reject the access request.

9. A flow limiting device, characterized in that: The flow limiting device comprises: a memory, a processor and a flow limiting program stored in the memory and executable on the processor, wherein the flow limiting program implements the steps of the flow limiting method as claimed in any one of claims 1 to 8 when executed by the processor.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a flow limiting program, and when the flow limiting program is executed by the processor, the steps of the flow limiting method according to any one of claims 1 to 8 are implemented.