Network request anti-detection method, device and equipment, and storage medium

By storing the bit values ​​of network requests using a BitMap and combining JVM memory and Redis database for deduplication prevention, the problem of Redis resource and performance overhead under large-scale, high-frequency network requests is solved, and efficient deduplication prevention is achieved.

CN117014333BActive Publication Date: 2026-11-24HUNAN FUMI INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210458019.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-28
Publication Date
2026-11-24
Estimated Expiration
2042-04-28

AI Technical Summary

Technical Problem

Existing technologies face high overhead costs when directly querying the Redis database in the face of large-scale, high-frequency network requests, leading to database bottlenecks and performance overhead, and increasing Redis resource and management costs.

Method used

By using BitMap to store the bit values ​​corresponding to the request, and combining JVM memory and Redis database for deduplication detection, the requirements for Redis resources are reduced and the efficiency of deduplication processing is improved.

Benefits of technology

It reduces Redis resource requirements and costs, avoids database performance bottlenecks, and improves the efficiency of anti-duplicate detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117014333B_ABST
    Figure CN117014333B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for preventing duplicate network requests. The method includes: receiving a network request carrying a request identifier and the current date; obtaining a first BitMap corresponding to the previous date of the current date, the first BitMap storing the bit values ​​corresponding to all requests processed on the previous date; querying and obtaining the bit value at the position corresponding to the request identifier in the first BitMap; and determining the duplicate detection result of the network request based on the bit value at the position corresponding to the request identifier in the first BitMap according to duplicate prevention rules. This solution reduces Redis resource requirements and costs, enabling duplicate detection of network requests directly based on the first BitMap and the bit value at the position corresponding to the request identifier in the first BitMap when facing large-scale, high-frequency data requests. This improves duplicate prevention efficiency, significantly reduces database load overhead caused by duplicate prevention, and avoids database performance bottlenecks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention generally relates to the field of computer network technology, and specifically to a method, apparatus, device, and storage medium for preventing duplicate network requests. Background Technology

[0002] With the continuous development of mobile internet technology, information processing services are increasing. The internet, as a vast and comprehensive system, relies on a series of strict network protocols and request-response mechanisms to achieve interconnection between billions of users and tens of billions of devices. In the process of handling network requests, to prevent redundant data from being generated by multiple API calls, or to avoid malicious users submitting multiple requests that could slow down processing and prevent service interruptions, it is crucial to implement anti-duplicate network request detection in actual business operations.

[0003] Currently, related technologies store request identifiers as String key-value pairs in a Redis database, and perform deduplication detection by querying the Redis database when a request is encountered. However, when faced with large-scale, high-frequency network requests, the overhead of directly querying the database increases dramatically, easily causing the database to reach a bottleneck and affecting the overall system throughput and stability. Furthermore, it requires a large amount of Redis resources, resulting in high Redis performance overhead and management costs. Summary of the Invention

[0004] In view of the above-mentioned defects or deficiencies in the existing technology, it is desirable to provide a network request anti-duplicate detection method, device, equipment and storage medium that can reduce Redis resource requirements and cost, improve anti-duplicate processing efficiency, greatly reduce the database load overhead caused by anti-duplicate processing, and avoid database performance bottlenecks.

[0005] In a first aspect, the present invention provides a method for preventing duplicate network requests, the method comprising:

[0006] Receive a network request, the network request carrying a request identifier and the current date;

[0007] Get the first BitMap corresponding to the previous date of the current date. The first BitMap is used to store the bit values ​​corresponding to all requests processed in the previous date.

[0008] Query and retrieve the bit value at the position corresponding to the request identifier in the first BitMap;

[0009] Based on the bit value at the corresponding position of the request identifier in the first BitMap, the anti-duplicate detection result of the network request is determined according to the anti-duplicate rules.

[0010] In one embodiment, obtaining the first BitMap corresponding to the previous date of the current date includes:

[0011] The application is loaded to check if the first BitMap exists in the local JVM memory.

[0012] If it does not exist, retrieve the first BitMap from the Redis database.

[0013] In one embodiment, based on the bit value at the position corresponding to the request identifier in the first BitMap, the anti-duplicate detection result of the network request is determined according to the anti-duplicate rule, including:

[0014] Determine whether the bit value at the position corresponding to the request identifier in the first BitMap is one;

[0015] When the bit value at the position corresponding to the request identifier in the first BitMap is one, query the DB database to see if the network request corresponding to the request identifier is duplicated, and generate the anti-duplicate detection result of the network request;

