Data feedback method and device, storage medium and electronic device

By receiving service requests in the application system and managing the counter of hot keys, the problem of crashing the redis cluster when the number of visits surges is solved. By dispersing request processing, the number of direct calls to the redis cluster is reduced and the stability of the system is improved.

CN114610460BActive Publication Date: 2025-01-10AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210258560.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-16
Publication Date
2025-01-10
Estimated Expiration
2042-03-16

AI Technical Summary

Technical Problem

When the number of accesses to the application system surges, the hot keys in the redis cluster are frequently accessed, causing the system to crash and unable to handle a large number of access requests, causing the system to crash.

Method used

By receiving service requests, determine the hot key corresponding to the request, and update the value of its counter. When the counter reaches the threshold, the redis cluster feedback response data is called and the request is allocated to multiple service nodes for processing, reducing direct calls to the redis cluster frequency.

Benefits of technology

It effectively reduces the access pressure of the redis cluster, avoids system crashes, and improves the reliability and processing capabilities of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114610460B_ABST
    Figure CN114610460B_ABST
Patent Text Reader

Abstract

The present invention provides a data feedback method and device, a storage medium and an electronic device, the method comprising: receiving a service request; determining a hot key corresponding to the service request, and determining the hot key as a target hot key; determining a counter belonging to the target hot key in each counter as a target counter; updating the count value in the target counter, and judging whether the updated count value is equal to a count threshold; if it is equal, calling a redis cluster to feed back response data to the requester of the service request, and updating the request statistics of the target hot key in the redis cluster. After receiving the service request, first determine the target hot key corresponding to the service request, then update the count value of the counter corresponding to the target hot key, and when the updated count value is equal to the calculation threshold, call the redis cluster to feed back response data to the requester corresponding to the service request, thereby compressing the number of calls to the redis cluster and reducing the connection with the redis cluster, avoiding a large number of accesses in a short time that cause the system to crash.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a data feedback method and device, a storage medium and an electronic device. Background Art

[0002] With the rapid development of the Internet industry, people can access various application systems through the network to obtain corresponding data or services. At present, the data of application systems are usually stored in redis clusters, which usually store the data of various hot keys of the application. Users can obtain data in the redis cluster by accessing the hot keys.

[0003] As the number of people using the application system increases, the number of visits to the application system is constantly increasing. There is often a sudden surge in the number of visits at a certain point in time, which causes a hot key in the redis cluster to be frequently accessed. As a result, the number of visits to the redis cluster in a short period of time exceeds the system's processing capacity, causing the application system to crash. Summary of the invention

[0004] In view of this, the present invention provides a data feedback method and device, a storage medium and an electronic device, which can effectively reduce the number of visits to the redis cluster of the application system and avoid the system crash caused by excessive visits in a short period of time.

[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0006] A first aspect of the present invention discloses a data feedback method, comprising:

[0007] Receive service requests;

[0008] Determine a hot key corresponding to the service request from among various preset hot keys, and determine the hot key as a target hot key;

[0009] Determine the counter belonging to the target hot key among the preset counters as the target counter;

[0010] Updating the count value in the target counter, and determining whether the updated count value in the target counter is equal to a preset count threshold;

[0011] If it is determined that the updated count value in the target counter is equal to the count threshold, a preset redis cluster is called to feed back response data to the requester of the service request, and the request statistics of the target hot key in the redis cluster are updated.

[0012] In the above method, optionally, determining the hot key corresponding to the service request from each preset hot key includes:

[0013] Obtain key information in the service request;

[0014] Match the key information with each preset hot key one by one;

[0015] A hot key matching the key information is determined as a hot key corresponding to the service request.

[0016] In the above method, optionally, calling a preset redis cluster to feed back response data to the requester of the service request includes:

[0017] Adding the service request to the request queue corresponding to the target hot key;

[0018] Determine in the redis cluster the node cluster to which the target hot key belongs, wherein the node cluster includes multiple service nodes;

