Interface call frequency limiting method and device, computer device and storage medium

By comparing the local shared memory area between the interface caller and the frequency limiting server, the problem of low performance in traditional interface call frequency limiting methods is solved, and efficient and secure frequency limiting processing is achieved.

CN115220925BActive Publication Date: 2026-05-26TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2021-04-19
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Traditional API call frequency limiting methods rely on a unified frequency limiting service, resulting in poor performance and the need for external service support, making it inefficient for handling high-concurrency calls.

Method used

By matching the interface caller with the frequency limiting server, the accumulated call information and frequency limiting control information are obtained using the local shared memory area, and the frequency limiting response results are generated through local comparison, thus avoiding centralized processing of the unified frequency limiting service.

Benefits of technology

Decentralized frequency limiting processing was implemented, which improved performance and security, reduced reliance on external services, simplified security mechanisms, and improved system processing efficiency and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115220925B_ABST
    Figure CN115220925B_ABST
Patent Text Reader

Abstract

This application relates to an interface call frequency limiting method, apparatus, computer device, and storage medium. The method includes: after an interface caller sends a call request for a target interface, obtaining a call frequency limiting query request corresponding to the target interface through a frequency limiting server matched with the interface caller; the frequency limiting server, based on the call frequency limiting query request, obtaining accumulated call information of the interface caller's calls to the target interface from a local shared memory area; obtaining frequency limiting control information corresponding to the interface caller from the shared memory area; comparing the accumulated call information with the frequency limiting control information; generating a frequency limiting response result based on the comparison result; the frequency limiting response result indicating whether to limit the call request. This method can improve performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to an interface call frequency limiting method, apparatus, computer device, and storage medium. Background Technology

[0002] With the development of science and technology, internet services have penetrated into all aspects of life, such as search services, order placement services, and payment services, providing people with a great deal of convenience. When using internet services, users often need to call the interfaces that provide these services. However, if the interface callers make high-concurrency calls, it can easily cause the interface to become unavailable. Therefore, it is necessary to limit the number of times the interface can be called by the callers, i.e., frequency limiting.

[0003] In traditional technologies, when limiting the frequency of different API calls, a unified frequency limiting service is typically invoked to obtain the limiting result and determine whether limiting is necessary. However, in this centralized design, relying on a unified frequency limiting service for uniform frequency limiting results in low performance. Furthermore, the unified frequency limiting service often depends on external services (such as MySQL) to perform frequency limiting, further reducing performance. Summary of the Invention

[0004] Therefore, it is necessary to provide an interface call frequency limiting method, apparatus, computer device, and storage medium that can improve performance in response to the above-mentioned technical problems.

[0005] An interface call frequency limiting method, the method comprising:

[0006] After the interface caller sends a call request for the target interface, the call frequency limiting query request corresponding to the target interface is obtained through the frequency limiting server that matches the interface caller.

[0007] The frequency limiting server obtains the cumulative call information of the interface caller to the target interface from the local shared memory area according to the call frequency limiting query request;

[0008] Obtain the frequency limiting control information corresponding to the interface caller from the shared memory area;

[0009] The accumulated call information is compared with the frequency limiting control information;

[0010] A frequency limiting response result is generated based on the comparison result; the frequency limiting response result is used to indicate whether the call request should be restricted.

[0011] An interface call frequency limiting device, the device comprising:

[0012] The query request acquisition module is used to acquire the call frequency limiting query request corresponding to the target interface through a frequency limiting server that matches the interface caller after the interface caller sends a call request for the target interface.

[0013] The local information acquisition module is used to acquire, based on the call frequency limiting query request, the cumulative call information of the interface caller to the target interface from the local shared memory area; and to acquire the frequency limiting control information corresponding to the interface caller from the shared memory area.

[0014] The comparison module is used to compare the accumulated call information with the frequency limiting control information;

[0015] The result generation module is used to generate a frequency limiting response result based on the comparison result; the frequency limiting response result is used to indicate whether the call request should be restricted.

[0016] In one embodiment, the local information acquisition module is further configured to determine the identifier of the interface caller that makes the call to the target interface based on the call frequency limiting query request; determine the region identifier based on the identifier of the interface caller and the identifier of the target interface, and search for the corresponding shared memory region locally according to the region identifier; and obtain the cumulative call information of the interface caller's calls to the target interface from the shared memory region.

[0017] In one embodiment, the local information acquisition module is further configured to acquire a frequency limiting period based on the found shared memory area; if a new frequency limiting period has not yet been entered, the step of acquiring the cumulative call information of the interface caller to the target interface from the shared memory area is executed.

[0018] In one embodiment, the interface call frequency limiting device further includes: a memory area creation module, used to recreate a shared memory area corresponding to the region identifier locally according to a locally preset frequency limiting configuration file if a new frequency limiting period is entered; the local information acquisition module is also used to acquire the cumulative call information of the interface caller calling the target interface from the recreated shared memory area.

[0019] In one embodiment, the interface call frequency limiting device further includes: a frequency limiting cycle determination module, used to obtain the creation time of the shared memory area from the found shared memory area; obtain a refresh time point based on the creation time and the frequency limiting cycle; if the current time point is less than or equal to the refresh time point, determine that a new refresh cycle has not yet been entered; if the current time point is greater than the refresh time point, determine that a new refresh cycle has been entered.

[0020] In one embodiment, the memory area creation module is further configured to, if no corresponding shared memory area is found, obtain the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file; create a shared memory area corresponding to the region identifier; write the frequency limiting control information into the created shared memory area; and record the cumulative call information of the interface caller calling the target interface through the shared memory area.

[0021] In one embodiment, the memory area creation module is further configured to obtain the target frequency limiting level to which the interface caller belongs from the frequency limiting configuration file; and obtain frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file.

[0022] In one embodiment, the frequency limiting configuration file includes frequency limiting control information under different frequency limiting levels configured for the target interface; the memory area creation module is further configured to search for frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting control information under different frequency limiting levels configured for the target interface.

[0023] In one embodiment, the memory area creation module is further configured to obtain the frequency limiting period corresponding to the target interface from the frequency limiting configuration file; and write the frequency limiting period into the created shared memory area.

[0024] In one embodiment, the cumulative call information includes the cumulative call count; the local information acquisition module is further configured to increase the cumulative call count recorded in the local shared memory area according to the call frequency limiting query request; and acquire the increased cumulative call count recorded in the shared memory area; wherein, the cumulative call count is the cumulative number of times the interface caller calls the target interface.

[0025] In one embodiment, the frequency limiting control information includes a call limit threshold; the comparison module is further configured to compare the acquired cumulative call count with the call limit threshold; the result generation module is further configured to generate a frequency limiting response result that does not limit the call request if the acquired cumulative call count is less than or equal to the call limit threshold; and generate a frequency limiting response result that limits the call request if the cumulative call count is greater than the call limit threshold.

[0026] In one embodiment, the interface call frequency limiting device further includes: a frequency limiting server determination module, configured to receive a call request sent by the interface caller for a target interface; in response to the call request, perform a hash operation on the identifier of the interface caller to generate a first hash value; and determine a frequency limiting server matching the interface caller from the candidate servers based on the first hash value and the second hash values ​​of each candidate frequency limiting server; wherein the second hash value is obtained by performing a hash operation on the identifier of the candidate frequency limiting server.

[0027] A computer device includes a memory and a processor. The memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps in the interface call frequency limiting method described in the embodiments of this application.

[0028] A computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps in the interface call frequency limiting method described in the embodiments of this application.

[0029] A computer program product or computer program includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps in the interface call frequency limiting method described in the embodiments of this application.

[0030] The aforementioned interface call frequency limiting method, device, computer equipment, and storage medium, after the interface caller sends a call request for the target interface, obtain the call frequency limiting query request corresponding to the target interface through a frequency limiting server matched with the interface caller, and determine the frequency limiting response result. In this way, the call frequency limiting query requests corresponding to different interface callers are distributed to various frequency limiting servers to determine the frequency limiting response result, eliminating the need to call a unified frequency limiting service. Instead, each frequency limiting server handles the processing independently, achieving decentralization and thus improving performance. Based on the call frequency limiting query request, the frequency limiting server obtains the cumulative call information of the interface caller to the target interface from its local shared memory area, and obtains the frequency limiting control information corresponding to the interface caller. It compares the cumulative call information with the frequency limiting control information, and generates a frequency limiting response result based on the comparison result to indicate whether to limit the call request. In this way, by obtaining information from the local shared memory area and performing calculations locally, the frequency limiting server has no external dependencies and performs pure local calculations, further improving performance. Attached Figure Description