[0016] When the bit value at the position corresponding to the request identifier in the first BitMap is not one, the second BitMap corresponding to the current date is obtained, and the anti-duplicate detection result of the network request is determined based on the second BitMap; the second BitMap is used to store the bit values ​​corresponding to all requests processed in the current date.

[0017] In one embodiment, querying the DB database to determine whether the network request corresponding to the request identifier is duplicated, and generating the anti-duplicate detection result of the network request, includes:

[0018] Obtain the database log file of the DB database and query whether a request identifier exists in the database log file;

[0019] When the request identifier exists in the database log file, the anti-duplicate detection result of the network request is determined to be a duplicate request.

[0020] If the request identifier is not present in the database log file, the anti-duplicate detection result of the network request is determined to be that the network request is not a duplicate request.

[0021] In one embodiment, after the anti-duplicate detection result of the network request is that the network request is a duplicate request, the method further includes:

[0022] Set the bit value at the position corresponding to the request identifier in the second BitMap corresponding to the current date to one.

[0023] In one embodiment, the anti-duplicate detection result of the network request is determined based on the second BitMap, including...

[0024] Query and retrieve the bit value at the position corresponding to the request identifier in the second BitMap;

[0025] Determine whether the bit value at the position corresponding to the request identifier in the second BitMap is one;

[0026] When the bit value at the corresponding position of the request identifier in the second BitMap is one, the anti-duplicate detection result of the network request is determined to be a duplicate request;

[0027] When the bit value at the position corresponding to the request identifier in the second BitMap is not one, query the DB database to see if the network request corresponding to the request identifier is duplicated, and generate the anti-duplicate detection result of the network request.

[0028] In one embodiment, the bit value at the position corresponding to the request identifier in the first BitMap is generated using a preset hash algorithm based on the previous date and the request identifier; the bit value at the position corresponding to the request identifier in the second BitMap is generated using a preset hash algorithm based on the current date and the request identifier.

[0029] Secondly, embodiments of this application provide a network request anti-duplicate detection device, which includes:

[0030] A receiving module is used to receive network requests, wherein the network requests carry a request identifier and the current date;

[0031] The acquisition module is used to acquire the first BitMap corresponding to the previous date of the current date. The first BitMap is used to store the bit values ​​corresponding to all requests processed in the previous date.

[0032] The query module is used to query and obtain the bit value at the position corresponding to the request identifier in the first BitMap;

[0033] The anti-duplicate detection module is used to determine the anti-duplicate detection result of the network request based on the bit value at the corresponding position of the request identifier in the first BitMap and in accordance with the anti-duplicate rules.

[0034] Thirdly, embodiments of this application provide an apparatus including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the network request anti-duplication detection method as described in the first aspect above.

[0035] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon for implementing the network request anti-duplicate detection method as described in the first aspect above.

[0036] The network request anti-duplicate detection method, apparatus, device, and medium provided in this application receive a network request carrying a request identifier and the current date, and obtain a first BitMap corresponding to the previous date of the current date. This first BitMap stores the bit values ​​corresponding to all requests processed on the previous date. Then, the bit value at the position corresponding to the request identifier in the first BitMap is queried and obtained. Based on the bit value at the position corresponding to the request identifier in the first BitMap, the anti-duplicate detection result of the network request is determined according to anti-duplicate rules. This technical solution reduces Redis resource requirements and cost by storing the bit values ​​corresponding to all requests in a BitMap. Therefore, when facing large-scale, high-frequency data requests, anti-duplicate detection of network requests can be performed directly based on the first BitMap and the bit value at the position corresponding to the request identifier in the first BitMap, improving anti-duplicate processing efficiency, greatly reducing the database load overhead caused by anti-duplicate processing, and avoiding database performance bottlenecks. Attached Figure Description

[0037] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0038] Figure 1 A schematic diagram of the implementation environment for the network request anti-duplicate detection method provided in this application embodiment;

[0039] Figure 2 A flowchart illustrating the network request anti-duplicate detection method provided in this application embodiment;

[0040] Figure 3 A flowchart illustrating the method for determining the anti-duplication detection result of a network request provided in an embodiment of this application;

[0041] Figure 4 A flowchart illustrating the network request anti-duplicate detection method provided in this application embodiment;

[0042] Figure 5 A schematic diagram of the system structure for preventing duplicate network requests provided in this application embodiment;