[0019] Allocating each service request in the request queue to a corresponding service node;

[0020] For each service request in the request queue, the service node corresponding to the service request is called to feed back response data corresponding to the target hot key to the requester of the service request.

[0021] The above method may optionally further include:

[0022] If it is determined that the updated count value in the target counter is not equal to the count threshold, the service request is added to the request queue corresponding to the target hot key.

[0023] The above method may optionally further include:

[0024] The target counter is initialized.

[0025] A second aspect of the present invention discloses a data feedback device, comprising:

[0026] A receiving unit, configured to receive a service request;

[0027] A first determining unit, configured to determine a hot key corresponding to the service request from among various preset hot keys, and determine the hot key as a target hot key;

[0028] A second determining unit, configured to determine a counter belonging to the target hot key among the preset counters as a target counter;

[0029] an updating unit, configured to update the count value in the target counter and determine whether the updated count value in the target counter is equal to a preset count threshold;

[0030] The calling unit is used to call a preset redis cluster to feed back response data to the requester of the service request if it is determined that the updated count value in the target counter is equal to the count threshold, and to update the request statistics of the target hot key in the redis cluster.

[0031] In the above device, optionally, the first determining unit includes:

[0032] An acquisition module, used to obtain key information in the service request;

[0033] A matching module, used to match the key information with each preset hot key one by one;

[0034] The first determining module is used to determine a hot key matching the key information as a hot key corresponding to the service request.

[0035] In the above device, optionally, the calling unit includes:

[0036] An adding module, used for adding the service request to the request queue corresponding to the target hot key;

[0037] A second determination module is used to determine the node cluster to which the target hot key belongs in the redis cluster, wherein the node cluster includes multiple service nodes;

[0038] An allocation module, used to allocate each service request in the request queue to a corresponding service node;

[0039] The calling module is used to call the service node corresponding to each service request in the request queue to feed back response data corresponding to the target hot key to the requester of the service request.

[0040] The above device may optionally further include:

[0041] An adding unit is used to add the service request to a request queue corresponding to the target hot key if it is determined that the updated count value in the target counter is not equal to the count threshold.

[0042] The above device may optionally further include:

[0043] An initialization unit is used to initialize the target counter.

[0044] A third aspect of the present invention discloses a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the data feedback method as described above.

[0045] A fourth aspect of the present invention discloses an electronic device, comprising a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the data feedback method as described above.

[0046] The present invention provides a data feedback method and device, a storage medium and an electronic device, the method comprising: receiving a service request; determining a hot key corresponding to the service request in each preset hot key, and determining the hot key as a target hot key; determining a counter belonging to the target hot key in each preset counter as a target counter; updating the count value in the target counter, and judging whether the updated count value in the target counter is equal to a preset count threshold; if equal, calling a preset redis cluster to feed back response data to the requester of the service request, and updating the request statistics of the target hot key in the redis cluster. After receiving the service request, first determine the target hot key corresponding to the service request, then update the count value of the counter corresponding to the target hot key, and when the updated count value is equal to the preset calculation threshold, call the redis cluster to feed back response data to the requester corresponding to the service request, thereby compressing the number of calls to the redis cluster and reducing the connection with the redis cluster, avoiding a large number of accesses in a short time that cause the system to crash. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0048] Figure 1 A method flow chart of a data feedback method provided by an embodiment of the present invention;

[0049] Figure 2 A flow chart of a method for determining a hot key corresponding to a service request provided by an embodiment of the present invention;

[0050] Figure 3 A flow chart of a method for feeding back response data to a requester of a service request provided by an embodiment of the present invention;

[0051] Figure 4A schematic diagram of the structure of a data feedback device provided by an embodiment of the present invention;

[0052] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0054] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0055] Explanation of the terms used in this invention:

[0056] Redis hot key: A sudden large number of requests access a specific key in Redis.

[0057] Incr: A redis command that increases the numeric value stored in the key by one.