[0031] Figure 1 This is a diagram illustrating the application environment of the interface call frequency limiting method in one embodiment;

[0032] Figure 2 This is a flowchart illustrating the interface call to the frequency limiting method in one embodiment;

[0033] Figure 3 This is a schematic diagram illustrating the matching relationship between the frequency limiting server and the interface caller in one embodiment;

[0034] Figure 4 This is a schematic diagram illustrating the information stored in a frequency limiting configuration file in one embodiment;

[0035] Figure 5 This is a schematic diagram illustrating the information stored in the frequency limiting configuration file in another embodiment;

[0036] Figure 6 This is a schematic diagram of information stored in a shared memory area in one embodiment;

[0037] Figure 7 This is a schematic diagram of the overall process for determining the frequency limiting response result in one embodiment;

[0038] Figure 8 This is a structural block diagram of an interface calling a frequency limiting device in one embodiment;

[0039] Figure 9 This is a block diagram of the interface calling frequency limiting device in another embodiment;

[0040] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0042] The interface call frequency limiting method provided in this application can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with interface server 104 via a network. Interface server 104 communicates with frequency limiting server 106 via a network. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. Interface server 104 and frequency limiting server 106 can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0043] Different interface servers 104 can provide different interfaces. When terminal 102 calls the target interface, it can send a call request to the corresponding interface server 104 that provides the target interface. Different frequency limiting servers 106 can be matched with different interface callers. A frequency limiting query request can be obtained through the frequency limiting server 106 matched with the interface caller, and a frequency limiting response result can be generated. Figure 1 As shown, frequency limiting server 1 is matched with interface caller A, and frequency limiting server 2 is matched with interface caller B. Whether interface caller A calls interface 1 provided by interface server 1 or interface 2 provided by interface server 2, the frequency limiting query request is obtained from frequency limiting server 1, which is matched with interface caller A. Similarly, whether interface caller B calls interface 1 provided by interface server 1 or interface 2 provided by interface server 2, the frequency limiting query request is obtained from frequency limiting server 2, which is matched with interface caller B.

[0044] Specifically, terminal 102 can send a call request to interface server 104 of the target interface. Interface server 104 can send a call frequency limiting query request to frequency limiting server 106 that matches the interface caller corresponding to terminal 102. Frequency limiting server 106 can obtain the cumulative call information of the interface caller to the target interface from its local shared memory area according to the call frequency limiting query request. Then, it can obtain the frequency limiting control information corresponding to the interface caller from the shared memory area, compare the cumulative call information with the frequency limiting control information, and generate a frequency limiting response result based on the comparison result. Frequency limiting server 106 can return the generated frequency limiting response result to interface server 104. Interface server 104 can determine whether to restrict the call request based on the received frequency limiting response result.

[0045] It is understood that the interface call frequency limiting methods in the various embodiments of this application can also be implemented using blockchain technology. For example, the target interface can be an interface provided by a node in the blockchain.

[0046] Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying platform, a platform product and service layer, and an application service layer.

[0047] In one embodiment, such as Figure 2 As shown, an interface call frequency limiting method is provided. This method can be executed by a frequency limiting server or implemented through interaction between a terminal, an interface server, and a frequency limiting server. This application embodiment applies this method to... Figure 1 Taking the frequency limiting server 106 as an example, the following steps are included:

[0048] Step 202: After the interface caller sends a call request for the target interface, the call frequency limiting query request corresponding to the target interface is obtained through the frequency limiting server matched with the interface caller.

[0049] In this context, the API caller is the party that invokes the target API. The target API is the API that the API caller requests to invoke. The call request is used to request the invocation of the target API. The frequency limiting server is the server that responds to call frequency limiting query requests to determine the frequency limiting response result. The call frequency limiting query request inquires whether call requests targeting the target API should be restricted. Frequency limiting refers to limiting the frequency of API calls made by an API caller to the same API or the number of calls made within a certain time period.

[0050] It is understandable that the call frequency limit query request corresponding to the target interface is used to inquire whether the target interface can be called.

[0051] In one embodiment, the target interface can be an interface that provides services. For example, the services may include at least one of search services and merchant services. In one embodiment, the target interface for providing merchant services may include at least one of card payment interface, direct debit agreement interface, and direct debit interface.

[0052] Specifically, the terminal corresponding to the interface caller can send a call request to the interface server of the target interface. The interface server can send a call frequency limiting query request to the frequency limiting server that matches the interface caller. The frequency limiting server that matches the interface caller can receive the call frequency limiting query request.

[0053] In one embodiment, different interface servers can provide different interfaces. The same interface server can provide at least one interface. For example, an order placement interface server can provide a card-swipe order placement interface. A deduction interface server can provide a deduction contract interface and a deduction payment interface. When calling the target interface, the interface caller can send a call request to the interface server providing the target interface through the terminal corresponding to the interface caller.

[0054] In one embodiment, different frequency limiting servers can be matched with different API callers. The same frequency limiting server can match at least one API caller. For example, merchant A and merchant C can be matched with frequency limiting server 1, and merchant B can be matched with frequency limiting server 2.

[0055] like Figure 3 As shown, whether Merchant A calls the card swipe order interface, the direct debit agreement interface, or the direct debit payment interface, the processing is handled by the frequency-limiting server 1 that matches Merchant A. Similarly, whether Merchant B calls the card swipe order interface, the direct debit agreement interface, or the direct debit payment interface, the processing is handled by the frequency-limiting server 2 that matches Merchant B.

[0056] In one embodiment, the interface server can determine the frequency limiting server that matches the interface caller based on the caller's identifier, and then send a call frequency limiting query request to the matching frequency limiting server.

[0057] The identifier of the API caller is used to uniquely identify the API caller.

[0058] In one embodiment, the identifier of the API caller can be the caller's IP address. For example, it could be the IP address used by the user calling the target API that provides the search service.

[0059] In another embodiment, the identifier of the API caller can be the API caller's account. For example, it could be the merchant account of the merchant calling the target API that provides merchant services.

[0060] In other embodiments, the identifier of the interface caller may also be in other forms, without limitation.

[0061] In one embodiment, the interface server can use a consistent hashing algorithm (i.e., a consistent hash algorithm) to determine the frequency limiting server that matches the interface caller based on the caller's identifier.

[0062] Step 204: The frequency limiting server retrieves the cumulative call information of the interface caller to the target interface from the local shared memory area based on the call frequency limiting query request.

[0063] Shared memory refers to a memory area that can be accessed by multiple processes, and multiple programs can also pass information through shared memory. Accumulated call information is used to record the calls made by the caller to the target interface.

[0064] In one embodiment, the cumulative call information may include the cumulative number of calls. The cumulative number of calls is the total number of times the interface caller has made calls to the target interface.

[0065] In another embodiment, the cumulative call information may include the call frequency. Here, represents the frequency at which the interface caller invokes the target interface.

[0066] In other embodiments, the accumulated call information may also be other forms of information, without limitation.

[0067] Specifically, the frequency limiting server can determine the target interface and the interface caller that calls the target interface based on the frequency limiting query request. Then, it can search the local shared memory area corresponding to the interface caller and the target interface, and obtain the cumulative call information of the interface caller to the target interface from the found shared memory area.

[0068] In one embodiment, the cumulative call information for different interface callers can be recorded in different shared memory areas. The cumulative call information for the same interface caller calling different interfaces can also be recorded in different shared memory areas. That is, the shared memory areas retrieved by the same interface caller when calling different interfaces, or by different interface callers when calling interfaces, will be different.

[0069] In one embodiment, the frequency limiting server can update the cumulative call information recorded in the local shared memory area based on the call frequency limiting query request, and then obtain the updated cumulative call information recorded in the shared memory area.