[0043] Figure 6 A flowchart illustrating the network request anti-duplicate detection method provided in this application embodiment;

[0044] Figure 7This is a schematic diagram of the network request anti-repetition detection device provided in the embodiments of this application;

[0045] Figure 8 A schematic diagram of the structure of a network request anti-repetition detection device provided in another embodiment of this application;

[0046] Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0047] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0048] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0049] Understandably, with the rise of mobile internet, web applications have become increasingly diverse. Servers process various requests and return results to the web client. However, during request processing, web clients may maliciously refresh the page, causing duplicate requests, such as duplicate payments. To ensure that multiple identical requests are executed only once, duplicate request detection is necessary.

[0050] Currently, related technologies store request identifiers as String keys in a Redis database. When a request is encountered, the Redis database is queried for deduplication detection. However, in addition to recording the actual data, the String type requires additional memory to record information such as data length and space usage. When faced with large-scale, high-frequency network requests, such as when the number of deduplication requests reaches 1 billion, the overhead of directly querying the database increases dramatically. This can easily cause the database to reach a bottleneck, affecting the throughput and stability of the entire system. Furthermore, it means that Redis needs to manage 1 billion keys, resulting in high Redis performance overhead and management costs.

[0051] To address the aforementioned shortcomings, this application provides a method for preventing duplicate network requests. Compared with existing technologies, this solution reduces Redis resource requirements and costs by storing all request-related bit values ​​in a BitMap. This allows for direct duplicate detection of network requests based on the first BitMap and the bit values ​​at the corresponding positions of the request identifiers within it when facing large-scale, high-frequency data requests. This improves the efficiency of duplicate prevention, significantly reduces database load overhead caused by duplicate prevention, and avoids database performance bottlenecks.

[0052] Figure 1 This is an implementation environment architecture diagram of a network request anti-duplicate detection method provided in an embodiment of this application. For example... Figure 1 As shown, the implementation environment architecture includes: terminal 10 and backend server 20.

[0053] Terminal 10 establishes a communication connection with the backend server 20 via a wired or wireless network.

[0054] The terminal 10 may be equipped with a client, which allows users to operate the terminal by receiving user commands, processing them, generating corresponding network requests, and sending them to the backend server 20.

[0055] The backend server 20 is used to receive network requests, which carry a request identifier. It obtains the first BitMap and the bit value at the corresponding position of the request identifier in the first BitMap, performs anti-duplicate detection on the network request based on the first BitMap and the corresponding bit value, obtains the anti-duplicate detection result of the network request, and returns it to the terminal 10.

[0056] Optionally, the type of the terminal 10 mentioned above may include, but is not limited to, smartphones, tablets, laptops, desktop computers, etc., and this application embodiment does not specifically limit this.

[0057] The backend server 20 can be configured on a separate physical server, or it can be a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides 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.

[0058] For ease of understanding and explanation, the following will use... Figures 2 to 9 This application provides a detailed description of the network request anti-duplicate detection method, apparatus, equipment, and medium provided in its embodiments.

[0059] Figure 2The diagram shown is a flowchart of a network request anti-duplicate detection method according to an embodiment of this application. This method can be executed by a network request anti-duplicate detection device. Figure 2 As shown, the method includes:

[0060] S101. Receive a network request, which includes a request identifier and the current date.

[0061] Specifically, when a user processes related business on the terminal, it triggers a corresponding operation, generating a network request and sending it to the server, which then receives the network request. Optionally, the network request may carry a request identifier and the current date, and may also include request information, such as text, images, videos, or voice messages.

[0062] It should be noted that the above request identifier is used to uniquely identify the request, such as a request ID. The current date refers to the date when the network request was received, such as xx year x month x day.

[0063] S102. Obtain the first BitMap corresponding to the previous date of the current date. The first BitMap is used to store the bit values ​​corresponding to all requests processed in the previous date.

[0064] As is understandable, in Redis, a BitMap is a continuous string of binary numbers (0 or 1). It can be viewed as an array of bits, with each bit's position representing an offset. The array index in a BitMap is called the offset. AND, OR, XOR, and other bitwise operations can be performed on a BitMap. Redis provides excellent support for storing and manipulating BitMaps.

[0065] In the space calculation process for BitMap, since the bits in BitMap are mapped to strings, and the storage of strings in the value has an upper limit, the storage space of the BitMap's value can be calculated in the same way. The maximum length of a string in Redis is 512M, so the maximum value of the BitMap's offset is: 512*1024*1024*8=2^32.