[0058] incrBy: A redis command that adds the specified increment value N to the number stored in the key.

[0059] HashMap: An implementation of the Map interface based on a hash table, which is not thread-safe.

[0060] ConcurrentHashMap: A thread-safe and efficient container.

[0061] As can be seen from the background technology, a surge in the number of visits to the application system at a certain point in time is a common situation in application systems with hundreds of millions of visits. For example, the Double Eleven e-commerce system product flash sales, the appearance of some hot news on Weibo, the 12306 train ticket rush, etc. will all cause a surge in the number of visits to the system at a certain point in time, which will cause the system to have a redis hot key problem, which will cause a key in redis to be frequently accessed. When the number of visits exceeds the number of connections in the redis cluster, the redis cluster will not be able to support it, resulting in slow response or even system service crashes.

[0062] The present invention provides a data feedback method and device, which can compress the number of times a redis cluster is accessed when a large number of access requests occur, thereby reducing the number of times the redis cluster is accessed and avoiding the system crash caused by the number of accesses to the application system in a short period of time.

[0063] The execution subject of the present invention can be a server or a processor in an application system, and the present invention can be used in an application system, a variety of general or special computing device environments or configurations, such as personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor devices, and distributed computing environments including any of the above devices or equipment.

[0064] Reference Figure 1 , is a method flow chart of a data feedback method provided by an embodiment of the present invention, and is specifically described as follows:

[0065] S101: receiving a service request.

[0066] A service request is a request sent by a requester who needs to obtain data from an application system or use services of an application system. Specifically, a service request includes but is not limited to requester information and demand information. For example, requester information includes but is not limited to IP address information, user information, terminal information, etc., and demand information includes but is not limited to key information, request time, etc.

[0067] Preferably, when multiple service requests are received, the method provided by the present invention can also be applied to process each service request simultaneously.

[0068] S102: Determine a hot key corresponding to the service request from among various preset hot keys, and determine the hot key as a target hot key.

[0069] Reference Figure 2 , which is a flow chart of a method for determining a hot key corresponding to a service request provided by an embodiment of the present invention, and is specifically described as follows:

[0070] S201: Obtain key information in the service request.

[0071] The service request is parsed to obtain key information in the service request. Preferably, the key information may include the identifier of the hot key of the service that the requester needs to access, the name of the hot key, and the creation time of the hot key.

[0072] S202: Match the key information with each preset hot key one by one.

[0073] The preset hot key also has corresponding information. The obtained key information is compared with the information of each preset hot key, so that the hot key matching the key information can be found. The information of the hot key is the same as the key information.

[0074] S203: Determine the hot key that matches the key information as the hot key corresponding to the service request.

[0075] Based on the key information obtained from the service request, the hot key corresponding to the service request can be determined, and then the target hot key can be determined from multiple hot keys. Preferably, there is only one corresponding hot key for a service request. Based on the key information in the service request, the target hot key can be accurately determined from each preset hot key to ensure the accuracy of subsequent feedback data.

[0076] S103: Determine the counter belonging to the target hot key among the preset counters as the target counter.

[0077] In the method provided in the embodiment of the present invention, multiple counters are set in the redis cluster, and each counter has a corresponding hot key. Preferably, the counter can be implemented using ConcurrentHashMap, thereby ensuring thread safety in the redis cluster.

[0078] S104: Update the count value in the target counter and determine whether the updated count value in the target counter is equal to the preset count threshold; if it is determined that the updated count value in the target counter is equal to the count threshold, execute S105; if it is determined that the updated count value in the target counter is not equal to the count value, execute S106.

[0079] Preferably, each time the count value in the target counter is updated, the current count value in the target counter may be increased by one, thereby completing the update of the count value in the target counter; exemplarily, the current count value in the target counter is 98, and after the count value in the target counter is increased by one, the count value in the target counter is 99.

[0080] Furthermore, after the count value in the target counter is updated, it is necessary to determine whether the updated count value in the target counter is equal to a preset count threshold. The count threshold can be set according to actual needs, such as the count threshold is 100.