[0070] In one embodiment, the frequency limiting server can first obtain the frequency limiting period from the found shared memory area, and determine whether a new frequency limiting period has begun based on the frequency limiting period. If a new frequency limiting period has begun, the server retrieves the cumulative call information of the interface caller to the target interface from the local shared memory area. If a new frequency limiting period has begun, the server recreates the shared memory area corresponding to the interface caller and the target interface locally, and retrieves the cumulative call information of the interface caller to the target interface from the recreated shared memory area.

[0071] In one embodiment, when operating shared memory, the frequency limiting server can use a semaphore mechanism to avoid conflicts between different processes accessing shared memory. A semaphore is a facility used in a multi-threaded environment to ensure that two or more critical code segments are not called concurrently.

[0072] Step 206: Obtain the frequency limiting control information corresponding to the interface caller from the shared memory area.

[0073] Among them, frequency limiting control information is preset information that limits the accumulated call information.

[0074] In one embodiment, the frequency limiting control information may include a frequency limiting threshold. The frequency limiting threshold is a threshold used for limiting.

[0075] In one embodiment, the frequency limiting threshold may include a call limit threshold. The call limit threshold is a preset limit on the cumulative number of calls.

[0076] In another embodiment, the frequency limiting threshold may include a call frequency threshold. The call frequency threshold is a preset limit for the call frequency.

[0077] In other embodiments, the frequency limiting control information may be other information, without limitation.

[0078] Specifically, because the frequency limiting server searches for the shared memory area corresponding to the interface caller and the target interface based on the target interface and the interface caller, the frequency limiting control information stored in the found shared memory area is the frequency limiting control information corresponding to the interface caller. Therefore, the frequency limiting server can directly obtain the frequency limiting control information corresponding to the interface caller from the found shared memory area.

[0079] Step 208: Compare the accumulated call information with the frequency limiting control information.

[0080] In one embodiment, the frequency limiting server can compare the updated cumulative number of calls with the call limit threshold.

[0081] In another embodiment, the frequency limiting server can compare the obtained updated call frequency with the frequency limit threshold.

[0082] Step 210: Generate a frequency limiting response result based on the comparison result; the frequency limiting response result is used to indicate whether to limit the call request.

[0083] Specifically, the frequency limiting server can generate a frequency limiting response result based on the comparison result, and then send the frequency limiting response result to the interface server. The interface server can determine whether to restrict the call request based on the frequency limiting response result.

[0084] The interface server that sends the frequency limiting response result to is the interface server that receives the call request and sends the call frequency limiting query request to the frequency limiting server.

[0085] In one embodiment, if the accumulated call information is less than or equal to the frequency limiting control information, a frequency limiting response result that does not limit call requests is generated. If the accumulated call information is greater than the frequency limiting control information, a frequency limiting response result that limits call requests is generated.

[0086] In one embodiment, if the frequency limiting response result is that the call request is not limited, the interface server can respond to the call request and provide the target interface call service to the terminal of the interface caller.

[0087] In another embodiment, if the frequency limiting response results in a restricted call request, the interface server may reject the caller's call request for the target interface. In one embodiment, the interface server may send an interface call failure message to the caller's terminal.

[0088] In the aforementioned interface call frequency limiting method, after the interface caller sends a call request for the target interface, a frequency limiting server matched with the interface caller obtains the call frequency limiting query request corresponding to the target interface and determines the frequency limiting response result. This distributes the call frequency limiting query requests from different interface callers to various frequency limiting servers to determine the frequency limiting response result, eliminating the need to call a unified frequency limiting service. Instead, each frequency limiting server handles the processing independently, achieving decentralization and thus improving performance. Based on the call frequency limiting query request, the frequency limiting server retrieves the cumulative call information of the interface caller to the target interface from its local shared memory area and obtains the corresponding frequency limiting control information. It compares the cumulative call information with the frequency limiting control information and generates a frequency limiting response result based on the comparison result, indicating whether to limit the call request. This method, where the frequency limiting server retrieves information from its local shared memory area and performs calculations locally without external dependencies, further improves performance through purely local computation. Furthermore, by using shared memory, security can be improved by combining it with the security mechanisms provided by the operating system. This eliminates the need for a separate security scheme and avoids the high complexity caused by the traditional unified frequency limiting service requiring authentication of the caller to improve security. It also makes it easier to ensure security.

[0089] In one embodiment, the frequency limiting server retrieves the cumulative call information of the interface caller to the target interface from the local shared memory area based on the call frequency limiting query request. This includes: the frequency limiting server determining the identifier of the interface caller to the target interface based on the call frequency limiting query request; determining the region identifier based on the identifier of the interface caller and the identifier of the target interface, and searching for the corresponding shared memory area locally according to the region identifier; and retrieving the cumulative call information of the interface caller to the target interface from the shared memory area.

[0090] Among them, the region identifier is used to uniquely identify the shared memory region.

[0091] Specifically, the frequency limiting server can determine the identifier of the target interface and the identifier of the interface caller that calls the target interface based on the frequency limiting query request. Then, based on the identifier of the interface caller and the identifier of the target interface, it determines the region identifier, searches for the shared memory region corresponding to the region identifier locally, and then obtains the cumulative call information of the interface caller to the target interface from the found shared memory region.

[0092] In one embodiment, the frequency limiting server can combine the identifier of the interface caller and the identifier of the target interface to obtain a region identifier. For example, if the identifier of the interface caller is "Merchant A" and the identifier of the target interface is "Card Swiping Order Interface", then the frequency limiting server can combine "Merchant A" and "Card Swiping Order Interface" to obtain "Merchant A_Card Swiping Order Interface" as the region identifier.

[0093] In one embodiment, the region identifier is the key corresponding to the shared memory area. For example, in the above example, if "Merchant A_Card Swiping Order Interface" is obtained as the region identifier, then based on "key=Merchant A_Card Swiping Order Interface", a shared memory area with a matching key value is searched locally. Figure 6 As shown, this is the shared memory area found based on "key=merchant A_card swipe order interface".

[0094] In the above embodiments, the frequency limiting server can determine the region identifier based on the identifier of the interface caller and the identifier of the target interface, and search for the corresponding shared memory region locally according to the region identifier. It can then obtain the accumulated call information from the searched shared memory region. This allows the accumulated call information corresponding to different interface callers or the same interface caller calling different interfaces to be stored in different shared memory regions. This regional storage facilitates searching and can efficiently record accumulated call information. Searching for the corresponding shared memory region based on the region identifier improves search efficiency.

[0095] In one embodiment, the method further includes: obtaining a frequency limiting period based on the found shared memory region; if a new frequency limiting period has not yet begun, performing the step of obtaining cumulative call information of the interface caller calling the target interface from the shared memory region.

[0096] The frequency limiting period is the period during which the accumulated call information in the shared memory area is recorded. After each frequency limiting period, the accumulated call information recorded in the shared memory area needs to be refreshed.

[0097] Specifically, before retrieving the cumulative call information of the interface caller to the target interface from the shared memory area, the frequency limiting server can first obtain the frequency limiting period from the found shared memory area and determine whether a new frequency limiting period has begun based on the frequency limiting period. If a new frequency limiting period has not begun, the step of retrieving the cumulative call information of the interface caller to the target interface from the shared memory area is executed.

[0098] In one embodiment, the frequency limiting period can be a duration information. The frequency limiting period can be a duration information set in any time unit. For example, the frequency limiting period is 10 seconds.

[0099] In the above embodiments, before obtaining the cumulative call information, the frequency limiting server can first obtain the frequency limiting period. If a new frequency limiting period has not yet been entered, the cumulative call information is obtained, thereby enabling the cumulative call information within each frequency limiting period to be restricted. This avoids the same interface caller making high-frequency calls to the interface within a certain period of time, thus achieving accurate frequency limiting for the calls made by the interface caller to the target interface.

[0100] In one embodiment, the method further includes: if a new frequency limiting period is entered, recreating the shared memory area corresponding to the region identifier locally according to a locally preset frequency limiting configuration file. In this embodiment, obtaining the cumulative call information of the interface caller to the target interface from the shared memory area includes: obtaining the cumulative call information of the interface caller to the target interface from the recreated shared memory area.

[0101] The frequency limiting configuration file is a file used to store information that needs to be written to the created shared memory area.