[0066] The previous date mentioned above refers to the day before today. For example, if the current date is April 3rd, then the previous date is April 2nd. The first BitMap mentioned above includes the bit values ​​corresponding to all requests processed in the previous date of the current date. The bit value at each position can be a bit value obtained by compressing the request identifier using a preset hash algorithm. This bit value is represented by a binary number and can be 1 or 0.

[0067] Specifically, the application can be loaded to check if the first BitMap exists in the local JVM memory. If the first BitMap does not exist in the local JVM memory, it can be retrieved from the Redis database and loaded into the local JVM memory, which can be achieved through a pre-defined program. If the first BitMap exists in the local JVM memory, it can be retrieved for anti-duplicate detection.

[0068] It should be noted that the first BitMap mentioned above can store the correspondence between bit values ​​and the original data, and provide the function of looking up the original data based on the bit values. JVM is an abbreviation for Java Virtual Machine. The JVM is a specification for computing devices; it is a virtual computer implemented by simulating various computer functions on a real computer. The JVM needs to use the computer's memory; the objects or algorithms processed by a Java program will use the JVM's memory space.

[0069] For example, when a network request is received each day, the target data that needs to be bit-coded in the network requests of that day can be determined, such as the request identifier. Then, a preset hash algorithm is called to map the network request and the request identifier to their corresponding positions, calculate the bit value corresponding to the target data, and store the bit value in a BitMap. For example, for a network request corresponding to the previous date of the current date, a preset hash algorithm can be used to generate the bit value at the corresponding position of the request identifier based on the request identifier, and the bit value corresponding to each request identifier can be stored in the first BitMap; similarly, for a network request corresponding to the current date, a preset hash algorithm can be used to generate the bit value at the corresponding position of the request identifier based on the request identifier, and the bit value corresponding to each request identifier can be stored in the second BitMap. The bit value at the corresponding position of the request identifier in the first BitMap and the bit value at the corresponding position of the request identifier in the second BitMap can be 1 or 0. The hash algorithm can be, for example, the murmur hash algorithm, or other hash algorithms that can be flexibly adjusted according to needs. In this step, the hash function implemented in the Guava API provided by Google can be used, which has the characteristics of high performance and low collision rate.

[0070] In this step, network requests are stored using a Bitmap, so that the request ID corresponding to each request is represented by one bit. When one hundred million request IDs are represented by a Bitmap, the memory size occupied is about 10MB. Compared with the common basic Redis String data type (request ID as key) used in the existing technology, which requires one hundred million Strings to store KEY-VALUE for deduplication, this can significantly reduce the performance overhead on Redis.

[0071] S103. Query and obtain the bit value at the corresponding position of the requested identifier in the first BitMap.

[0072] Specifically, after obtaining the first BitMap corresponding to the previous date of the current date, you can query and retrieve the bit value at the corresponding position of the request identifier in the first BitMap. For example, you can check whether the bit value at the corresponding position of the request identifier in the first BitMap is 1.

[0073] For example, to track unique users, such as how many unique users used a particular application each day, a Bitmap can be generated daily based on the application's user access logs. Each user corresponds to a position in the Bitmap; if a user accessed the application that day, the corresponding position is marked as 1; if the user did not access the application that day, the corresponding position is marked as 0. This way, the total number of unique users for the application that day can be determined by checking how many 1s are in the Bitmap for that day.

[0074] S104. Based on the bit value at the corresponding position of the request identifier in the first BitMap, determine the anti-duplicate detection result of the network request according to the anti-duplicate rules.

[0075] It should be noted that the above anti-duplicate rules can be customized by the user in advance according to their anti-duplicate requirements. These rules can include checking the bit values ​​in the Bitmap corresponding to the previous date of the current date, and can also include checking the bit values ​​in the Bitmap corresponding to the current date.

[0076] In this embodiment, based on JVM memory and a Redis database, each request is pre-queried in the database to check if it already exists or has been processed before processing. Specifically, memory processing, by accessing JVM memory to perform duplicate detection on network requests, significantly improves performance compared to the network I / O and disk I / O required for high-frequency database access. Furthermore, in handling large-scale, high-frequency requests, memory processing technology reduces database load, thereby lowering database costs.

[0077] Optionally, as one possible implementation, based on the above embodiments, such as... Figure 3 As shown, Figure 3 This is a flowchart illustrating a method for determining the anti-duplicate detection result of a network request according to anti-duplicate rules, as provided in an embodiment of this application. The method includes:

[0078] S201. Determine whether the bit value at the corresponding position of the request identifier in the first BitMap is one.

[0079] S202. When the bit value at the corresponding position of the request identifier in the first BitMap is one, query the DB database to see if the network request corresponding to the request identifier is duplicated, and generate the anti-duplicate detection result of the network request.

[0080] For details, please see Figure 4 As shown, after obtaining the bit value at the corresponding position of the request identifier in the first BitMap, it can be determined whether the bit value is one. When it is one, there may be a hash collision, and the network request may be duplicated. In order to further determine the anti-duplicate detection result of the network request, it can be achieved by querying the DB database.

[0081] One example of a hash collision is when the hash results obtained by two request identifiers using a hash algorithm conflict. For instance, if the first hash result is obtained by hashing string 1 corresponding to request identifier 1 and the second hash result is obtained by hashing string 2 corresponding to request identifier 2, and both the first and second hash results are located at the ninth position in the BitMap, then it indicates that request identifier 1 and request identifier 2 have a hash collision.

[0082] In this step, the database log file of the DB database can be retrieved, and the existence of a request identifier in the database log file can be checked. If the request identifier exists in the database log file, the anti-duplicate detection result of the network request is determined to be a duplicate request; if the request identifier does not exist in the database log file, the anti-duplicate detection result of the network request is determined to be a non-duplicate request.

[0083] Furthermore, since a single BitMap corresponds to each day, and Redis manages the expiration of these BitMaps, the data in the BitMaps can be automatically cleaned up within a preset time period, such as the previous 24 hours. The BitMap for the current day is updated in real time in Redis, while past BitMaps, which are no longer updated, are loaded into local memory by the JVM program. Approximately 12MB of memory is used for 100 million request IDs.

[0084] Once the database query confirms that the network request is a duplicate request, the bit value at the corresponding position of the request identifier in the second BitMap for the current date is set to one. This is because the BitMap changes daily, requiring the ability to detect requests from the previous date even on the next date. For example, if the current date is T, it is necessary to detect requests from T-1 that already exist on T+1.

[0085] It's important to note that the "DB" database mentioned above refers to MongoDB, a database based on distributed file storage. Written in C++, it's a product that falls between relational and non-relational databases, boasting the richest functionality and most relational-like characteristics among non-relational databases. MongoDB's greatest strength lies in its powerful query language, with syntax similar to object-oriented query languages. It supports field indexes, cursor operations, excels at querying JSON data, and can store massive amounts of data.

[0086] S203. When the bit value at the corresponding position of the request identifier in the first BitMap is not one, obtain the second BitMap corresponding to the current date, and determine the anti-duplicate detection result of the network request based on the second BitMap; the second BitMap is used to store the bit values ​​corresponding to all requests processed in the current date.

[0087] Specifically, when the bit value at the corresponding position of the request identifier in the first BitMap is not one, it means that the previous date of the current date was not found to be duplicated based on memory checks, and further checks are needed on the second BitMap corresponding to the current date. Since the second BitMap corresponding to the current date is constantly changing, it cannot be loaded into local memory by the application; instead, it must be read and written in a centralized, concurrently safe manner. Therefore, the second BitMap corresponding to the current date is maintained through Redis operations, involving one read (first) and one write (later) operations implemented with "atomicity" through Lua scripts.

[0088] As one possible approach, in determining the anti-duplicate detection result of a network request based on the second BitMap, the bit value at the corresponding position of the request identifier in the second BitMap is retrieved by querying and obtaining the bit value at the corresponding position of the request identifier in the second BitMap. This bit value is generated using a preset hash algorithm based on the current date and the request identifier. Then, it is determined whether the bit value at the corresponding position of the request identifier in the second BitMap is one. If the bit value is one, the anti-duplicate detection result of the network request is determined to be a duplicate request; if the bit value is not one, the database is queried to determine whether the network request corresponding to the request identifier is duplicated, thus obtaining the anti-duplicate detection result of the network request.

[0089] Specifically, the database log file of the DB database can be retrieved, and the existence of a request identifier in the database log file can be checked. If the request identifier exists in the database log file, the anti-duplicate detection result of the network request is determined to be a duplicate request. If the request identifier does not exist in the database log file, the anti-duplicate detection result of the network request is determined to be a non-duplicate request.