[0081] S105: calling a preset redis cluster to feed back response data to the requester of the service request, and updating the request statistics of the target hot key in the redis cluster.

[0082] It should be noted that calling the redis cluster means accessing the redis cluster.

[0083] Reference Figure 3 , is a flow chart of a method for feeding back response data to a requester of a service request provided by an embodiment of the present invention, and is specifically described as follows:

[0084] S301: Add the service request to the request queue corresponding to the target hot key.

[0085] Preferably, a request queue is set for each hot key, and the request queue is used to store service requests for the hot key.

[0086] After determining that the updated count value of the target counter is equal to the count threshold, the service request needs to be saved in the request queue.

[0087] S302: Determine the node cluster to which the target hot key belongs in the redis cluster, where the node cluster includes multiple service nodes.

[0088] The redis cluster contains multiple node clusters, each node cluster has a corresponding hot key, and each node cluster contains multiple service nodes.

[0089] Preferably, the node cluster to which the target hot key belongs can be determined in each node cluster according to the node cluster identifier of the target hot key.

[0090] S303: Allocate each service request in the request queue to a corresponding service node.

[0091] When allocating each service request in the request queue to the corresponding service node, the allocation can be performed according to the operating information of each service node, and the operating information includes but is not limited to idle computing resources, CPU operating information, etc. The number of allocatable requests of each service node can be determined according to the operating information of each service node, and service requests are allocated to each service node based on the number of allocatable requests of each service node. Preferably, for each service node, each service request allocated to the service node is randomly extracted from the request queue, and the number of each extracted service request is equal to the number of allocatable requests of the service node. Furthermore, the service node is the service node corresponding to each extracted service request.

[0092] S304: For each service request in the request queue, the service node corresponding to the service request is called to feed back response data corresponding to the target hot key to the requester of the service request.

[0093] After assigning a service request to each service node, for each service node, the service node needs to feed back the response data corresponding to the target hot key to the requester of each service request assigned to it.

[0094] Preferably, after the response data is fed back to the requester of the service request, the request statistics of the target hot key in the redis cluster need to be updated. Specifically, the current request statistics of the target hot key in the redis cluster can be added to the value of the counting threshold. For example, the counting threshold is 100, the current request statistics of the target hot key in the redis cluster is 1000, and the request statistics of the target hot key after the update are 1100.

[0095] Preferably, after updating the request statistics of the target hot key in the redis cluster, the target counter needs to be initialized, specifically, the count value in the target counter may be cleared or reset to an initial value, specifically, the initial value is 0.

[0096] In the method provided by the embodiment of the present invention, when the count value after the hot key is updated is equal to the preset count threshold, the redis cluster can be called to feedback response data to the requester of the service request, thereby effectively compressing the number of accesses to the redis cluster and reducing the processing volume of the redis cluster. In addition, each hot key has multiple corresponding service nodes, thereby dispersing the processing of each service request and dispersing the processing pressure, thereby avoiding the crash of the application system.

[0097] S106: Add the service request to the request queue corresponding to the target hot key.

[0098] In the method provided by an embodiment of the present invention, when the updated count value in the target counter is not equal to the count threshold, it is necessary to add the service request to the request queue corresponding to the target hot key until the updated count value in the target counter is equal to the count threshold, and step S105 can be executed.

[0099] In the method provided by the embodiment of the present invention, a service request is received; a hot key corresponding to the service request is determined in each preset hot key, and the hot key is determined as a target hot key; a counter belonging to the target hot key in each preset counter is determined as a target counter; the count value in the target counter is updated, and it is determined whether the updated count value in the target counter is equal to the preset count threshold; if it is equal, the preset redis cluster is called to feedback response data to the requester of the service request, and the request statistics of the target hot key in the redis cluster are updated. After receiving the service request, the target hot key corresponding to the service request is first determined, and then the count value of the counter corresponding to the target hot key is updated. When the updated count value is equal to the preset calculation threshold, the redis cluster is called to feedback response data to the requester corresponding to the service request, thereby compressing the number of calls to the redis cluster and reducing the connection with the redis cluster, avoiding a large number of accesses in a short period of time that cause the system to crash.