[0102] In one embodiment, the frequency limiting configuration file can be a formatted JSON (JavaScript Object Notation) file.

[0103] In one embodiment, the information stored in the frequency limiting configuration file that needs to be written to the created shared memory area may include frequency limiting control information.

[0104] In another embodiment, the information stored in the frequency limiting configuration file that needs to be written to the created shared memory area may include frequency limiting control information and frequency limiting period.

[0105] Specifically, before retrieving the cumulative call information of the interface caller to the target interface from the shared memory area, the frequency limiting server can first obtain the frequency limiting period from the found shared memory area and determine whether a new frequency limiting period has begun based on the frequency limiting period. If a new frequency limiting period has begun, the frequency limiting server can recreate the shared memory area corresponding to the region identifier locally according to the locally preset frequency limiting configuration file. Then, the frequency limiting server can update the cumulative call information in the newly created shared memory area and obtain the updated cumulative call information recorded in the shared memory area.

[0106] In one embodiment, the cumulative call information includes the cumulative call count. The cumulative call count in the recreated shared memory area is 0. The rate limiting server can increment the cumulative call count in the recreated shared memory area and obtain the incremented cumulative call count recorded in the shared memory area.

[0107] In one embodiment, the frequency limiting server can recreate the shared memory area corresponding to the region identifier locally, obtain the frequency limiting control information corresponding to the interface caller from the frequency limiting configuration file, and write the obtained frequency limiting control information into the recreated shared memory area.

[0108] In one embodiment, the frequency limiting server can obtain the frequency limiting period corresponding to the target interface from the frequency limiting configuration file and write the frequency limiting period into the newly created shared memory area.

[0109] In one embodiment, the specific implementation of the step in which the frequency limiting server recreates the shared memory region corresponding to the region identifier locally according to the locally preset frequency limiting configuration file is the same as the specific implementation of the step in this application where the frequency limiting server creates the shared memory region when no corresponding shared memory region is found, and will not be repeated here.

[0110] In the above embodiments, if a new frequency limiting cycle is entered, the frequency limiting server can recreate the shared memory area corresponding to the region identifier locally according to the local preset frequency limiting configuration file. Then, based on the recreated shared memory area, it can obtain the accumulated call information and perform subsequent processing, thereby limiting the accumulated call information in each round of frequency limiting cycle. This avoids the same interface caller from making high-frequency calls to the interface within a certain period of time, thus achieving accurate frequency limiting for the calls made by the interface caller to the target interface.

[0111] In one embodiment, the method further includes: obtaining the creation time of the shared memory region from the found shared memory region; obtaining the refresh time point based on the creation time and the frequency limiting period; determining that a new refresh period has not yet been entered if the current time point is less than or equal to the refresh time point; and determining that a new refresh period has been entered if the current time point is greater than the refresh time point.

[0112] The creation time is the point in time when the shared memory area is created. The refresh time is the point in time when the shared memory area is refreshed.

[0113] Specifically, the frequency limiting server can obtain the creation time of the shared memory area from the found shared memory area, then calculate the refresh time point based on the creation time and the frequency limiting cycle, and compare the refresh time point with the current time point to determine whether a new frequency limiting cycle has begun. If the current time point is less than or equal to the refresh time point, the frequency limiting server can determine that a new frequency limiting cycle has not yet begun. If the current time point is greater than the refresh time point, the frequency limiting server can determine that a new frequency limiting cycle has begun. Here, the current time point refers to the current time.

[0114] In one embodiment, the frequency limiting server can add the creation time to the frequency limiting period to obtain the refresh time. For example, if the creation time is 3:10:00 and the frequency limiting period is 10 seconds, then the refresh time is 3:10:10.

[0115] In one embodiment, the frequency limiting server can obtain the creation time and the current time from the shared memory area. For example... Figure 6 As shown, the shared memory area stores the creation time (Createtime), the current time (Updatetime), and the frequency limiting period (Refreshtime). The frequency limiting server can obtain the creation time, the current time, and the frequency limiting period from the shared memory area, add the creation time and the frequency limiting period to obtain the refresh time, and then compare the refresh time with the current time.

[0116] In one embodiment, when creating a shared memory region, the frequency limiting server can write the creation time as the creation time into the created shared memory region.

[0117] In one embodiment, the current point in time in the shared memory area can change over time.

[0118] In the above embodiments, the frequency limiting server can determine the refresh time point based on the creation time and the frequency limiting cycle. Then, based on the relationship between the refresh time point and the current time point, it can determine whether a new frequency limiting cycle has begun. This enables timing through local shared memory, thereby limiting the cumulative call information within each frequency limiting cycle. This avoids the same interface caller making high-frequency calls to the interface within a certain period of time, thus achieving accurate frequency limiting for the calls made by the interface caller to the target interface.

[0119] In one embodiment, the method further includes: if no corresponding shared memory region is found, obtaining the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file; creating a shared memory region corresponding to the region identifier, writing the frequency limiting control information into the created shared memory region, and recording the cumulative call information of the interface caller calling the target interface through the shared memory region.

[0120] Specifically, if no corresponding shared memory area is found, the frequency limiting server can obtain the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file, create a shared memory area corresponding to the area identifier, write the frequency limiting control information into the created shared memory area, and then the frequency limiting server can execute the cumulative call information and subsequent steps obtained from the shared memory area for the interface caller to call the target interface.

[0121] In one embodiment, the cumulative call information includes the cumulative call count. The frequency limiting server can set the cumulative call count in the created shared memory area to 0, and then increment the cumulative call count in the created shared memory area, and then obtain the incremented cumulative call count recorded in the shared memory area.

[0122] It is understandable that if no shared memory region corresponding to the region identifier is found, it means that this call is the first time the caller of this interface has called the target interface. That is, no corresponding shared memory region has been created for the caller of this interface to call the target interface in the past.

[0123] In the above embodiments, if no corresponding shared memory area is found, the frequency limiting server can obtain frequency limiting control information from the local frequency limiting configuration file, create a shared memory area and write the frequency limiting control information. In this way, the server can record the cumulative call information of the interface caller to the target interface through the created shared memory area, and determine the frequency limiting response result based on the frequency limiting control information and the recorded cumulative call information. The server stores the information in different areas, which is convenient for searching and can efficiently record the cumulative call information. The server can also search for the corresponding shared memory area based on the area identifier, which improves the search efficiency.

[0124] In one embodiment, obtaining the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file includes: obtaining the target frequency limiting level to which the interface caller belongs from the frequency limiting configuration file; and obtaining the frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file.

[0125] The frequency limiting level refers to the degree of frequency limiting imposed on API callers. Different frequency limiting levels result in different levels of frequency limiting; the higher the level, the greater the frequency limiting.

[0126] Specifically, the frequency limiting configuration file stores the interface callers included under different frequency limiting levels, and stores the corresponding frequency limiting control information configured for each frequency limiting level. The frequency limiting control information is different for different frequency limiting levels. The frequency limiting server can obtain the target frequency limiting level to which the interface caller belongs from the frequency limiting configuration file, and then obtain the frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file.

[0127] like Figure 4 The image shows information from a frequency limiting configuration file in one embodiment. In this frequency limiting configuration file, merchant A's frequency limiting level is "Group 0", merchant B's frequency limiting level is "Group 1", the frequency limit threshold configured for "Group 0" is 1000, and the frequency limit threshold configured for "Group 1" is 2000.

[0128] Assuming the API caller is merchant A, and in the frequency limiting configuration file, merchant A belongs to frequency limiting level "Group 0", and the frequency limit threshold corresponding to frequency limiting level "Group 0" is 1000, then the frequency limiting server can first select from... Figure 4 The frequency limiting configuration file shows that merchant A belongs to the frequency limiting level of "Group 0". Then the frequency limiting server can obtain the frequency limit threshold of 1000 corresponding to "Group 0" from the frequency limiting configuration file.

[0129] In the above embodiments, the target frequency limiting level of the interface caller is determined according to the frequency limiting configuration file, and then the frequency limiting control information corresponding to the target frequency limiting level is obtained from the frequency limiting configuration file. This enables the frequency limiting degree for each interface caller to be classified, with lower frequency limiting levels set for higher priority interface callers and higher frequency limiting levels set for lower priority interface callers. This prioritizes providing smoother interface services to high priority interface callers and realizes flexible frequency limiting for interface callers of different priorities.

