A method, device and system for limiting the number of topology map pull commands
Through the working together of the current limiting component and the monitoring component, the number of topology map pull commands of the REDIS server is limited, which solves the overload problem caused by topology map pull of the REDIS server, and achieves stable operation and cost savings of the server.
Patent Information
- Application Number
- CN202211120956.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-15
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-09-15
AI Technical Summary
When facing a large number of connection requests, the frequent pulling of the topology diagram leads to excessive CPU load and network traffic pressure, which is prone to overload and cannot provide services normally. The protection methods of the existing technology are costly and at risk of failure.
Through the working together of the current limiting component and the monitoring component, the number of cluster topology map pull commands executed by the REDIS server within a unit time is limited, and the random wait mechanism and connection disconnection mechanism are adopted to control the topology refresh traffic and avoid overloading.
It effectively avoids the overload of REDIS server due to the outbreak of topology drawing requests, reduces the risk and cost of server overload, ensures the normal operation of the server, and avoids the risk of new failures caused by proxy flow restriction.
Smart Images

Figure CN115550260B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of REDIS servers, and in particular to a method, device and system for limiting the number of topology map pulling commands. Background Art
[0002] REDIS supports cluster mode distributed deployment of multiple REDIS instances to meet business needs. With the help of Hash algorithm, the key value corresponding to the task is mapped to 0~2 14 -1. A REDIS instance is responsible for a range of key values within this range, evenly distributing the corresponding key values across multiple REDIS instances for processing. A cluster topology diagram is used to represent the mapping between key values and REDIS instances, allowing clients to identify the servers where instances reside. After establishing a connection with any instance, the REDIS client pulls the cluster topology diagram. Generating the corresponding cluster topology diagram consumes the CPU usage of the server where REDIS resides. The CPU usage O is directly proportional to the total number of instances n, O(n). Frequent topology diagram pulls in significant pressure on REDIS's CPU load and network traffic.
[0003] When the REDIS client encounters network jitter or operation timeout, it will usually retry the timeout error, try to re-establish the connection, and pull the cluster topology again to update the topology. Excessive topology pulling will cause the REDIS server to be overloaded and unable to provide normal services. The number of clients of large Internet applications can be as high as 10 4 Simultaneous topology updates will overwhelm the server and easily lead to overload. Once REDIS is overloaded, the server CPU will be unable to process tasks in a timely manner, resulting in more timeouts. This will in turn cause more topology update requests to be sent to the REDIS server per unit time, causing REDIS to enter an avalanche state and be unable to provide external services normally.
[0004] In the prior art, the protection methods for server overload caused by the above-mentioned topology pulling are: implanting protection code in the client to limit the client's connection operations; or setting up a proxy in front of the server, allowing applications to access REDIS through the proxy, and limiting the topology updates on the proxy side. However, client-side current limiting requires all businesses to cooperate with the client code upgrade, which is difficult to implement; using proxy current limiting requires setting up a proxy in front of REDIS, which increases server costs. At the same time, the introduction of new components will also bring new failure risks. Therefore, there is an urgent need for a method, device and system for limiting the number of topology map pulling commands, which can accurately and effectively prevent the REDIS server from being overloaded and unable to provide services normally due to the formation of a connection storm when facing a large number of connection requests; at the same time, compared with the prior art, it can effectively reduce the cost of the REDIS server from being overloaded during a connection storm. Summary of the Invention
[0005] In order to solve the problem of REDIS connection storm in the prior art, the embodiment of the present invention provides a method, device and system for limiting the number of topology map pull commands. It accurately and effectively prevents the REDIS server from being overloaded and unable to provide services normally due to the formation of a connection storm when facing a large number of connection requests. At the same time, compared with the prior art, it effectively reduces the cost of the REDIS server from being overloaded during a connection storm. In order to solve one or more of the above technical problems, the technical solutions adopted by the present invention are as follows:
[0006] In a first aspect, a method for limiting the number of topology map pull commands is provided, for limiting the number of cluster topology map pull commands executed by a REDIS server per unit time, and is applied to a REDIS server. The method comprises:
[0007] Receive the current refresh command from the REDIS client requesting to refresh the cluster topology map;
[0008] The current refresh command is transmitted to the current limiting component to determine the topology refresh flow and wait for processing;
[0009] Process the current refresh command based on the result of the topology refresh traffic judgment.
[0010] Furthermore, the topology refresh traffic is judged, including:
[0011] The current limiting component reports the current refresh command to the monitoring component so that the monitoring component can calculate the refresh command rate;
[0012] The current limiting component obtains the refresh command rate calculated based on the current refresh command from the monitoring component;
[0013] The rate limiting component compares the refresh command rate with the preset rate limit threshold.
[0014] Furthermore, the refresh command rate is calculated, including:
[0015] Add 1 to the total number of refresh commands waiting to be processed in the current limiting component to obtain the current total number of refresh commands to be processed;
[0016] The quotient of the total number of refresh commands to be processed and the preset time is used as the refresh command rate.
[0017] Furthermore, based on the result of the topology refresh flow determination, the current refresh command is processed, including:
[0018] If the refresh command rate is greater than the preset rate limit threshold, the execution of the refresh command is blocked;
[0019] If the refresh command rate is less than or equal to the preset rate limit threshold, the refresh command is executed.
[0020] Furthermore, the execution of the refresh command is prevented, including:
[0021] Generate a random wait time corresponding to the current refresh command;
[0022] Implement a waiting process for the current refresh command, and the length of the waiting process is a random waiting time;
[0023] After the waiting process corresponding to the current refresh command is completed, disconnect from the REDIS client.
[0024] Furthermore, the random waiting time is generated by a random number generation function according to a preset time range. In a second aspect, a method for limiting the number of topology map pull commands is provided, which is used to limit the number of cluster topology map pull commands executed by the REDIS server per unit time, and is applied to the REDIS client. The method includes:
[0025] When network jitter causes the REDIS client to time out, read the REDIS server address configuration and prepare to retry;
[0026] Establish a connection with the REDIS server and send a current refresh command requesting to refresh the cluster topology map to the REDIS server, so that the REDIS server can execute a method for limiting the number of topology map pull commands.
[0027] In a third aspect, a device for limiting the number of topology map pull commands is provided, which is used to limit the number of cluster topology map pull commands executed by a REDIS server within a unit time. The device is applied to a REDIS server and includes: a command receiving module, a traffic judgment module, and a command processing module;
[0028] The command receiving module is used to receive the current refresh command requested by the REDIS client to refresh the cluster topology map;
[0029] The traffic judgment module is used to transmit the current refresh command to the current limiting component to perform topology refresh traffic judgment and wait for processing;
[0030] The command processing module is used to process the current refresh command according to the result of the topology refresh traffic judgment.
[0031] In a fourth aspect, a device for limiting the number of topology map pull commands is provided, which is used to limit the number of cluster topology map pull commands executed by a REDIS server within a unit time, and is applied to a REDIS client. The device includes: a configuration reading module, a command sending module;
[0032] The configuration reading module is used to read the REDIS server address configuration and prepare to retry when the network jitter causes the REDIS client to time out;
[0033] The command sending module is used to establish a connection with the REDIS server and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute a method for limiting the number of topology map pulling commands.
[0034] In a fifth aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method described in the first aspect are implemented.
[0035] In a sixth aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method described in the second aspect are implemented.
[0036] In a seventh aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0037] In an eighth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the second aspect are implemented.
[0038] The technical solution provided by the embodiment of the present invention has the following beneficial effects:
[0039] 1. By implementing a method for limiting the number of topology map pull commands disclosed in an embodiment of the present invention, it is effectively avoided that the server is overloaded due to an outbreak of cluster topology map pull requests in a short period of time, resulting in the server being unable to provide external services;
[0040] 2. A protection mechanism is established on the server side to prevent server overload caused by pulling the cluster topology diagram. There is no need to consider the relevant parameter settings of the client, nor is there any need to guide users to set timeout retries on the client, which improves the normal operation guarantee mechanism of the server; avoids the potential failure risks brought about by setting up agents and introducing new components, and saves the cost of setting up agents. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 This is a schematic diagram of a method for limiting the number of topology map pull commands applied to a REDIS server provided by an embodiment of the present invention;
[0043] Figure 2 This is a schematic diagram of a method for limiting the number of topology map pull commands applied to a REDIS client according to an embodiment of the present invention;
[0044] Figure 3 Schematic diagram of a device for limiting the number of topology map pull commands applied to a REDIS server according to an embodiment of the present invention;
[0045] Figure 4 This is a schematic diagram of a device for limiting the number of topology map pull commands applied to a REDIS client provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0047] Unless otherwise defined, technical or scientific terms used in this disclosure should have the ordinary meaning understood by a person of ordinary skill in the art to which this disclosure belongs. The terms "first," "second," and similar expressions used in this disclosure do not indicate any order, quantity, or importance, but are simply used to distinguish different components. Similarly, terms such as "a," "an," or "the" do not indicate a quantitative limitation, but rather indicate the presence of at least one. The numbers in the drawings in this specification merely distinguish between various functional components or modules and do not indicate a logical relationship between the components or modules. Terms such as "include" or "comprising" mean that the element or object preceding the term includes the elements or objects listed after the term, and their equivalents, without excluding other elements or objects. Terms such as "connected" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0048] Hereinafter, various embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. Note that, in the accompanying drawings, the same reference numerals are given to components having substantially the same or similar structures and functions, and repeated descriptions thereof will be omitted.
[0049] REDIS servers are popular among users for their fast response speeds, but they still lack effective means to deal with connection storms. In the prior art, infinite-flow REDIS servers have the problem of connection storms. The embodiments of the present invention provide a method, device, and system for limiting the number of topology map pull commands. This method accurately and effectively prevents the REDIS server from being overloaded and unable to provide services normally due to the formation of a connection storm when faced with a large number of connection requests. At the same time, compared to the prior art, the method effectively reduces the cost of preventing the REDIS server from being overloaded during a connection storm.
[0050] In one embodiment, a method for limiting the number of topology map pull commands is used to limit the number of cluster topology map pull commands executed by a REDIS server per unit time, and is applied to a REDIS server, such as Figure 1 As shown, the method includes:
[0051] S110: receiving a current refresh command from the REDIS client requesting to refresh the cluster topology map;
[0052] S120: Transmit the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing;
[0053] S130: Process the current refresh command according to the result of the topology refresh flow determination.
[0054] In another embodiment, performing topology refresh traffic determination specifically includes:
[0055] S121: The current limiting component reports the current refresh command to the monitoring component so that the monitoring component can calculate the refresh command rate;
[0056] S122: The current limiting component obtains the refresh command rate calculated according to the current refresh command from the monitoring component;
[0057] S123: The current limiting component compares the refresh command rate with a preset rate limit threshold.
[0058] In one embodiment, the threshold is determined by the refresh command rate when CPU utilization reaches 90%. A preset rate limit of 2,000 to 3,000 commands per second is used to achieve 90% CPU utilization. In another embodiment, the CPU processing of refresh topology commands is limited to 10% CPU utilization, limiting the topology command refresh rate to 200 to 300 commands per second to avoid excessive server pressure.
[0059] In one embodiment, calculating the refresh command rate includes:
[0060] S1211: Add 1 to the total number of refresh commands waiting to be processed in the current limiting component to obtain the total number of refresh commands currently waiting to be processed;
[0061] S1212: The quotient of the total number of refresh commands to be processed and the preset time is used as the refresh command rate.
[0062] In one embodiment, processing the current refresh command according to the result of the topology refresh flow determination specifically includes:
[0063] S131: If the refresh command rate is greater than a preset rate limit threshold, preventing the refresh command from being executed;
[0064] S131 ′: If the refresh command rate is less than or equal to the preset rate limit threshold, the refresh command is executed.
[0065] In one embodiment, preventing the execution of the refresh command specifically includes:
[0066] S1311: Generate a random waiting time corresponding to the current refresh command;
[0067] S1312: Implementing a waiting process for the current refresh command, where the duration of the waiting process is a random waiting time; the random waiting time is generated by a random number generation function according to a preset time range.
[0068] S1313: After the waiting process corresponding to the current refresh command ends, disconnect the connection with the REDIS client.
[0069] In one embodiment, the random waiting time is any value between 0 and 20 ms.
[0070] In another embodiment, a method for limiting the number of topology map pull commands is provided, which is used to limit the number of cluster topology map pull commands executed by the REDIS server within a unit time, and is applied to the REDIS client, such as Figure 2 As shown, the method includes:
[0071] S210: When the network jitter causes the REDIS client to time out, read the REDIS server address configuration and prepare to retry;
[0072] S220: Establish a connection with the REDIS server, and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute the method of limiting the number of topology map pulling commands.
[0073] In another embodiment, a device for limiting the number of topology map pull commands is provided, which is used to limit the number of cluster topology map pull commands executed by the REDIS server within a unit time, and is applied to the REDIS server, such as Figure 3 As shown, the device includes: a command receiving module, a flow determination module, and a command processing module;
[0074] The command receiving module is used to receive the current refresh command requested by the REDIS client to refresh the cluster topology map;
[0075] The traffic judgment module is used to transmit the current refresh command to the current limiting component to perform topology refresh traffic judgment and wait for processing;
[0076] The command processing module is used to process the current refresh command according to the result of the topology refresh traffic judgment.
[0077] In another embodiment, a device for limiting the number of topology map pull commands is used to limit the number of cluster topology map pull commands executed by a REDIS server per unit time, and is applied to a REDIS client, such as Figure 4 As shown, the device includes: a configuration reading module, a command sending module;
[0078] The configuration reading module is used to read the REDIS server address configuration and prepare to retry when the network jitter causes the REDIS client to time out;
[0079] The command sending module is used to establish a connection with the REDIS server and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute a method for limiting the number of topology map pulling commands.
[0080] In another embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the computer program.
[0081] In another embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the second aspect when executing the computer program.
[0082] In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0083] In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the second aspect are implemented.
[0084] By implementing a method, device and system for limiting the number of topology map pulling commands disclosed in an embodiment of the present invention, it is effectively avoided that the server is overloaded due to an outbreak of requests for pulling cluster topology maps in a short period of time, resulting in the server being unable to provide services to the outside world; a protection mechanism for server overload caused by pulling cluster topology maps is established on the server side, without considering the relevant parameter settings of the client, and without guiding the user to set timeout retries on the client, thereby improving the normal operation guarantee mechanism of the server; avoiding the potential failure risks brought about by setting up a proxy and introducing new components, and saving the cost of setting up the proxy.
[0085] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present invention, and will not be described in detail here.
[0086] Example 1
[0087] A method for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by the REDIS server per unit time, applied to the REDIS server, such as Figure 1 As shown, the method includes:
[0088] S110: receiving a current refresh command from the REDIS client requesting to refresh the cluster topology map;
[0089] S120: Transmit the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing;
[0090] S130: Process the current refresh command according to the result of the topology refresh flow determination.
[0091] Example 2
[0092] A method for limiting the number of topology map pull commands specifically includes:
[0093] S110: receiving a current refresh command from the REDIS client requesting to refresh the cluster topology map;
[0094] S120: Transmit the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing;
[0095] Perform topology refresh traffic judgment, including:
[0096] S121: The current limiting component reports the current refresh command to the monitoring component so that the monitoring component can calculate the refresh command rate;
[0097] Calculate the refresh command rate, including:
[0098] S1211: Add 1 to the total number of refresh commands waiting to be processed in the current limiting component to obtain the total number of refresh commands currently waiting to be processed;
[0099] S1212: The quotient of the total number of refresh commands to be processed and the preset time is used as the refresh command rate.
[0100] S122: The current limiting component obtains the refresh command rate calculated according to the current refresh command from the monitoring component;
[0101] S123: The current limiting component compares the refresh command rate with a preset rate limit threshold.
[0102] The preset rate limit threshold is set in the following way: when the CPU usage reaches 10%, the corresponding refresh command rate.
[0103] S130: Processing the current refresh command according to the result of the topology refresh flow determination, specifically including:
[0104] S131: If the refresh command rate is greater than a preset rate limit threshold, preventing the refresh command from being executed;
[0105] Prevent the execution of refresh commands, including:
[0106] S1311: Generate a random waiting time corresponding to the current refresh command; the random waiting time is generated by a random number generation function according to a preset time range. In this embodiment, the length of the random waiting time is any value within a range of 0 to 20 ms.
[0107] S1312: Implement a waiting process for the current refresh command, where the duration of the waiting process is a random waiting time.
[0108] S1313: After the waiting process corresponding to the current refresh command ends, disconnect the connection with the REDIS client.
[0109] S131 ′: If the refresh command rate is less than or equal to the preset rate limit threshold, the refresh command is executed.
[0110] Example 3
[0111] A method for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by the REDIS server per unit time, applied to the REDIS client, such as Figure 2 As shown, the method includes:
[0112] S210: When the network jitter causes the REDIS client to time out, read the REDIS server address configuration and prepare to retry;
[0113] S220: Establish a connection with the REDIS server, and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute the method of limiting the number of topology map pulling commands.
[0114] Example 4
[0115] A device for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by a REDIS server within a unit time, applied to a REDIS server, such as Figure 3 As shown, the device includes: a command receiving module, a flow determination module, and a command processing module;
[0116] The command receiving module is used to receive the current refresh command requested by the REDIS client to refresh the cluster topology map;
[0117] The traffic judgment module is used to transmit the current refresh command to the current limiting component to perform topology refresh traffic judgment and wait for processing;
[0118] The command processing module is used to process the current refresh command according to the result of the topology refresh traffic judgment.
[0119] Example 5
[0120] A device for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by the REDIS server within a unit time, applied to the REDIS client, such as Figure 4 As shown, the device includes: a configuration reading module, a command sending module;
[0121] The configuration reading module is used to read the REDIS server address configuration and prepare to retry when the network jitter causes the REDIS client to time out;
[0122] The command sending module is used to establish a connection with the REDIS server and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute a method for limiting the number of topology map pulling commands.
[0123] Example 6
[0124] In another embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for limiting the number of topology map pull commands applied to a REDIS server are implemented, specifically including:
[0125] S110: receiving a current refresh command from the REDIS client requesting to refresh the cluster topology map;
[0126] S120: Transmit the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing;
[0127] Perform topology refresh traffic judgment, including:
[0128] S121: The current limiting component reports the current refresh command to the monitoring component so that the monitoring component can calculate the refresh command rate;
[0129] Calculate the refresh command rate, including:
[0130] S1211: Add 1 to the total number of refresh commands waiting to be processed in the current limiting component to obtain the total number of refresh commands currently waiting to be processed;
[0131] S1212: The quotient of the total number of refresh commands to be processed and the preset time is used as the refresh command rate.
[0132] S122: The current limiting component obtains the refresh command rate calculated according to the current refresh command from the monitoring component;
[0133] S123: The current limiting component compares the refresh command rate with a preset rate limit threshold.
[0134] The preset rate limit threshold is set in the following way: when the CPU usage reaches 10%, the corresponding refresh command rate.
[0135] S130: Processing the current refresh command according to the result of the topology refresh flow determination, specifically including:
[0136] S131: If the refresh command rate is greater than a preset rate limit threshold, preventing the refresh command from being executed;
[0137] Prevent the execution of refresh commands, including:
[0138] S1311: Generate a random waiting time corresponding to the current refresh command; the random waiting time is generated by a random number generation function according to a preset time range. In this embodiment, the length of the random waiting time is any value within the range of 0 to 20ms.
[0139] S1312: Implement a waiting process for the current refresh command, where the duration of the waiting process is a random waiting time.
[0140] S1313: After the waiting process corresponding to the current refresh command ends, disconnect the connection with the REDIS client.
[0141] S131 ′: If the refresh command rate is less than or equal to the preset rate limit threshold, the refresh command is executed.
[0142] Example 7
[0143] In another embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for limiting the number of topology map pull commands applied to a REDIS client are implemented, specifically including:
[0144] S210: When the network jitter causes the REDIS client to time out, read the REDIS server address configuration and prepare to retry;
[0145] S220: Establish a connection with the REDIS server, and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute the method of limiting the number of topology map pulling commands.
[0146] Example 8
[0147] In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for limiting the number of topology map pull commands applied to the REDIS server are implemented, specifically including:
[0148] S110: receiving a current refresh command from the REDIS client requesting to refresh the cluster topology map;
[0149] S120: Transmit the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing;
[0150] Perform topology refresh traffic judgment, including:
[0151] S121: The current limiting component reports the current refresh command to the monitoring component so that the monitoring component can calculate the refresh command rate;
[0152] Calculate the refresh command rate, including:
[0153] S1211: Add 1 to the total number of refresh commands waiting to be processed in the current limiting component to obtain the total number of refresh commands currently waiting to be processed;
[0154] S1212: The quotient of the total number of refresh commands to be processed and the preset time is used as the refresh command rate.
[0155] S122: The current limiting component obtains the refresh command rate calculated according to the current refresh command from the monitoring component;
[0156] S123: The current limiting component compares the refresh command rate with a preset rate limit threshold.
[0157] The preset rate limit threshold is set in the following way: when the CPU usage reaches 10%, the corresponding refresh command rate.
[0158] S130: Processing the current refresh command according to the result of the topology refresh flow determination, specifically including:
[0159] S131: If the refresh command rate is greater than a preset rate limit threshold, preventing the refresh command from being executed;
[0160] Prevent the execution of refresh commands, including:
[0161] S1311: Generate a random waiting time corresponding to the current refresh command; the random waiting time is generated by a random number generation function according to a preset time range. In this embodiment, the length of the random waiting time is any value within the range of 0 to 20ms.
[0162] S1312: Implement a waiting process for the current refresh command, where the duration of the waiting process is a random waiting time.
[0163] S1313: After the waiting process corresponding to the current refresh command ends, disconnect the connection with the REDIS client.
[0164] S131 ′: If the refresh command rate is less than or equal to the preset rate limit threshold, the refresh command is executed.
[0165] Embodiment 9
[0166] In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for limiting the number of topology map pull commands applied to a REDIS client are implemented, specifically including:
[0167] S210: When the network jitter causes the REDIS client to time out, read the REDIS server address configuration and prepare to retry;
[0168] S220: Establish a connection with the REDIS server, and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute the method of limiting the number of topology map pulling commands.
[0169] By implementing a method, device and system for limiting the number of topology map pulling commands disclosed in an embodiment of the present invention, it is effectively avoided that the server is overloaded due to an outbreak of requests for pulling cluster topology maps in a short period of time, resulting in the server being unable to provide services to the outside world; a protection mechanism for server overload caused by pulling cluster topology maps is established on the server side, without considering the relevant parameter settings of the client, and without guiding the user to set timeout retries on the client, thereby improving the normal operation guarantee mechanism of the server; avoiding the potential failure risks brought about by setting up a proxy and introducing new components, and saving the cost of setting up the proxy.
[0170] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program loaded on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a memory, or installed from a ROM. When the computer program is executed by an external processor, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0171] It should be noted that the computer-readable medium of the embodiments of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present application, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device. In the embodiments of the present application, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or convey a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0172] The computer-readable medium may be included in the server or may exist independently and not incorporated into the server. The computer-readable medium carries one or more programs that, when executed by the server, cause the server to: in response to detecting that the terminal's peripheral mode is inactive, obtain the frame rate of applications on the terminal; when the frame rate meets a screen-off condition, determine whether the user is currently accessing the terminal's screen information; and, in response to determining that the user is not accessing the terminal's screen information, control the screen to enter an immediate dimming mode.
[0173] Computer program code for performing the operations of embodiments of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0174] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For relevant parts, 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 can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.
[0175] The above is a detailed introduction to the technical solutions provided by this application. Specific examples are used herein to illustrate the principles and implementation methods of this application. The description of the above embodiments is only intended to help understand the method and core concept of this application. At the same time, for those skilled in the art, based on the concept of this application, there may be changes in the specific implementation methods and application scope. In summary, the contents of this specification should not be understood as limiting this application.
[0176] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by a REDIS server per unit time, applied to a REDIS server, characterized in that: The method comprises: Receive the current refresh command from the REDIS client requesting to refresh the cluster topology map; Transmitting the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing; Processing the current refresh command according to the result of the topology refresh flow determination; The step of processing the current refresh command according to the result of the topology refresh flow determination includes: If the refresh command rate is greater than a preset rate limit threshold, preventing the execution of the refresh command; Wherein, preventing the execution of the refresh command includes: generating a random wait time corresponding to the current refresh command; Implementing a waiting process for the current refresh command, wherein the duration of the waiting process is the random waiting time; After the waiting process corresponding to the current refresh command ends, the connection with the REDIS client is disconnected.
2. A method for limiting the number of topology map pull commands according to claim 1, characterized in that: The topology refresh flow determination includes: The current limiting component reports the current refresh command to the monitoring component so that the monitoring component can calculate the refresh command rate; The current limiting component obtains a refresh command rate calculated according to the current refresh command from the monitoring component; The current limiting component compares the refresh command rate with a preset rate limit threshold.
3. A method for limiting the number of topology map pull commands according to claim 2, characterized in that: The calculating the refresh command rate includes: Add 1 to the total number of refresh commands waiting to be processed in the current limiting component to obtain the total number of refresh commands currently to be processed; The quotient of the total number of refresh commands to be processed and the preset time is used as the refresh command rate.
4. The method for limiting the number of topology map pull commands according to claim 1, characterized in that: The processing of the current refresh command according to the result of the topology refresh flow determination further includes: If the refresh command rate is less than or equal to the preset rate limit threshold, the refresh command is executed.
5. The method for limiting the number of topology map pull commands according to claim 1, characterized in that: The random waiting time is generated by a random number generation function according to a preset time range.
6. A method for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by a REDIS server per unit time, applied to a REDIS client, characterized in that: The method comprises: When network jitter causes the REDIS client to time out, read the REDIS server address configuration and prepare to retry; Establishing a connection with the REDIS server and sending a current refresh command requesting a refresh of the cluster topology map to the REDIS server, so that the REDIS server executes a method for limiting the number of topology map pull commands; The method for limiting the number of topology map pull commands executed by the REDIS server includes: Receive the current refresh command from the REDIS client requesting to refresh the cluster topology map; Transmitting the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing; Processing the current refresh command according to the result of the topology refresh flow determination; The step of processing the current refresh command according to the result of the topology refresh flow determination includes: If the refresh command rate is greater than a preset rate limit threshold, preventing the execution of the refresh command; Wherein, preventing the execution of the refresh command includes: generating a random wait time corresponding to the current refresh command; Implementing a waiting process for the current refresh command, wherein the duration of the waiting process is the random waiting time; After the waiting process corresponding to the current refresh command ends, the connection with the REDIS client is disconnected.
7. A device for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by a REDIS server per unit time, applied to a REDIS server, characterized in that: The device includes: a command receiving module, a flow determination module, and a command processing module; The command receiving module is used to receive the current refresh command requested by the REDIS client to refresh the cluster topology map; The flow judgment module is used to transmit the current refresh command to the current limiting component to perform topology refresh flow judgment and wait for processing; The command processing module is configured to process the current refresh command according to the result of the topology refresh flow determination; The step of processing the current refresh command according to the result of the topology refresh flow determination includes: If the refresh command rate is greater than a preset rate limit threshold, preventing the execution of the refresh command; Wherein, preventing the execution of the refresh command includes: generating a random wait time corresponding to the current refresh command; Implementing a waiting process for the current refresh command, wherein the duration of the waiting process is the random waiting time; After the waiting process corresponding to the current refresh command ends, the connection with the REDIS client is disconnected.
8. A device for limiting the number of topology map pull commands, used to limit the number of cluster topology map pull commands executed by a REDIS server per unit time, applied to a REDIS client, characterized in that: The device includes: a configuration reading module and a command sending module; The configuration reading module is used to read the REDIS server address configuration and prepare for retry when the REDIS client times out due to network jitter; The command sending module is used to establish a connection with the REDIS server and send a current refresh command to the REDIS server requesting to refresh the cluster topology map, so that the REDIS server can execute the method of limiting the number of topology map pulling commands; The method for limiting the number of topology map pull commands executed by the REDIS server includes: Receive the current refresh command from the REDIS client requesting to refresh the cluster topology map; Transmitting the current refresh command to the current limiting component to determine the topology refresh flow and wait for processing; Processing the current refresh command according to the result of the topology refresh flow determination; The step of processing the current refresh command according to the result of the topology refresh flow determination includes: If the refresh command rate is greater than a preset rate limit threshold, preventing the execution of the refresh command; Wherein, preventing the execution of the refresh command includes: generating a random wait time corresponding to the current refresh command; Implementing a waiting process for the current refresh command, wherein the duration of the waiting process is the random waiting time; After the waiting process corresponding to the current refresh command ends, the connection with the REDIS client is disconnected.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Current limiting method and device, server and server cluster
CN111988355A