[0100] Exemplarily, the present invention can solve the redis hot key problem of an application system with billions of visits. The present invention can reduce the access in the application system by combining hot key splitting and cache counting. The present invention takes the visit statistics function of an advertisement in an advertising page of an application with billions of visits as an example, improves the redis hot key problem that occurs in the process of collecting visits, and implements a redis hot key processor for an application system with billions of visits. On the basis of dispersed access requests, a metering number of 0 is defined for the hot key. Each access first updates the metering number by 1. When the metering number reaches a custom upper limit N, N is a preset value, specifically a positive integer, and then redis is accessed to update the total visit volume plus N, thereby reducing the number of key accesses in redis to 1 / N, thereby solving the redis hot key problem. Furthermore, when there are multiple keys, the present invention adopts a method of processing by encapsulating the measurement number of multiple keys through Map, wherein Map adopts ConcurrentHashMap instead of HashMap to ensure thread safety, thereby solving the problem of circular linked list caused by the expansion of HashMap under multi-threading, resulting in thread dead loop and 100% CPU occupancy, and further solving the problems of multi-key management, connection number control, CPU occupancy rate and other problems caused by concurrent access.

[0101] It should be noted that when there is a single key, the counter can be implemented using Integer. By defining an Integer to count the number, the initial value is 0, and the count is increased by 1 each time it is accessed. When the count reaches 100, the redis incrBy command is executed to update the key value plus 100, and then restore the count value to 0. In this way, the original 100 incr calls can be reduced to 1 incrBy call.

[0102] When there are multiple keys, refer to the solution of a single key and count in the Java code. When it reaches 100, execute the incrBy command again. However, the difference from a single key is that this time there are multiple keys, and an Integer cannot be used to count them. Therefore, a Map is used to count multiple keys.

[0103] During the function optimization process, HashMap was initially used to count keys, but server CPU abnormalities occurred during the subsequent system operation. The CPU usage of about 4% would suddenly jump to 20%, 50% after a few hours, and eventually rise to 100% CPU usage, causing the node service to crash. After investigation, it was found that in the JDK1.6 environment, the expansion of HashMap under multi-threading would cause a circular linked list, causing the current thread to enter an infinite loop, resulting in an increase in CPU usage, even reaching 100%, which caused the node service to crash. It was decided to use a thread-safe ConcurrentHashMap to count multiple keys.

[0104] In the JDK1.6 environment, the specific reasons why HashMap causes the above phenomenon and the reasons for replacing it with ConcurrentHashMap are analyzed as follows:

[0105] 1) Causes of HashMap loop:

[0106] HashMap is a non-thread-safe collection. In concurrent situations, the linked list may form a loop, resulting in an infinite loop. The code that causes the loop appears in the transfer code, which is the data migration part after the expansion.

[0107] In the specific implementation process, first get the length of the new table, then traverse each entry in the new table, and then form a rehashed linked list in each entry in reverse form. Suppose there are a and b in a bucket of the map, and now c is to be inserted. Inserting c will cause expansion. Enter the above code. Our ideal insertion method inserts in the order of c->b->a. Combined with the code, the first loop for(Entry<K,V> e:table) traverses the old linked list, e is the first element, next is the next element, the three winning lines are to determine the position of the new linked list in the data, and the first insertion is from the beginning.

[0108] When you encounter the problem of concurrent multi-threaded expansion, for example, concurrent threads A and B. Assume that thread A executes first and executes to Entry<K,V> next=e.next. After executing this code, next points to b and thread A is suspended. Then thread B is executed. At this time, thread B succeeds and the linked list order is changed to c->b->a. Then, thread A resumes execution and when a is inserted at the head, next points to b because thread B has pointed b.next to a. This causes the map traversal or insertion to continue in an endless loop, causing the CPU to soar.