[0130] In one embodiment, the frequency limiting configuration file includes frequency limiting control information for different frequency limiting levels configured for the target interface. In this embodiment, obtaining the frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file includes: searching for the frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting control information for different frequency limiting levels configured for the target interface.

[0131] Specifically, the frequency limiting configuration file stores the interface callers included under different frequency limiting levels, and stores the frequency limiting control information configured for each interface under different frequency limiting levels. The frequency limiting server can obtain the target frequency limiting level to which the interface caller belongs from the frequency limiting configuration file, and then find the frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting control information configured for different frequency limiting levels for the target interface in the frequency limiting configuration file.

[0132] like Figure 5 The image shows information from a frequency limiting configuration file in one embodiment. In this configuration file, Merchant A's frequency limiting level is "Group 0", and Merchant B's frequency limiting level is "Group 1". The frequency limit threshold for "Group 0" under the card swipe order interface is 1000, and the frequency limit threshold for "Group 1" is 2000. The frequency limit threshold for "Group 0" under the direct debit contract interface is 5000, and the frequency limit threshold for "Group 1" is 6000.

[0133] Assuming the API caller is merchant B, and the target API is the direct debit / contract API, the frequency limiting server can adjust the frequency based on the following: Figure 5 The frequency limiting configuration file shown determines that Merchant B belongs to the frequency limiting level "Group 1". Then, the frequency limiting threshold of "Group 1" is obtained from the information configured for the deduction contract interface, which is 6000.

[0134] In the above embodiments, the frequency limiting server searches for frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting control information configured for different frequency limiting levels for the target interface. This not only enables the grading of frequency limiting for each interface caller, achieving flexible frequency limiting for interface callers of different priorities, but also enables frequency limiting according to the interface, resulting in finer granularity of frequency limiting control.

[0135] In one embodiment, the method further includes: obtaining the frequency limiting period corresponding to the target interface from the frequency limiting configuration file; and writing the frequency limiting period into a created shared memory area.

[0136] Specifically, the frequency limiting configuration file stores the frequency limiting periods configured for each interface. The frequency limiting server can obtain the frequency limiting period corresponding to the target interface from the frequency limiting configuration file, and then write the obtained frequency limiting period into the created shared memory area.

[0137] like Figure 5 As shown, in the frequency limiting configuration file, the frequency limiting period for the card swipe order interface is configured as 10 seconds, and the frequency limiting period for the direct debit contract interface is configured as 20 seconds. Assuming the target interface is the card swipe order interface, the frequency limiting server can obtain the corresponding frequency limiting period of 10 seconds for the card swipe order interface from the frequency limiting configuration file, and then write the frequency limiting period of 10 seconds into the created shared memory area.

[0138] In the above embodiments, the frequency limiting period for different interfaces can be flexibly configured in the frequency limiting configuration file. The frequency limiting period corresponding to the target interface is obtained from the configuration file and then written into the created shared memory area. The refresh of the shared memory area can be controlled based on the frequency limiting period in the local shared memory area, thereby limiting the accumulated call information within each frequency limiting period. This prevents the same interface caller from making high-frequency calls to the interface within a certain period, thus achieving accurate frequency limiting for calls to the target interface by the interface caller. Furthermore, since the computation is performed locally without external dependencies, pure local computation improves performance.

[0139] In one embodiment, the cumulative call information includes the cumulative call count. In this embodiment, the frequency limiting server obtains the cumulative call information of the interface caller calling the target interface from the local shared memory area according to the call frequency limiting query request, including: the frequency limiting server increments the cumulative call count recorded in the local shared memory area according to the call frequency limiting query request; wherein, the cumulative call count is the cumulative number of times the interface caller calls the target interface; and the increased cumulative call count is obtained from the shared memory area.

[0140] Specifically, the frequency limiting server can determine the identifier of the target interface and the identifier of the interface caller that calls the target interface based on the frequency limiting query request. Then, it determines the region identifier based on the identifier of the interface caller and the identifier of the target interface, and searches for the corresponding shared memory region locally according to the region identifier. Finally, it increments the cumulative call count recorded in the found shared memory region and obtains the incremented cumulative call count recorded in the shared memory region.

[0141] In one embodiment, the frequency limiting server can increment the cumulative call count recorded in the shared memory area by 1.

[0142] In one embodiment, the frequency limiting server can first read the cumulative call count from the shared memory area, then increment the read cumulative call count to obtain the incremented cumulative call count, and write the incremented cumulative call count into the shared memory area.

[0143] In another embodiment, the frequency limiting server can directly increment the cumulative call count in the shared memory area and then read the incremented cumulative call count from the shared memory area.

[0144] In the above embodiments, the cumulative call information includes the cumulative call count. The frequency limiting server can increment the cumulative call count in the shared memory area and then obtain the incremented cumulative call count recorded in the shared memory area. This allows for accurate recording of the number of calls made by the interface caller to the target interface, achieving accurate frequency limiting. Furthermore, since the computation is performed locally without external dependencies, pure local computation improves performance.

[0145] In one embodiment, the frequency limiting control information includes a call limit threshold. In this embodiment, comparing the accumulated call information with the frequency limiting control information includes comparing the acquired accumulated call count with the call limit threshold. In this embodiment, generating a frequency limiting response result based on the comparison result includes: if the acquired accumulated call count is less than or equal to the call limit threshold, a frequency limiting response result that does not restrict call requests is generated; if the accumulated call count is greater than the call limit threshold, a frequency limiting response result that restricts call requests is generated.

[0146] The response result for not limiting call requests indicates that no limit will be applied to the call requests. The response result for limiting call requests indicates that limit will be applied to the call requests.

[0147] Specifically, after obtaining the increased cumulative call count, the rate-limiting server compares the increased cumulative call count with the call limit threshold to determine the rate-limiting response result. If the increased cumulative call count is less than or equal to the call limit threshold, a rate-limiting response result that does not restrict call requests is generated. If the increased cumulative call count is greater than the call limit threshold, a rate-limiting response result that restricts call requests is generated.

[0148] For example, if the threshold for the number of calls is 1000, it means that within the frequency limiting period, the cumulative number of calls made by the caller to the target interface cannot exceed 1000. If the cumulative number of calls is greater than 1000, a frequency limiting response result is generated to instruct the interface server to limit the call requests.

[0149] like Figure 6As shown, the shared memory area stores the number of calls limit (Bucket_limit) and the cumulative number of calls (Consumed_token). The frequency limiting server can increase the cumulative number of calls in the shared memory area, obtain the number of calls limit in the shared memory area and the increased cumulative number of calls, and then compare the increased cumulative number of calls with the number of calls limit.

[0150] In the above embodiments, the frequency limiting server can compare the cumulative number of calls with the call limit threshold to determine the corresponding frequency limiting response result, thereby limiting the number of calls made by the interface caller to the target interface and achieving accurate frequency limiting. Furthermore, since the computation is performed locally without external dependencies, pure local computation improves performance.

[0151] In one embodiment, such as Figure 6 As shown, the shared memory area stores the creation time (Createtime), current time (Updatetime), frequency limiting period (Refreshtime), call limit threshold (Bucket_limit), and cumulative call count (Consumed_token). The frequency limiting server can monitor time based on the creation time, current time, and frequency limiting period in the shared memory area, and recreate the shared memory area each time a new frequency limiting period begins. The frequency limiting server can also monitor the calls made to the target interface by the caller within the current frequency limiting period based on the call limit threshold and cumulative call count in the shared memory area. If the cumulative call count exceeds the call limit threshold within the current frequency limiting period, a frequency limiting response result is generated to restrict the call requests.

[0152] like Figure 7 The diagram illustrates the overall process of the frequency limiting server determining the frequency limiting response result in response to a frequency limiting query request in various embodiments of this application, specifically including the following steps:

[0153] Step 702: The frequency limiting server can determine the target interface and the interface caller that calls the target interface based on the frequency limiting query request.

[0154] Step 704: The frequency limiting server can determine the region identifier based on the identifier of the target interface and the identifier of the interface caller.