[0090] In this embodiment, network requests are deduplication-prevented by using a first BitMap corresponding to the previous date and a second BitMap corresponding to the current date. This allows for deduplication prevention primarily to be handled by local memory and a Redis database, with only a very small number of hash collisions requiring a database query for the result. Furthermore, for these rare deduplication queries, the performance overhead is minimal when using the snowflake algorithm to generate the ID as the primary key, thus reducing overall performance costs.

[0091] For example, please see Figure 5 As shown, Figure 5 This is a schematic diagram of the system architecture for preventing duplicate network requests provided in an embodiment of this application. The system may include JVM memory, a Redis database, and a DB database. The JVM memory is the memory space corresponding to the application layer service; the Redis database is the memory space for the reliable caching service corresponding to the middleware; and the DB database is a non-relational database based on distributed file storage.

[0092] Please see Figure 6As shown, when a network request is received, a duplicate check is required. This can be done by obtaining the request ID from day T and then checking if the request from day T-1 is a duplicate. First, the JVM program is loaded to query whether a BitMap (T-1) from day T-1 exists in the local memory. If the BitMap (T-1) from day T-1 does not exist in the local memory, it is loaded from the Redis database; otherwise, it is retrieved from the Redis database. If the BitMap (T-1) from day T-1 exists in the local memory, the bit value at the corresponding position of the request identifier in the BitMap (T-1) from day T-1 is checked to see if it is 1. If it is 1, the database (DB) database is checked to see if the request from day T-1 is a duplicate. This can be done by retrieving the database log file of the DB database and querying the ID database log file to see if the request identifier exists. If the ID request identifier exists in the database log file, the duplicate detection result for the ID network request is determined to be a duplicate request, and the bit position corresponding to the request identifier in the BitMap (T) from day T is set to 1. When the ID request identifier is not present in the database log file, the result of the anti-duplicate detection of the ID network request is that the ID network request is not a duplicate request.

[0093] If the bit value at the corresponding position of the request identifier in BitMap(T-1) is not 1, then check whether the request in BitMap(T) on day T is duplicated; retrieve the bit value at the corresponding position of the request identifier in BitMap(T), and query whether the bit value at the corresponding position of the request identifier in BitMap(T) on day T is 1; if it is not 1, access the database to check, and generate the anti-duplicate detection result of the network request by querying the DB database to see if the network request corresponding to the request identifier is duplicated. If it is 1, then the anti-duplicate detection result of the network request is determined to be a duplicate request.

[0094] The network request deduplication detection method provided in this application receives a network request carrying a request identifier and the current date, and obtains a first BitMap corresponding to the previous date. This first BitMap stores the bit values ​​corresponding to all requests processed on the previous date. Then, it queries and retrieves the bit value at the position corresponding to the request identifier in the first BitMap. Based on the bit value at the position corresponding to the request identifier in the first BitMap, the deduplication detection result of the network request is determined according to deduplication rules. This technical solution reduces Redis resource requirements and costs by storing the bit values ​​corresponding to all requests in a BitMap. Therefore, when facing large-scale, high-frequency data requests, it can directly perform deduplication detection on network requests based on the first BitMap and the bit value at the position corresponding to the request identifier in the first BitMap, improving deduplication processing efficiency, greatly reducing the database load overhead caused by deduplication processing, and avoiding database performance bottlenecks.

[0095] It should be noted that although the operations of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0096] on the other hand, Figure 7 This is a schematic diagram of a network request anti-duplicate detection device provided in an embodiment of this application. This device can be a component within a computer device, such as… Figure 7 As shown, the device includes:

[0097] The receiving module 410 is used to receive network requests, which carry a request identifier and the current date.

[0098] The acquisition module 420 is used to acquire the first BitMap corresponding to the previous date of the current date. The first BitMap is used to store the bit values ​​corresponding to all requests processed in the previous date.

[0099] Query module 430 is used to query and obtain the bit value at the corresponding position of the request identifier in the first BitMap;

[0100] The anti-duplicate detection module 440 is used to determine the anti-duplicate detection result of the network request based on the bit value at the corresponding position of the request identifier in the first BitMap and in accordance with the anti-duplicate rules.

[0101] Optional, please see Figure 8 As shown, the acquisition module 420 includes:

[0102] Query unit 421 is used to query whether the ID First BitMap exists in the local JVM memory by loading the application;

[0103] Unit 422 is used to retrieve the first BitMap from the Redis database if the first BitMap does not exist in the local JVM memory.

[0104] Optional, the anti-rebound detection module 440 includes:

[0105] Judgment unit 441 is used to determine whether the bit value at the corresponding position of the request identifier in the first BitMap is one;

[0106] The first determining unit 442 is used to query the DB database to see if the network request corresponding to the request identifier is repeated when the bit value at the corresponding position of the request identifier in the first BitMap is one, and generate the anti-duplicate detection result of the network request.

[0107] The second determining unit 443 is used to obtain the second BitMap corresponding to the current date when the bit value at the corresponding position of the request identifier in the first BitMap is not one, and to determine the anti-duplicate detection result of the network request based on the second BitMap; the second BitMap is used to store the bit values ​​corresponding to all requests processed in the current date.

[0108] Optionally, the first determining unit 442 described above is specifically used for:

[0109] Retrieve the database log file of the DB database and check if the request identifier exists in the database log file;

[0110] When a request identifier exists in the database log file, the anti-duplicate detection result of the network request is determined to be a duplicate request.

[0111] If the request identifier is not present in the database log file, the result of the anti-duplicate network request detection is determined to be that the network request is not a duplicate request.

[0112] Optionally, the above-mentioned device is also used for:

[0113] Set the bit value at the corresponding position of the request identifier in the second BitMap corresponding to the current date to one.

[0114] Optionally, the first determining unit 443 described above is specifically used for:

[0115] Query and retrieve the bit value at the corresponding position of the requested identifier in the second BitMap;

[0116] Determine whether the bit value at the corresponding position of the requested identifier in the second BitMap is one;

[0117] When the bit value at the corresponding position of the request identifier in the second BitMap is one, the anti-duplicate detection result of the network request is determined to be a duplicate request;

[0118] When the bit value at the corresponding position of the request identifier in the second BitMap is not one, query the DB database to see if the network request corresponding to the request identifier is duplicated, and generate the anti-duplicate detection result of the network request.

[0119] Optionally, the bit value at the position corresponding to the request identifier in the first BitMap is generated using a preset hash algorithm based on the previous date and the request identifier; the bit value at the position corresponding to the request identifier in the second BitMap is generated using a preset hash algorithm based on the current date and the request identifier.

[0120] The network request anti-duplicate detection device provided in this application reduces Redis resource requirements and costs by storing the bit values ​​corresponding to all requests in a BitMap. This enables the device to directly perform anti-duplicate detection on network requests based on the bit values ​​at the corresponding positions of the request identifiers in the first BitMap when faced with large-scale, high-frequency data requests. This improves the efficiency of anti-duplicate processing, greatly reduces the database load overhead caused by anti-duplicate processing, and avoids database performance bottlenecks.

[0121] On the other hand, the terminal device provided in this application embodiment includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the network request anti-duplicate detection method as described above.

[0122] The following is for reference. Figure 9 , Figure 9 This is a schematic diagram of the computer system structure of the terminal device according to an embodiment of this application.

[0123] like Figure 9 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage portion 603 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0124] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0125] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a machine-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 603, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this application.

[0126] It should be noted that the computer-readable medium shown in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0127] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0128] The units or modules described in the embodiments of this application can be implemented in software or hardware. The described units or modules can also be housed in a processor; for example, it can be described as: a processor including: a receiving module, an acquiring module, a querying module, and an anti-duplicate detection module. The names of these units or modules do not necessarily limit the unit or module itself; for example, a receiving module can also be described as "for receiving network requests, the network requests carrying a request identifier and the current date."

[0129] In another aspect, this application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable storage medium stores one or more programs, which, when used by one or more processors, execute the network request anti-duplicate detection method described in this application:

[0130] Receive a network request, the network request carrying a request identifier and the current date;

[0131] Get the first BitMap corresponding to the previous date of the current date. The first BitMap is used to store the bit values ​​corresponding to all requests processed in the previous date.

[0132] Query and retrieve the bit value at the position corresponding to the request identifier in the first BitMap;

[0133] Based on the bit value at the corresponding position of the request identifier in the first BitMap, the anti-duplicate detection result of the network request is determined according to the anti-duplicate rules.