[0109] 2) Reasons for using ConcurrentHashMap to replace HashMap:

[0110] ConcurrentHashMap is a thread-safe collection, which consists of a Segment array and multiple HashEntry. The significance of Segment data is to divide a large table into multiple small tables for locking, that is, lock separation technology. First, the data is stored in segments. When a thread occupies the lock to access one of the segments, the data of other segments can also be accessed by other threads. When writing, only the Segment where the element is located can be locked. Ideally, ConcurrentHashMap can support write operations of up to the number of Segments at the same time. Therefore, using ConcurrentHashMap can avoid multiple threads accessing and operating the same segment of data at the same time, thereby avoiding the formation of a line switching linked list that causes an infinite loop, and solving the CPU surge problem caused by the HashMap closed loop.

[0111] Based on the use of multiple cache servers to disperse requests, the present invention starts from the root and uses ConcurrentHashMap to count multiple keys. When the count of a key reaches the maximum value N, redis is accessed to update the value of the key, thereby reducing the number of redis accesses and greatly reducing the call of a key, thereby solving the redis hot key problem.

[0112] Reference Figure 4 , which is a schematic diagram of a data feedback device provided by an embodiment of the present invention, the device can be used in an application system with hundreds of millions of visits, and the device is used to support Figure 1 The real-life implementation of the method shown is described below:

[0113] The receiving unit 401 is used to receive a service request;

[0114] A first determining unit 402 is used to determine a hot key corresponding to the service request from various preset hot keys, and determine the hot key as a target hot key;

[0115] A second determining unit 403 is used to determine a counter belonging to the target hot key among the preset counters as a target counter;

[0116] An updating unit 404, configured to update the count value in the target counter and determine whether the updated count value in the target counter is equal to a preset count threshold;

[0117] The calling unit 405 is used to call a preset redis cluster to feed back response data to the requester of the service request if it is determined that the updated count value in the target counter is equal to the count threshold, and update the request statistics of the target hot key in the redis cluster.

[0118] In the device provided by the embodiment of the present invention, a service request is received; a hot key corresponding to the service request is determined in each preset hot key, and the hot key is determined as a target hot key; a counter belonging to the target hot key in each preset counter is determined as a target counter; the count value in the target counter is updated, and it is determined whether the updated count value in the target counter is equal to the preset count threshold; if it is equal, the preset redis cluster is called to feedback response data to the requester of the service request, and the request statistics of the target hot key in the redis cluster are updated. After receiving the service request, the target hot key corresponding to the service request is first determined, and then the count value of the counter corresponding to the target hot key is updated. When the updated count value is equal to the preset calculation threshold, the redis cluster is called to feedback response data to the requester corresponding to the service request, thereby compressing the number of calls to the redis cluster and reducing the connection with the redis cluster, avoiding a large number of accesses in a short period of time that cause the system to crash.

[0119] In the device provided by the embodiment of the present invention, the first determining unit 402 in the device may also be configured as:

[0120] An acquisition module, used to obtain key information in the service request;

[0121] A matching module, used to match the key information with each preset hot key one by one;

[0122] The first determining module is used to determine a hot key matching the key information as a hot key corresponding to the service request.

[0123] In the device provided by the embodiment of the present invention, the calling unit 405 in the device may also be configured as follows:

[0124] An adding module, used for adding the service request to the request queue corresponding to the target hot key;

[0125] A second determination module is used to determine the node cluster to which the target hot key belongs in the redis cluster, wherein the node cluster includes multiple service nodes;

[0126] An allocation module, used to allocate each service request in the request queue to a corresponding service node;

[0127] The calling module is used to call the service node corresponding to each service request in the request queue to feed back response data corresponding to the target hot key to the requester of the service request.

[0128] In the device provided in the embodiment of the present invention, the device may further include:

[0129] An adding unit is used to add the service request to a request queue corresponding to the target hot key if it is determined that the updated count value in the target counter is not equal to the count threshold.

[0130] In the device provided in the embodiment of the present invention, the device may further include:

[0131] An initialization unit is used to initialize the target counter.

[0132] An embodiment of the present invention further provides a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the above-mentioned data feedback method.

[0133] The embodiment of the present invention further provides an electronic device, the structural diagram of which is shown in FIG. Figure 5 As shown, it specifically includes a memory 501 and one or more instructions 502, wherein the one or more instructions 502 are stored in the memory 501 and are configured to be executed by one or more processors 503 to perform the above-mentioned data feedback method.

[0134] The specific implementation processes and derivative methods of the above-mentioned embodiments are all within the protection scope of the present invention.

[0135] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0136] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0137] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data feedback method, characterized in that: include: Receive service requests; Determine a hot key corresponding to the service request from among various preset hot keys, and determine the hot key as a target hot key; Determine the counter belonging to the target hot key among the preset counters as the target counter; Updating the count value in the target counter, and determining whether the updated count value in the target counter is equal to a preset count threshold; If it is determined that the updated count value in the target counter is equal to the count threshold, calling a preset redis cluster to feed back response data to the requester of the service request, and updating the request statistics of the target hot key in the redis cluster; If it is determined that the updated count value in the target counter is not equal to the count threshold, adding the service request to the request queue corresponding to the target hot key; The calling of the preset redis cluster to feed back response data to the requester of the service request includes: Adding the service request to the request queue corresponding to the target hot key; Determine in the redis cluster the node cluster to which the target hot key belongs, wherein the node cluster includes multiple service nodes; Allocating each service request in the request queue to a corresponding service node; For each service request in the request queue, the service node corresponding to the service request is called to feed back response data corresponding to the target hot key to the requester of the service request.

2. The method according to claim 1, characterized in that The step of determining the hot key corresponding to the service request from among the preset hot keys includes: Obtain key information in the service request; Match the key information with each preset hot key one by one; A hot key matching the key information is determined as a hot key corresponding to the service request.

3. The method according to claim 1, characterized in that Also includes: The target counter is initialized.

4. A data feedback device, characterized in that: include: A receiving unit, configured to receive a service request; A first determining unit, configured to determine a hot key corresponding to the service request from among various preset hot keys, and determine the hot key as a target hot key; A second determining unit, configured to determine a counter belonging to the target hot key among the preset counters as a target counter; an updating unit, configured to update the count value in the target counter and determine whether the updated count value in the target counter is equal to a preset count threshold; A calling unit, configured to call a preset redis cluster to feed back response data to the requester of the service request and update the request statistics of the target hot key in the redis cluster if it is determined that the updated count value in the target counter is equal to the count threshold; an adding unit, configured to add the service request to a request queue corresponding to the target hot key if it is determined that the updated count value in the target counter is not equal to the count threshold; Wherein, the calling unit includes: An adding module, used for adding the service request to the request queue corresponding to the target hot key; A second determination module is used to determine the node cluster to which the target hot key belongs in the redis cluster, wherein the node cluster includes multiple service nodes; An allocation module, used to allocate each service request in the request queue to a corresponding service node; The calling module is used to call the service node corresponding to each service request in the request queue to feed back response data corresponding to the target hot key to the requester of the service request.

5. The device according to claim 4, characterized in that The first determining unit includes: An acquisition module, used to obtain key information in the service request; A matching module, used to match the key information with each preset hot key one by one; The first determining module is used to determine a hot key matching the key information as a hot key corresponding to the service request.

6. A storage medium, characterized in that: The storage medium includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the data feedback method according to any one of claims 1 to 3.

7. An electronic device, characterized in that: The device comprises a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to execute the data feedback method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Data distribution method based on Redis cluster and related equipment

    CN111124672A

  • Cache system hotspot data access method and device, equipment and storage medium

    CN112115167A