[0155] Step 706: The frequency limiting server can locate the corresponding shared memory area locally according to the area identifier.

[0156] Step 708: Determine if a shared memory region has been found. If yes, proceed to steps 710 to 718. If no, first proceed to steps 724 to 726, then proceed to steps 714 to 718.

[0157] Step 710: The frequency limiting server can obtain the frequency limiting period from the found shared memory area.

[0158] Step 712: Determine whether a new frequency limiting cycle has begun. If not, proceed to steps 714 to 718. If yes, first proceed to steps 720 to 722, then proceed to steps 714 to 718.

[0159] Step 714: The frequency limiting server can update the accumulated call information in the shared memory area.

[0160] Step 716: Compare the updated cumulative call information with the frequency limiting control information in the shared memory area.

[0161] Step 718: Generate frequency limiting response results based on the comparison results.

[0162] Step 720: The frequency limiting server can obtain the frequency limiting period and frequency limiting control information from the local frequency limiting configuration file.

[0163] Step 722: The frequency limiting server can recreate the shared memory area based on the frequency limiting period and frequency limiting control information.

[0164] Step 724: Obtain the frequency limiting period and frequency limiting control information from the local frequency limiting configuration file.

[0165] Step 726: Create a shared memory area based on the frequency limiting period and frequency limiting control information.

[0166] In one embodiment, the frequency limiting server matching the interface caller is determined by the interface server through a frequency limiting service determination step. In this embodiment, the frequency limiting service determination step includes: receiving a call request sent by the interface caller for a target interface through the interface server; in response to the call request, performing a hash operation on the identifier of the interface caller to generate a first hash value; and determining the frequency limiting server matching the interface caller from the candidate servers based on the first hash value and the second hash values ​​of each candidate frequency limiting server; wherein the second hash value is obtained by hashing the identifier of the candidate frequency limiting server.

[0167] The identifier of the candidate frequency limiting server is used to uniquely identify the candidate frequency limiting server.

[0168] In one embodiment, the identifier of the frequency limiting server can be any one of the following: the IP address and hostname of the frequency limiting server.

[0169] Specifically, the interface server can perform a hash operation on the identifiers of each candidate frequency-limiting server to obtain a second hash value corresponding to each candidate frequency-limiting server. The interface server can receive a call request sent by the interface caller for the target interface, determine the caller's identifier based on the call request, and then perform a hash operation on the caller's identifier to generate a first hash value. Then, the interface server can select the candidate frequency-limiting server corresponding to the second hash value that is closest to the first hash value as the frequency-limiting server that matches the interface server.

[0170] In one embodiment, the interface server can organize the entire hash space into a virtual ring (i.e., a hash ring), and map each candidate frequency-limiting server to a corresponding position on the hash ring based on each second hash value. The interface server can map the interface caller to a corresponding position on the hash ring based on the first hash value, and then search for a candidate frequency-limiting server clockwise on the hash ring starting from that position, and take the first candidate frequency-limiting server found as the frequency-limiting server that matches the interface caller.

[0171] In the above embodiments, the interface server can perform a hash operation on the identifier of the interface caller to obtain a first hash value, and determine the frequency limiting server that matches the interface caller based on the first hash value and the second hash values ​​of each candidate frequency limiting server. In this way, a matching frequency limiting server can be uniquely determined based on the identifier of the interface caller, thereby distributing the call frequency limiting query requests for different interface callers to the target interface to various frequency limiting servers for processing. Different frequency limiting servers handle the call frequency limiting query requests corresponding to different interface callers respectively, without calling a unified frequency limiting service. Instead, each frequency limiting server handles the requests independently, thereby improving performance.

[0172] This application also provides an application scenario where merchants call interfaces such as card swiping order interface, direct debit agreement interface, or direct debit interface provided by the mobile payment platform to implement corresponding functions on the mobile payment platform. This application scenario applies the aforementioned interface call frequency limiting method. Specifically, the application of this interface call frequency limiting method in this scenario is as follows:

[0173] When Merchant A needs to implement the card swipe order function through a mobile payment platform, the terminal used by Merchant A can send a call request to the interface server corresponding to the card swipe order interface. Based on the call request, the interface server corresponding to the card swipe order interface can determine the frequency limiting server matching Merchant A as frequency limiting server 1, and send a frequency limiting query request to frequency limiting server 1. Specifically, the interface server corresponding to the card swipe order interface can determine Merchant A's merchant number based on the call request, and then determine the frequency limiting server matching Merchant A as frequency limiting server 1 based on the merchant number, and send a frequency limiting query request to frequency limiting server 1.

[0174] You can pre-define the corresponding frequency limiting levels for each merchant in the frequency limiting configuration file, and configure the corresponding number of times limit for each frequency limiting level. You can also configure the number of times limit for each frequency limiting level under different interfaces.

[0175] Frequency limiting server 1 can determine the target interface as the card swipe order interface and the caller as merchant A based on the frequency limiting query request. Based on merchant A and the card swipe order interface, the region identifier is determined to be "Merchant A_Card Swipe Order Interface". Then, it searches for the corresponding shared memory region locally according to this region identifier. Frequency limiting server 1 can obtain the frequency limiting period from the found shared memory region. If a new frequency limiting period has begun, frequency limiting server 1 can first recreate the shared memory region corresponding to the region identifier locally according to the preset frequency limiting configuration file, then increment the accumulated call count in the newly created shared memory region, and obtain the increased accumulated call count recorded in the newly created shared memory region. If a new frequency limiting period has not begun, frequency limiting server 1 does not need to recreate the shared memory region; instead, it can directly increment the accumulated call count in the found shared memory region and obtain the increased accumulated call count recorded in the shared memory region. Frequency limiting server 1 can obtain the call limit threshold from the shared memory area and compare the cumulative call count with the call limit threshold. If the cumulative call count is less than or equal to the call limit threshold, a frequency limiting response result that does not restrict call requests is generated. If the cumulative call count is greater than the call limit threshold, a frequency limiting response result that restricts call requests is generated.

[0176] Frequency limiting server 1 can send the generated frequency limiting response result to the interface server corresponding to the card swipe order interface. The interface server corresponding to the card swipe order interface can determine whether to restrict the call request based on the frequency limiting response result. If the frequency limiting response result is not to restrict the call request, the interface server corresponding to the card swipe order interface can respond to the call request and provide the card swipe order interface call service to the terminal provided by merchant A to realize the card swipe order function. If the frequency limiting response result is to restrict the call request, the interface server corresponding to the card swipe order interface can reject merchant A's call request for the card swipe order interface and send an interface call failure prompt message to merchant A's terminal.

[0177] For example, if the frequency limiting period is 10 seconds and the number of calls is limited to 1000, then the above application can ensure that merchant A does not make more than 1000 calls to the card swipe order interface within 10 seconds.

[0178] When Merchant B needs to implement the direct debit agreement function through a mobile payment platform, the terminal used by Merchant B can send a call request to the interface server corresponding to the direct debit agreement interface. The interface server corresponding to the direct debit agreement interface can determine the frequency limiting server matching Merchant B as frequency limiting server 2 based on the call request, and send a call frequency limiting query request to frequency limiting server 2. Frequency limiting server 2 can also execute the interface call frequency limiting method in the various embodiments of this application, determine the frequency limiting response result, and send the frequency limiting response result to the interface server corresponding to the direct debit agreement interface. The interface server corresponding to the direct debit agreement interface can determine whether to restrict the call request based on the frequency limiting response result.

[0179] This application also provides another application scenario where a user calls the search function interface provided by a search engine to perform a search. In this scenario, the aforementioned interface call frequency limiting method is applied. Specifically, the application of the interface call frequency limiting method in this scenario is as follows:

[0180] When user C searches on a search engine, the user's terminal can send a call request to the search interface server. Based on the call request, the search interface server determines the frequency limiting server matching the user as frequency limiting server 3, and sends a frequency limiting query request to frequency limiting server 3. Specifically, the search interface server can determine the user's IP address based on the call request, and then, based on the IP address, determine the frequency limiting server matching the user as frequency limiting server 3, and send a frequency limiting query request to frequency limiting server 3.