[0134] In summary, the network request anti-duplicate detection method, apparatus, device, and medium provided in this application receive a network request carrying a request identifier and the current date, and obtain a first BitMap corresponding to the previous date of the current date. This first BitMap stores the bit values ​​corresponding to all requests processed on the previous date. Then, the bit value at the position corresponding to the request identifier in the first BitMap is queried and obtained. Based on the bit value at the position corresponding to the request identifier in the first BitMap, the anti-duplicate detection result of the network request is determined according to anti-duplicate rules. This technical solution reduces Redis resource requirements and cost by storing the bit values ​​corresponding to all requests in a BitMap. Therefore, when facing large-scale, high-frequency data requests, it can directly perform anti-duplicate detection on network requests based on the first BitMap and the bit value at the position corresponding to the request identifier in the first BitMap, improving anti-duplicate processing efficiency, greatly reducing the database load overhead caused by anti-duplicate processing, and avoiding database performance bottlenecks.

[0135] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.

Claims

1. A method for preventing duplicate network requests, characterized in that, The method includes: Receive a network request, the network request carrying a request identifier and the current date; Get the first BitMap corresponding to the previous date of the current date. The first BitMap is used to store the bit values ​​corresponding to all requests processed in the previous date. Query and retrieve the bit value at the position corresponding to the request identifier in the first BitMap; Determine whether the bit value at the position corresponding to the request identifier in the first BitMap is one; when the bit value at the position corresponding to the request identifier in the first BitMap is one, query the DB database to see if the network request corresponding to the request identifier is duplicated, and generate the anti-duplicate detection result of the network request; when the bit value at the position corresponding to the request identifier in the first BitMap is not one, obtain the second BitMap corresponding to the current date, and determine the anti-duplicate detection result of the network request based on the second BitMap; the second BitMap is used to store the bit values ​​corresponding to all requests processed in the current date.

2. The method according to claim 1, characterized in that, Retrieve the first BitMap corresponding to the previous date of the current date, including: The application is loaded to check if the first BitMap exists in the local JVM memory. If it does not exist, retrieve the first BitMap from the Redis database.

3. The method according to claim 1, characterized in that, The database is queried to determine whether the network request corresponding to the request identifier is duplicated, and the anti-duplicate detection result of the network request is generated, including: Obtain the database log file of the DB database and query whether a request identifier exists in the database log file; When the request identifier exists in the database log file, the anti-duplicate detection result of the network request is determined to be a duplicate request. If the request identifier is not present in the database log file, the anti-duplicate detection result of the network request is determined to be that the network request is not a duplicate request.

4. The method according to claim 3, characterized in that, After the anti-duplicate detection result of the network request is determined to be a duplicate request, the method further includes: Set the bit value at the position corresponding to the request identifier in the second BitMap corresponding to the current date to one.

5. The method according to claim 1, characterized in that, Based on the second BitMap, the anti-duplicate detection result of the network request is determined, including... Query and retrieve the bit value at the position corresponding to the request identifier in the second BitMap; Determine whether the bit value at the position corresponding to the request identifier in the second BitMap is one; When the bit value at the corresponding position of the request identifier in the second BitMap is one, the anti-duplicate detection result of the network request is determined to be a duplicate request; When the bit value at the position corresponding to the request identifier in the second BitMap is not one, query the DB database to see if the network request corresponding to the request identifier is duplicated, and generate the anti-duplicate detection result of the network request.

6. The method according to claim 5, characterized in that, The bit value at the position corresponding to the request identifier in the first BitMap is generated using a preset hash algorithm based on the previous date and the request identifier; the bit value at the position corresponding to the request identifier in the second BitMap is generated using a preset hash algorithm based on the current date and the request identifier.

7. A network request anti-duplicate detection device, characterized in that, The device includes: A receiving module is used to receive network requests, wherein the network requests carry a request identifier and the current date; The acquisition module is used to acquire the first BitMap corresponding to the previous date of the current date. The first BitMap is used to store the bit values ​​corresponding to all requests processed in the previous date. The query module is used to query and obtain the bit value at the position corresponding to the request identifier in the first BitMap; Anti-repetition detection module, used for Determine whether the bit value at the position corresponding to the request identifier in the first BitMap is one; when the bit value at the position corresponding to the request identifier in the first BitMap is one, query the DB database to see if the network request corresponding to the request identifier is duplicated, and generate the anti-duplicate detection result of the network request; when the bit value at the position corresponding to the request identifier in the first BitMap is not one, obtain the second BitMap corresponding to the current date, and determine the anti-duplicate detection result of the network request based on the second BitMap; the second BitMap is used to store the bit values ​​corresponding to all requests processed in the current date.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the request anti-duplicate detection method as described in any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, the computer program being used to implement the request anti-duplicate detection method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Uniqueness verification method, device and apparatus and readable storage medium

    CN110781464A