[0181] The historical search frequency of each user's corresponding IP address can be statistically analyzed in advance. Based on the statistical results, each user can be assigned to a corresponding frequency-limiting level and written into the frequency-limiting configuration file. Different frequency-limiting thresholds can be configured for different frequency-limiting levels in the frequency-limiting configuration file. Furthermore, the frequency-limiting thresholds for each frequency-limiting level can be allocated and configured under different interfaces. Frequency-limiting server 3 can locate the corresponding shared memory area based on the user and the search interface, and execute the interface call frequency-limiting method in the embodiments of this application to determine the frequency-limiting response result. Then, frequency-limiting server 3 can return the frequency-limiting response result to the server of the search interface.

[0182] It should be understood that although the steps in each flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in each flowchart may include multiple steps or stages, which are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.

[0183] In one embodiment, such as Figure 8 As shown, an interface call frequency limiting device 800 is provided. This device can be a software module, a hardware module, or a combination of both, integrated into a computer device. Specifically, the device includes: an inquiry request acquisition module 802, a local information acquisition module 804, a comparison module 806, and a result generation module 808, wherein:

[0184] The query request acquisition module 802 is used to obtain the call frequency limiting query request corresponding to the target interface through the frequency limiting server matched with the interface caller after the interface caller sends a call request for the target interface.

[0185] The local information acquisition module 804 is used to obtain the cumulative call information of the interface caller to the target interface from the local shared memory area according to the call frequency limiting query request; and to obtain the frequency limiting control information corresponding to the interface caller from the shared memory area.

[0186] The comparison module 806 is used to compare the accumulated call information with the frequency limiting control information.

[0187] The result generation module 808 is used to generate a frequency limiting response result based on the comparison result; the frequency limiting response result is used to indicate whether to limit the call request.

[0188] In one embodiment, the local information acquisition module 804 is further configured to determine the identifier of the interface caller that makes the call to the target interface based on the call frequency limiting query request; determine the region identifier based on the identifier of the interface caller and the identifier of the target interface, and search for the corresponding shared memory region locally according to the region identifier; and obtain the cumulative call information of the interface caller making the call to the target interface from the shared memory region.

[0189] In one embodiment, the local information acquisition module 804 is further configured to acquire the frequency limiting period based on the found shared memory area; if a new frequency limiting period has not yet been entered, the step of acquiring the cumulative call information of the interface caller to the target interface from the shared memory area is executed.

[0190] In one embodiment, the interface call frequency limiting device 800 further includes:

[0191] The memory area creation module 810 is used to recreate the shared memory area corresponding to the area identifier locally according to the local preset frequency limiting configuration file if a new frequency limiting period is entered. The local information acquisition module is also used to obtain the cumulative call information of the interface caller to the target interface from the recreated shared memory area.

[0192] In one embodiment, the interface call frequency limiting device 800 further includes:

[0193] The frequency limiting cycle determination module 812 is used to obtain the creation time of the shared memory area from the found shared memory area; obtain the refresh time point according to the creation time and frequency limiting cycle; if the current time point is less than or equal to the refresh time point, it is determined that a new refresh cycle has not been entered; if the current time point is greater than the refresh time point, it is determined that a new refresh cycle has been entered.

[0194] In one embodiment, the memory area creation module 810 is further configured to, if no corresponding shared memory area is found, obtain the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file; create a shared memory area corresponding to the area identifier; write the frequency limiting control information into the created shared memory area; and record the cumulative call information of the interface caller calling the target interface through the shared memory area.

[0195] In one embodiment, the memory area creation module 810 is further configured to obtain the target frequency limiting level to which the interface caller belongs from the frequency limiting configuration file; and obtain frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file.

[0196] In one embodiment, the frequency limiting configuration file includes frequency limiting control information for different frequency limiting levels configured for the target interface. In this embodiment, the memory area creation module 810 is further configured to search for frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting control information for different frequency limiting levels configured for the target interface.

[0197] In one embodiment, the memory area creation module 810 is further configured to obtain the frequency limiting period corresponding to the target interface from the frequency limiting configuration file; and write the frequency limiting period into the created shared memory area.

[0198] In one embodiment, the cumulative call information includes the cumulative number of calls. In this embodiment, the local information acquisition module 804 is further configured to increment the cumulative number of calls recorded in the local shared memory area according to the call frequency limiting query request; and acquire the incremented cumulative number of calls recorded in the shared memory area; wherein, the cumulative number of calls is the cumulative number of times the interface caller has called the target interface.

[0199] In one embodiment, the frequency limiting control information includes a call limit threshold. In this embodiment, the comparison module 806 is further configured to compare the acquired cumulative call count with the call limit threshold. In this embodiment, the result generation module 808 is further configured to generate a frequency limiting response result that does not restrict call requests if the acquired cumulative call count is less than or equal to the call limit threshold; and generate a frequency limiting response result that restricts call requests if the cumulative call count is greater than the call limit threshold.

[0200] In one embodiment, such as Figure 9 As shown, the interface call frequency limiting device 800 also includes:

[0201] The frequency limiting server determination module 814 is used to receive a call request sent by the interface caller for the target interface; in response to the call request, it performs a hash operation on the identifier of the interface caller to generate a first hash value; and determines the frequency limiting server that matches the interface caller from the candidate servers based on the first hash value and the second hash values ​​of each candidate frequency limiting server; wherein, the second hash value is obtained by performing a hash operation on the identifier of the candidate frequency limiting server.

[0202] In the aforementioned interface call frequency limiting device, after the interface caller sends a call request for the target interface, the frequency limiting priority server matched with the interface caller obtains the call frequency limiting query request corresponding to the target interface and determines the frequency limiting response result. This distributes the call frequency limiting query requests corresponding to different interface callers to various frequency limiting servers to determine the frequency limiting response result, eliminating the need to call a unified frequency limiting service. Instead, each frequency limiting server handles the processing independently, achieving decentralization and thus improving performance. Based on the call frequency limiting query request, the frequency limiting server retrieves the cumulative call information of the interface caller to the target interface from its local shared memory area and obtains the frequency limiting control information corresponding to the interface caller. It compares the cumulative call information with the frequency limiting control information and generates a frequency limiting response result based on the comparison result, indicating whether to limit the call request. This method of retrieving information from the local shared memory area and performing local calculations without external dependencies further improves performance. Furthermore, by using shared memory, security can be improved by combining it with the security mechanisms provided by the operating system. This eliminates the need for a separate security scheme and avoids the high complexity caused by the traditional unified frequency limiting service requiring authentication of the caller to improve security. It also makes it easier to ensure security.

[0203] For specific limitations regarding the interface call frequency limiting device, please refer to the limitations on the interface call frequency limiting method above, which will not be repeated here. Each module in the aforementioned interface call frequency limiting device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0204] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores frequency limiting data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements an interface call frequency limiting method.

[0205] Those skilled in the art will understand that Figure 10The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0206] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0207] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0208] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.

[0209] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0210] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0211] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for limiting the frequency of interface calls, characterized in that, The method includes: After the interface caller sends a call request for the target interface, the call frequency limiting query request corresponding to the target interface is obtained through the frequency limiting server that matches the interface caller. The frequency limiting server obtains the cumulative call information of the interface caller to the target interface from the local shared memory area according to the call frequency limiting query request; wherein, the call frequency limiting query requests corresponding to different interface callers when calling the interface are distributed to various frequency limiting servers to determine the frequency limiting response result. Obtain the frequency limiting control information corresponding to the interface caller from the shared memory area; The accumulated call information is compared with the frequency limiting control information; A frequency limiting response result is generated based on the comparison result; the frequency limiting response result is used to indicate whether the call request should be restricted.

2. The method according to claim 1, characterized in that, The frequency limiting server, based on the call frequency limiting query request, obtains the cumulative call information of the interface caller to the target interface from the local shared memory area, including: The frequency limiting server determines the identifier of the interface caller that made the call to the target interface based on the call frequency limiting query request; Based on the identifier of the interface caller and the identifier of the target interface, determine the region identifier, and search for the corresponding shared memory region locally according to the region identifier; Obtain from the shared memory area the cumulative call information of the interface caller to the target interface.

3. The method according to claim 2, characterized in that, The method further includes: Based on the found shared memory area, obtain the frequency limiting period; If a new frequency limiting cycle has not yet begun, the step of obtaining the cumulative call information of the interface caller to the target interface from the shared memory area is executed.

4. The method according to claim 3, characterized in that, The method further includes: If a new frequency limiting cycle is entered, then Based on the local preset frequency limiting configuration file, a shared memory area corresponding to the region identifier is recreated locally; The step of obtaining the cumulative call information of the interface caller to the target interface from the shared memory area includes: From the recreated shared memory area, obtain the cumulative call information of the interface caller to the target interface.

5. The method according to claim 3, characterized in that, The method further includes: From the found shared memory regions, obtain the creation time of the shared memory regions; The refresh time point is obtained based on the creation time and the frequency limiting period; If the current time point is less than or equal to the refresh time point, it is determined that a new refresh cycle has not yet begun. If the current time point is greater than the refresh time point, it is determined that a new refresh cycle has begun.

6. The method according to claim 2, characterized in that, The method further includes: If no corresponding shared memory area is found, then Obtain the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file; Create a shared memory area corresponding to the region identifier, write the frequency limiting control information into the created shared memory area, and record the cumulative call information of the interface caller calling the target interface through the shared memory area.

7. The method according to claim 6, characterized in that, The step of obtaining the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file includes: Obtain the target frequency limiting level of the interface caller from the frequency limiting configuration file; Obtain the frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file.

8. The method according to claim 7, characterized in that, The frequency limiting configuration file includes frequency limiting control information for different frequency limiting levels configured for the target interface; The step of obtaining frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file includes: From the frequency limiting control information configured for different frequency limiting levels of the target interface, find the frequency limiting control information corresponding to the target frequency limiting level.

9. The method according to claim 6, characterized in that, The method further includes: Obtain the frequency limiting period corresponding to the target interface from the frequency limiting configuration file; The frequency limiting period is written into the created shared memory area.

10. The method according to claim 1, characterized in that, The cumulative call information includes the cumulative number of calls; the frequency limiting server, based on the call frequency limiting query request, obtains the cumulative call information of the interface caller's calls to the target interface from the local shared memory area, including: The frequency limiting server increments the cumulative call count recorded in its local shared memory area according to the call frequency limiting query request; wherein, the cumulative call count is the cumulative number of times the interface caller has called the target interface; Obtain the cumulative number of calls recorded in the shared memory area after the increase.

11. The method according to claim 10, characterized in that, The frequency limiting control information includes a limit threshold for the number of calls; comparing the accumulated call information with the frequency limiting control information includes: The accumulated number of calls is compared with the number limit threshold. The step of generating a frequency-limiting response result based on the comparison results includes: If the accumulated number of calls is less than or equal to the number of calls limit threshold, a frequency-limiting response result that does not limit the call requests is generated; If the cumulative number of calls exceeds the limit threshold, a frequency-limiting response is generated to restrict the call requests.

12. The method according to any one of claims 1 to 11, characterized in that, The frequency limiting server matched with the interface caller is determined by the interface server through a frequency limiting service determination step; the frequency limiting service determination step includes: The interface server receives the call request sent by the interface caller for the target interface. In response to the call request, a hash operation is performed on the identifier of the interface caller to generate a first hash value; Based on the first hash value and the second hash value of each candidate frequency limiting server, a frequency limiting server that matches the interface caller is determined from the candidate frequency limiting servers; The second hash value is obtained by hashing the identifier of the candidate frequency-limiting server.

13. An interface call frequency limiting device, characterized in that, The device includes: The query request acquisition module is used to acquire the call frequency limiting query request corresponding to the target interface through a frequency limiting server that matches the interface caller after the interface caller sends a call request for the target interface. The local information acquisition module is used to acquire, based on the call frequency limiting query request, the cumulative call information of the interface caller calling the target interface from the local shared memory area; and to acquire the frequency limiting control information corresponding to the interface caller from the shared memory area; wherein, the call frequency limiting query requests corresponding to different interface callers when calling the interface are distributed to various frequency limiting servers to determine the frequency limiting response results. The comparison module is used to compare the accumulated call information with the frequency limiting control information; The result generation module is used to generate a frequency limiting response result based on the comparison result; the frequency limiting response result is used to indicate whether the call request should be restricted.

14. The interface call frequency limiting device according to claim 13, characterized in that, The local information acquisition module is further configured to determine the identifier of the interface caller that makes the call to the target interface based on the call frequency limiting query request; determine the region identifier based on the identifier of the interface caller and the identifier of the target interface; and search for the corresponding shared memory region locally according to the region identifier. Obtain from the shared memory area the cumulative call information of the interface caller to the target interface.

15. The interface call frequency limiting device according to claim 14, characterized in that, The local information acquisition module is also used to obtain the frequency limiting period based on the found shared memory area; if a new frequency limiting period has not yet been entered, the step of obtaining the cumulative call information of the interface caller calling the target interface from the shared memory area is executed.

16. The interface call frequency limiting device according to claim 15, characterized in that, The device further includes: a memory area creation module, used to recreate a shared memory area corresponding to the area identifier locally according to a locally preset frequency limiting configuration file if a new frequency limiting period is entered; the local information acquisition module is also used to acquire the cumulative call information of the interface caller calling the target interface from the recreated shared memory area.

17. The interface call frequency limiting device according to claim 15, characterized in that, The device further includes: a frequency limiting cycle determination module, used to obtain the creation time of the shared memory area from the found shared memory area; obtain a refresh time point based on the creation time and the frequency limiting cycle; if the current time point is less than or equal to the refresh time point, determine that a new refresh cycle has not yet been entered; if the current time point is greater than the refresh time point, determine that a new refresh cycle has been entered.

18. The interface call frequency limiting device according to claim 14, characterized in that, The device also includes a memory area creation module, which is used to obtain the frequency limiting control information corresponding to the interface caller from the local frequency limiting configuration file if no corresponding shared memory area is found. Create a shared memory area corresponding to the region identifier, write the frequency limiting control information into the created shared memory area, and record the cumulative call information of the interface caller calling the target interface through the shared memory area.

19. The interface call frequency limiting device according to claim 18, characterized in that, The memory area creation module is also used to obtain the target frequency limiting level to which the interface caller belongs from the frequency limiting configuration file; and to obtain frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting configuration file.

20. The interface call frequency limiting device according to claim 19, characterized in that, The frequency limiting configuration file includes frequency limiting control information under different frequency limiting levels configured for the target interface; the memory area creation module is also used to search for frequency limiting control information corresponding to the target frequency limiting level from the frequency limiting control information under different frequency limiting levels configured for the target interface.

21. The interface call frequency limiting device according to claim 18, characterized in that, The memory area creation module is also used to obtain the frequency limiting period corresponding to the target interface from the frequency limiting configuration file; and write the frequency limiting period into the created shared memory area.

22. The interface call frequency limiting device according to claim 13, characterized in that, The cumulative call information includes the cumulative call count; the local information acquisition module is further configured to increase the cumulative call count recorded in the local shared memory area according to the call frequency limiting query request; and acquire the increased cumulative call count recorded in the shared memory area; wherein, the cumulative call count is the cumulative number of times the interface caller calls the target interface.

23. The interface call frequency limiting device according to claim 22, characterized in that, The frequency limiting control information includes a call limit threshold; the comparison module is further configured to compare the acquired cumulative call count with the call limit threshold; the result generation module is further configured to generate a frequency limiting response result that does not limit the call request if the acquired cumulative call count is less than or equal to the call limit threshold; and generate a frequency limiting response result that limits the call request if the cumulative call count is greater than the call limit threshold.

24. The interface call frequency limiting device according to any one of claims 13 to 23, characterized in that, The apparatus further includes: a frequency limiting server determination module, configured to receive a call request sent by the interface caller for a target interface through an interface server; in response to the call request, perform a hash operation on the identifier of the interface caller to generate a first hash value; and determine a frequency limiting server matching the interface caller from the candidate frequency limiting servers based on the first hash value and the second hash values ​​of each candidate frequency limiting server; wherein the second hash value is obtained by performing a hash operation on the identifier of the candidate frequency limiting server.

25. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 12.

26. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 12.

27. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 12.