CN110971697B - Redis single instance protection processing method and device, computer equipment and storage medium - Google Patents

Redis single instance protection processing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN110971697B
CN110971697B CN201911243569.XA CN201911243569A CN110971697B CN 110971697 B CN110971697 B CN 110971697B CN 201911243569 A CN201911243569 A CN 201911243569A CN 110971697 B CN110971697 B CN 110971697B
Authority
CN
China
Prior art keywords
access request
redis
error rate
redis single
single instance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911243569.XA
Other languages
Chinese (zh)
Other versions
CN110971697A (en
Inventor
庞登
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Onething Technology Co Ltd
Original Assignee
Shenzhen Onething Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Onething Technology Co Ltd filed Critical Shenzhen Onething Technology Co Ltd
Priority to CN201911243569.XA priority Critical patent/CN110971697B/en
Publication of CN110971697A publication Critical patent/CN110971697A/en
Application granted granted Critical
Publication of CN110971697B publication Critical patent/CN110971697B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1014Server selection for load balancing based on the content of a request

Abstract

The invention provides a Redis single-instance protection processing method, which comprises the following steps: receiving an access request of a client to a Redis single instance through an access proxy; calculating a request error rate on the Redis single instance in the current period; judging whether the request error rate in the current period is greater than the error rate threshold value in the current period; responding to that the request error rate in the current period is larger than or equal to the error rate threshold in the current period, and performing differentiation processing on the access request according to the level of the access request to protect the Redis single instance. The invention also provides a Redis single instance protection processing device, computer equipment and a storage medium. The invention receives the access request of the client to the Redis single instance by taking the access proxy as the intermediate medium, thereby avoiding the direct connection between the client and the Redis single instance; by carrying out differentiated processing on the access request, the overload of the Redis single instance can be avoided, and the protection of the Redis single instance is realized.

Description

Redis single instance protection processing method and device, computer equipment and storage medium
Technical Field
The invention relates to the technical field of computer networks, in particular to a Redis single-instance protection processing method and device, computer equipment and a storage medium.
Background
Redis, known as a key-Value memory database, has high performance, reliability and expansibility, and is applied to various industries in a production environment, such as a leader board, a message queue, a publishing subscription and the like in games.
However, since the service frequently requests access to the Redis single instance (master node master or slave node slave), it may cause the load of the Redis single instance to be too high, thereby causing service delay or unstable service quality.
Therefore, it is necessary to provide a Redis single-instance protection processing scheme to avoid the load of the Redis single-instance being too high, thereby improving the service quality of the Redis single-instance.
Disclosure of Invention
The invention mainly aims to provide a Redis single-instance protection processing method, a device, computer equipment and a storage medium, and aims to solve the technical problem that the load is too high due to too many access requests on a Redis single instance.
In order to achieve the above object, a first aspect of the present invention provides a method for Redis single-instance protection processing, which is applied to a Redis cluster, and the method includes:
receiving an access request of a client to a Redis single instance through an access proxy;
calculating a request error rate on the Redis single instance in the current period;
judging whether the request error rate in the current period is greater than the error rate threshold value in the current period;
responding to that the request error rate in the current period is larger than or equal to the error rate threshold in the current period, and performing differentiation processing on the access request according to the level of the access request to protect the Redis single instance.
According to an optional embodiment of the present invention, the differentially processing the access request according to the level of the access request includes:
obtaining the request type of the access request through the access agent;
identifying a priority of the access request according to the request type;
and sending an access request corresponding to the priority higher than a preset priority threshold to the Redis single instance, and refusing to receive the access request corresponding to the priority lower than the preset priority threshold.
According to an optional embodiment of the present invention, the differentially processing the access request according to the level of the access request includes:
acquiring a feature code carried in the access request through the access agent;
identifying the service level of the access request according to the feature code;
and sending an access request corresponding to the service level higher than the preset level threshold value to the Redis single instance, and refusing to receive the access request corresponding to the service level lower than the preset level threshold value.
According to an optional embodiment of the present invention, the calculating a request error rate on the Redis single instance in the current cycle comprises:
calculating a first number of access requests on the Redis single instance in a current period;
calculating a second number of access request errors on the Redis single instance within the current period;
and calculating the request error rate in the current period according to the first number and the second number.
According to an optional embodiment of the present invention, the calculating a second number of access request errors on the Redis single instance in the current cycle comprises:
acquiring connection time of the access request on the Redis single instance in the current period, calculating the number of target connection time which is greater than or equal to a preset connection time threshold value, and determining the number of the target connection time as the second number; or
Acquiring the response time of the access request on the Redis single instance in the current period, calculating the number of target response times which are greater than or equal to a preset response time threshold value, and determining that the number of the target response times is the second number.
According to an alternative embodiment of the invention, the method further comprises:
calculating the request error rate on the Redis single instance in the next period;
judging whether the request error rate in the next period is smaller than the error rate threshold value in the next period;
and in response to the request error rate in the next period being less than or equal to the error rate threshold in the next period, performing normal processing on the access request to recover normal service of the Redis single instance.
According to an alternative embodiment of the invention, the method further comprises:
acquiring the CPU utilization rate of the Redis single instance in the current period;
judging whether the CPU utilization rate is greater than a preset utilization rate threshold value or not;
in response to the CPU utilization being greater than or equal to the preset utilization threshold, increasing an error rate threshold in the next cycle;
and in response to the CPU utilization rate being lower than the preset utilization rate threshold, reducing the error rate threshold in the next period.
To achieve the above object, a second aspect of the present invention provides a Redis single-instance protection processing apparatus, operating in a Redis cluster, the apparatus including:
the receiving module is used for receiving an access request of a client to the Redis single instance through an access agent;
the calculation module is used for calculating the request error rate on the Redis single instance in the current period;
the judging module is used for judging whether the request error rate in the current period is greater than the error rate threshold value in the current period;
and the processing module is used for responding to the condition that the request error rate in the current period is greater than or equal to the error rate threshold value in the current period, and carrying out differentiated processing on the access request according to the level of the access request so as to protect the Redis single instance.
To achieve the above object, a third aspect of the present invention provides a computer device, which includes a memory and a processor, wherein the memory stores a downloaded program of a Redis single-instance protection processing method executable on the processor, and the downloaded program of the Redis single-instance protection processing method implements the Redis single-instance protection processing method when executed by the processor.
To achieve the above object, a fourth aspect of the present invention provides a computer-readable storage medium having stored thereon a downloaded program of a Redis single-instance protection processing method, the downloaded program of the Redis single-instance protection processing method being executable by one or more processors to implement the Redis single-instance protection processing method.
According to the Redis single-instance protection processing method, the Redis single-instance protection processing device, the computer equipment and the storage medium, the access proxy is used as an intermediate medium to receive the access request of the client to the Redis single instance, so that the direct connection between the client and the Redis single instance is avoided; when the error rate of the request on the Redis single instance is calculated to be larger than the error rate threshold value in the current period, the access request is subjected to differentiation processing according to the level of the access request, so that the overload of the Redis single instance can be avoided, and the protection of the Redis single instance is realized; in addition, the load of the Redis single instance is reduced, the service quality of the Redis single instance to the access request can be improved, and the stability of the Redis cluster is improved; and the performance of the Redis cluster can be improved, and the reasonable utilization of the whole resource of the Redis cluster can be ensured.
Drawings
Fig. 1 is a schematic flow chart of a Redis single-instance protection processing method according to a first embodiment of the present invention;
fig. 2 is a functional module diagram of a Redis single-instance protection processing apparatus according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a computer device according to a third embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first" and "second" in the description and claims of the present application and the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
Example one
Fig. 1 is a flowchart illustrating a method for Redis single-instance protection processing according to a first embodiment of the present invention.
The Redis single-instance protection processing method can be applied to Redis clusters. The Redis single-instance protection processing method specifically comprises the following steps, the sequence of the steps in the flowchart can be changed according to different requirements, and certain steps can be omitted.
And S11, receiving an access request of the client to the Redis single instance through the access proxy.
In this embodiment, a plurality of access agents may be set in a Redis cluster, where the Redis cluster may include, but is not limited to: redis-sentinel mode, Redis-sentinel + Twymproxy cluster mode, Redis-cluster mode. Redis clusters, regardless of the mode, include Redis single instances. The Redis single instance can be a master node or a slave node, and the master node and the slave node can be switched with each other. The Redis cluster is prior art and the invention is not described in detail here.
After a plurality of access agents are arranged in the Redis cluster, an access request of a client to a Redis single instance can be received through the access agents. The access request may be a read data request, a write data request, or other request. The invention is not to be considered here.
And S12, calculating the request error rate on the Redis single instance in the current period.
In this embodiment, the request error rate refers to a rate of access request errors on the Redis single instance. In each period, the request error rate on each Redis single instance needs to be calculated, so that whether the access request is differentially processed according to the level of the access request is determined according to the request error rate, and the protection effect on the Redis single instance is realized.
In an optional embodiment, the calculating a request error rate on the Redis single instance in the current cycle includes:
the calculating the request error rate on the Redis single instance in the current period comprises:
calculating a first number of access requests on the Redis single instance in a current period;
calculating a second number of access request errors on the Redis single instance within the current period;
and calculating the request error rate in the current period according to the first quantity and the second quantity.
In this optional embodiment, the request error rate in a cycle is determined by calculating the number of requests for accessing the Redis single instance and the number of request errors on the Redis single instance in the cycle. The larger the request error rate is, the larger the service pressure on the Redis single instance in the period is, the larger the error probability is, so that the access request needs to be selectively processed according to the level of the access request, so as to protect the Redis single instance and avoid the overload of the Redis single instance. The smaller the request error rate is, the smaller the service pressure on the Redis single instance in the period is, the smaller the error probability is, and thus the access request does not need to be selectively processed, so that the Redis single instance can normally process the access request.
The normally processing the access request may be that the access proxy forwards the access request to the Redis single instance, and then the Redis single instance processes the access request according to a normal service logic or a normal processing logic.
In an optional embodiment, the calculating the second number of access request errors on the Redis single instance in the current cycle includes:
acquiring connection time of the access request on the Redis single instance in the current period, calculating the number of target connection time which is greater than or equal to a preset connection time threshold value, and determining the number of the target connection time as the second number; or
Acquiring the response time of the access request on the Redis single instance in the current period, calculating the number of target response times which are greater than or equal to a preset response time threshold value, and determining that the number of the target response times is the second number.
In this optional embodiment, when the connection time of the access request on the Redis single instance is greater than or equal to a preset connection time threshold, it indicates that the connection of the access request is overtime; and when the connection time of the access request on the Redis single instance is smaller than a preset connection time threshold, indicating that the connection of the access request is normal. When the response time of the access request on the Redis single instance is greater than or equal to a preset response time threshold, indicating that the response of the access request is overtime; and when the response time of the access request on the Redis single instance is smaller than a preset response time threshold, indicating that the response of the access request is normal.
And considering the access request corresponding to the connection timeout and/or the response timeout as the access request is wrong, and calculating the number of the access requests with the mistakes, namely determining the number of the access request mistakes on the Redis single instance in one period.
And S13, judging whether the request error rate in the current period is greater than the error rate threshold value in the current period.
In this embodiment, the error rate threshold may be a fixed value set in advance. The error rate threshold may be set by a system administrator or an operation maintenance person based on experience and actual business requirements. The same error rate threshold may be set for each cycle, or different error rate thresholds may be set for different cycles. If the same error rate threshold is set for each cycle, the error rate thresholds of the previous cycle, the current cycle and the next cycle are the same. If different error rate thresholds are set for different periods, the error rate thresholds of the previous period, the current period and the next period are different.
S14, responding to the request error rate in the current period being greater than or equal to the error rate threshold in the current period, and performing differentiation processing on the access request according to the level of the access request to protect the Redis single instance.
In this embodiment, when the access request error rate is greater than the error rate threshold, it indicates that the load pressure on the Redis single instance in the period is large, and the Redis single instance needs to be protected to reduce the load pressure on the Redis single instance. If the Redis single instance is not protected, the load pressure on the Redis single instance is increased, and the service quality of the Redis single instance on the access request is affected finally. For example, connection timeouts, response timeouts, or service instability, response data errors, etc. may occur.
In an optional embodiment, the performing differentiation processing on the access request according to the level of the access request includes:
obtaining the request type of the access request through the access agent;
identifying a priority of the access request according to the request type;
and sending an access request corresponding to the priority higher than a preset priority threshold to the Redis single instance, and refusing to receive the access request corresponding to the priority lower than the preset priority threshold.
In this alternative embodiment, different priorities may be set in advance for access requests of different request types. When the access agent receives an access request to the Redis single instance, the request type of the access request can be obtained, and the priority of the access request is determined according to the request type.
Illustratively, if the request type of the access request is an a type, it is determined that the priority of the access request is higher, and priority processing is required, and the access proxy forwards the access request to the Redis single instance. And if the request type of the access request is the type D, determining that the priority of the access request is lower, and directly refusing to receive the access request by the access agent. And after the access agent refuses to receive the access request, the access request is not transmitted to the Redis single instance.
By adopting different processing measures for the access requests according to the priorities of the access requests, when the load pressure of the Redis single instance is higher, the access requests with higher priorities are processed preferentially, and the access requests with lower priorities are rejected, so that the access requests needing emergency processing can be responded in time, and the load pressure of the Redis single instance can be prevented from being further increased.
In an optional embodiment, the performing differentiated processing on the access request according to the level of the access request includes:
acquiring a feature code carried in the access request through the access agent;
identifying the service level of the access request according to the feature code;
and sending an access request corresponding to the service level higher than the preset level threshold value to the Redis single instance, and refusing to receive the access request corresponding to the service level lower than the preset level threshold value.
In this optional embodiment, the Redis is stored in the form of a Key-Value Key Value pair, where the Key stores the feature code of the access request. The feature code may be a domain name, a client identification number, an IP address, etc. The access requests sent by different clients have different feature codes. Different service levels may be set in advance for access requests of different feature codes. When the access agent receives an access request to the Redis single instance, the access agent can acquire a feature code of the access request and determine the service level of the access request according to the feature code.
Illustratively, if the feature code of the access request is the first domain name, it is determined that the service level of the access request is the VIP level, and priority processing is required, the access proxy forwards the access request to the Redis single instance. And if the feature code of the access request is the second domain name, determining that the service level of the access request is a common level, and directly refusing to receive the access request by an access agent. And after the access agent refuses to receive the access request, the access request is not transmitted to the Redis single instance.
By adopting different processing measures for the access requests according to the service levels of the access requests, when the load pressure of the Redis single instance is higher, the access requests with higher service levels are processed preferentially, the access requests with lower service levels are refused, the access requests with the VIP levels can be responded in time, and the load pressure of the Redis single instance can be prevented from being further increased.
In an optional embodiment, the method further comprises:
calculating a request error rate on the Redis single instance in a next period;
judging whether the request error rate in the next period is smaller than the error rate threshold value in the next period;
and in response to the request error rate in the next period being less than or equal to the error rate threshold in the next period, performing normal processing on the access request to recover normal service of the Redis single instance.
In this optional embodiment, by performing priority processing or rejecting reception on the access request in the current cycle, the access pressure of the Redis single instance in the current cycle can be effectively relieved. And judging whether the access pressure of the Redis single instance in the next period is recovered to be normal or not by calculating the request error rate in the next period. And when the access pressure of the Redis single instance is not recovered to be normal in the next period, continuously carrying out differentiation processing on the access request according to the level of the access request, thereby continuously protecting the Redis single instance. And when the access pressure of the Redis single instance is recovered to be normal in the next period, normally processing the access request on the Redis single instance, thereby recovering the normal service of the Redis single instance.
In an optional embodiment, the method further comprises:
acquiring the CPU utilization rate of the Redis single instance in the current period;
judging whether the CPU utilization rate is greater than a preset utilization rate threshold value or not;
in response to the CPU utilization being greater than or equal to the preset utilization threshold, increasing an error rate threshold in the next cycle;
and in response to the CPU utilization rate being lower than the preset utilization rate threshold, reducing the error rate threshold in the next period.
In this optional embodiment, the error rate threshold in the next cycle may be dynamically adjusted according to the CPU utilization of the Redis single instance in the current cycle.
If the CPU utilization rate of the Redis single instance in the current period is greater than or equal to the preset utilization rate threshold, the error rate threshold in the current period is set too low, and most of the access requests are forwarded to the Redis single instance by the access proxy. The excessive number of access requests on the Redis single instance leads to the excessive CPU utilization rate of the Redis single instance, so that the error rate threshold value needs to be increased in the next cycle. By increasing the error rate threshold in the next period, most of the access requests are rejected by the access agent, the load pressure of the Redis single instance in the next period is prevented from being further increased, and the high load state of the Redis single instance in the next period is relieved.
If the CPU utilization rate of the Redis single instance in the current period is smaller than the preset utilization rate threshold, the error rate threshold setting in the current period is over high, and most access requests are directly rejected by the access agent and are not forwarded to the Redis single instance. Although the number of access requests of the Redis single instance is not large and the load pressure is not large, the CPU utilization rate of the Redis single instance is not fully utilized, the service rate is not high, and therefore the error rate threshold value needs to be reduced in the next period. By reducing the error rate threshold in the next period, the access agent forwards more access requests to the Redis single instance, so that the number of the access requests on the Redis single instance is increased, and CPU resources or other resources and the like are fully utilized.
In the method for processing Redis single-instance protection according to this embodiment, an access request of a client to a Redis single instance is received by using an access proxy as an intermediary, so that direct connection between the client and the Redis single instance is avoided; when the error rate of the request on the Redis single instance is calculated to be larger than the error rate threshold value in the current period, the access request is subjected to differentiation processing according to the level of the access request, so that the overload of the Redis single instance can be avoided, and the protection of the Redis single instance is realized; in addition, the load of the Redis single instance is reduced, the service quality of the Redis single instance to the access request can be improved, and the stability of the Redis cluster is improved; and the performance of the Redis cluster can be improved, and the reasonable utilization of the whole resource of the Redis cluster can be ensured.
Example two
Fig. 2 is a schematic diagram of functional modules of a Redis single-instance protection processing device according to a second embodiment of the present invention.
In some embodiments, the Redis single-instance protection processing apparatus 20 is run in a computer device. The Redis single-instance protection processing apparatus 20 may include a plurality of functional modules composed of program code segments. The program code of each program segment in the Redis single-instance protection processing apparatus 20 may be stored in a memory of a computer device and executed by at least one processor to perform (see fig. 1 for details) processing a request for accessing a Redis single instance.
In this embodiment, the Redis single-instance protection processing device 20 may be divided into a plurality of functional modules according to the functions executed by the device. The functional module may include: the device comprises a receiving module 201, a calculating module 202, a judging module 203, a processing module 204, an obtaining module 205 and an adjusting module 206. The module referred to herein is a series of computer program segments capable of being executed by at least one processor and capable of performing a fixed function and is stored in memory. In the present embodiment, the functions of the modules will be described in detail in the following embodiments.
The receiving module 201 is configured to receive an access request of a client to a Redis single instance through an access proxy.
In this embodiment, a plurality of access agents may be set in a Redis cluster, where the Redis cluster may include, but is not limited to: redis-sentinel mode, Redis-sentinel + Twymproxy cluster mode, Redis-cluster mode. Redis clusters, regardless of the mode, include Redis single instances. The Redis single instance can be a master node or a slave node, and the master node and the slave node can be switched with each other. The Redis cluster is prior art and the invention is not described in detail here.
After a plurality of access agents are arranged in the Redis cluster, an access request of a client to a Redis single instance can be received through the access agents. The access request may be a read data request, a write data request, or other request. The invention is not to be considered here.
The calculating module 202 is configured to calculate a request error rate on the Redis single instance in the current period.
In this embodiment, the request error rate refers to a rate of access request errors on the Redis single instance. In each period, the request error rate on each Redis single instance needs to be calculated, so that whether the access request is differentially processed according to the level of the access request is determined according to the request error rate, and the protection effect on the Redis single instance is realized.
In an optional embodiment, the calculating module 202 calculates the request error rate on the Redis single instance in the current cycle includes:
the calculating the request error rate on the Redis single instance in the current period comprises:
calculating a first number of access requests on the Redis single instance in a current period;
calculating a second number of access request errors on the Redis single instance within the current period;
and calculating the request error rate in the current period according to the first quantity and the second quantity.
In this optional embodiment, the request error rate in a cycle is determined by calculating the number of requests for accessing the Redis single instance and the number of request errors on the Redis single instance in the cycle. The larger the request error rate is, the larger the service pressure on the Redis single instance in the period is, the larger the error probability is, so that the access request needs to be selectively processed according to the level of the access request, so as to protect the Redis single instance and avoid the overload of the Redis single instance. The smaller the request error rate is, the smaller the service pressure on the Redis single instance in the period is, the smaller the error probability is, and thus the access request does not need to be selectively processed, so that the Redis single instance can normally process the access request.
The normally processing the access request may be that the access proxy forwards the access request to the Redis single instance, and then the Redis single instance processes the access request according to a normal service logic or a normal processing logic.
In an optional embodiment, the calculating module 202 calculates a second number of access request errors on the Redis single instance in the current cycle includes:
acquiring connection time of the access request on the Redis single instance in the current period, calculating the number of target connection time which is greater than or equal to a preset connection time threshold value, and determining the number of the target connection time as the second number; or
Acquiring the response time of the access request on the Redis single instance in the current period, calculating the number of target response times which are greater than or equal to a preset response time threshold value, and determining that the number of the target response times is the second number.
In this optional embodiment, when the connection time of the access request on the Redis single instance is greater than or equal to a preset connection time threshold, it indicates that the connection of the access request is overtime; and when the connection time of the access request on the Redis single instance is smaller than a preset connection time threshold, indicating that the connection of the access request is normal. When the response time of the access request on the Redis single instance is greater than or equal to a preset response time threshold, indicating that the response of the access request is overtime; and when the response time of the access request on the Redis single instance is smaller than a preset response time threshold, indicating that the response of the access request is normal.
And considering the access request corresponding to the connection timeout and/or the response timeout as the access request is wrong, and calculating the number of the access requests with the mistakes, namely determining the number of the access request mistakes on the Redis single instance in one period.
The determining module 203 is configured to determine whether the request error rate in the current period is greater than an error rate threshold in the current period.
In this embodiment, the error rate threshold may be a fixed value set in advance. The error rate threshold may be set by a system administrator or an operation maintenance person based on experience and actual business requirements. The same error rate threshold may be set for each cycle, or different error rate thresholds may be set for different cycles. If the same error rate threshold is set for each cycle, the error rate thresholds of the previous cycle, the current cycle and the next cycle are the same. If different error rate thresholds are set for different periods, the error rate thresholds of the previous period, the current period and the next period are different.
The processing module 204 is configured to, in response to that the request error rate in the current period is greater than or equal to the error rate threshold in the current period, perform differentiated processing on the access request according to the level of the access request to protect the Redis single instance.
In this embodiment, when the access request error rate is greater than the error rate threshold, it indicates that the load pressure on the Redis single instance in the period is large, and the Redis single instance needs to be protected to reduce the load pressure on the Redis single instance. If the Redis single instance is not subjected to protection processing, the load pressure on the Redis single instance is increased, and the service quality of the Redis single instance on an access request is affected finally. For example, connection timeouts, response timeouts, or service instability, response data errors, etc. may occur.
In an optional embodiment, the processing module 204 performs differential processing on the access request according to the level of the access request, including:
obtaining the request type of the access request through the access agent;
identifying a priority of the access request according to the request type;
and sending an access request corresponding to the priority higher than a preset priority threshold to the Redis single instance, and refusing to receive the access request corresponding to the priority lower than the preset priority threshold.
In this alternative embodiment, different priorities may be set in advance for access requests of different request types. When the access agent receives an access request to the Redis single instance, the request type of the access request can be obtained, and the priority of the access request is determined according to the request type.
Illustratively, if the request type of the access request is an a type, it is determined that the priority of the access request is higher, and priority processing is required, and the access proxy forwards the access request to the Redis single instance. And if the request type of the access request is the type D, determining that the priority of the access request is lower, and directly refusing to receive the access request by the access agent. And after the access agent refuses to receive the access request, the access request is not transmitted to the Redis single instance.
By adopting different processing measures for the access requests according to the priorities of the access requests, when the load pressure of the Redis single instance is higher, the access requests with higher priorities are processed preferentially, and the access requests with lower priorities are rejected, so that the access requests needing emergency processing can be responded in time, and the load pressure of the Redis single instance can be prevented from being further increased.
In an optional embodiment, the processing module 204 performs differentiated processing on the access request according to the level of the access request, including:
acquiring a feature code carried in the access request through the access agent;
identifying the service level of the access request according to the feature code;
and sending an access request corresponding to the service level higher than the preset level threshold value to the Redis single instance, and refusing to receive the access request corresponding to the service level lower than the preset level threshold value.
In this optional embodiment, the Redis is stored in the form of a Key-Value Key Value pair, where the Key stores the feature code of the access request. The feature code may be a domain name, a client identification number, an IP address, etc. The access requests sent by different clients are different in feature code. Different service levels may be set in advance for access requests of different feature codes. When the access agent receives an access request to the Redis single instance, the access agent can acquire a feature code of the access request and determine the service level of the access request according to the feature code.
Illustratively, if the feature code of the access request is the first domain name, it is determined that the service level of the access request is the VIP level, and priority processing is required, the access proxy forwards the access request to the Redis single instance. And if the feature code of the access request is the second domain name, determining that the service level of the access request is a common level, and directly refusing to receive the access request by an access agent. And after the access agent refuses to receive the access request, the access request is not transmitted to the Redis single instance.
By adopting different processing measures for the access request according to the service level of the access request, when the load pressure of the Redis single instance is higher, the access request with higher service level is processed preferentially, the access request with lower service level is rejected, the access request with a VIP level can be responded in time, and the load pressure of the Redis single instance can be prevented from being further increased.
In an optional embodiment, the calculating module 202 is further configured to calculate a request error rate on the Redis single instance in a next cycle.
The determining module 203 is further configured to determine whether the request error rate in the next period is smaller than an error rate threshold in the next period.
The processing module 204 is configured to, in response to that the request error rate in the next cycle is less than or equal to the error rate threshold in the next cycle, perform normal processing on the access request to recover normal service of the Redis single instance.
In this optional embodiment, by performing priority processing or rejecting reception on the access request in the current cycle, the access pressure of the Redis single instance in the current cycle can be effectively relieved. And judging whether the access pressure of the Redis single instance in the next period is recovered to be normal or not by calculating the request error rate in the next period. And when the access pressure of the Redis single instance is not recovered to be normal in the next period, continuously carrying out differentiation processing on the access request according to the level of the access request, thereby continuously protecting the Redis single instance. And when the access pressure of the Redis single instance is recovered to be normal in the next period, normally processing the access request on the Redis single instance, thereby recovering the normal service of the Redis single instance.
The obtaining module 205 is configured to obtain a CPU utilization of the Redis single instance in the current period.
The judging module 203 is configured to judge whether the CPU utilization is greater than a preset utilization threshold.
The adjusting module 206 is configured to increase the error rate threshold in the next period in response to the CPU utilization being greater than or equal to the preset utilization threshold.
The adjusting module 206 is further configured to reduce the error rate threshold in the next period in response to the CPU utilization being lower than the preset utilization threshold.
In this optional embodiment, the error rate threshold in the next cycle may be dynamically adjusted according to the CPU utilization of the Redis single instance in the current cycle.
If the CPU utilization rate of the Redis single instance in the current period is greater than or equal to the preset utilization rate threshold value, it indicates that the error rate threshold value in the current period is set too low, and most access requests are forwarded to the Redis single instance by the access proxy. The excessive number of access requests on the Redis single instance leads to the excessive CPU utilization rate of the Redis single instance, so that the error rate threshold value needs to be increased in the next cycle. By increasing the error rate threshold in the next period, most of the access requests are rejected by the access agent, the load pressure of the Redis single instance in the next period is prevented from being further increased, and the high load state of the Redis single instance in the next period is relieved.
If the CPU utilization rate of the Redis single instance in the current period is smaller than the preset utilization rate threshold, the error rate threshold setting in the current period is over high, and most access requests are directly rejected by the access agent and are not forwarded to the Redis single instance. Although the number of access requests of the Redis single instance is not large and the load pressure is not large, the CPU utilization rate of the Redis single instance is not fully utilized, the service rate is not high, and therefore the error rate threshold value needs to be reduced in the next period. By reducing the error rate threshold in the next period, the access agent forwards more access requests to the Redis single instance, so that the number of the access requests on the Redis single instance is increased, and CPU resources or other resources and the like are fully utilized.
The Redis single-instance protection processing apparatus described in this embodiment receives an access request of a client to a Redis single instance by using an access proxy as an intermediary, so as to avoid direct connection between the client and the Redis single instance; when the error rate of the request on the Redis single instance is calculated to be larger than the error rate threshold value in the current period, the access request is subjected to differentiation processing according to the level of the access request, so that the overload of the Redis single instance can be avoided, and the protection of the Redis single instance is realized; in addition, the load of the Redis single instance is reduced, the service quality of the Redis single instance to the access request can be improved, and the stability of the Redis cluster is improved; and the performance of the Redis cluster can be improved, and the reasonable utilization of the whole resource of the Redis cluster can be ensured.
EXAMPLE III
Fig. 3 is a schematic diagram of an internal structure of a computer device according to an embodiment of the disclosure.
In this embodiment, the computer device 3 may include a memory 31, a processor 32, a bus 33, and a transceiver 34.
The memory 31 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like. The memory 31 may in some embodiments be an internal storage unit of the computer device 3, for example a hard disk of the computer device 3. The memory 31 may also be an external storage device of the computer device 3 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the computer device 3. Further, the memory 31 may also include both an internal storage unit of the computer device 3 and an external storage device. The memory 31 may be used not only to store the application programs and various types of data installed in the computer apparatus 3, such as the code of the Redis single-instance protection processing device 20 and the respective modules, but also to temporarily store data that has been output or is to be output.
Processor 32 may be, in some embodiments, a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data Processing chip for executing program codes stored in memory 31 or Processing data.
The bus 33 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 3, but this does not mean only one bus or one type of bus.
Further, the computer device 3 may further include a network interface, which may optionally include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), and is generally used to establish a communication connection between the computer device 3 and other computer devices.
Optionally, the computer device 3 may further comprise a user interface, which may comprise a Display (Display), an input unit, such as a Keyboard (Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an Organic Light-Emitting Diode (OLED) touch screen, or the like. The display, which may also be referred to as a display screen or display unit, is used for displaying messages processed in the computer device and for displaying a visualized user interface.
Fig. 3 only shows the computer device 3 with components 31-34, it being understood by a person skilled in the art that the structure shown in fig. 3 does not constitute a limitation of the computer device 3, it may be a bus-type structure or a star-shaped structure, the computer device 3 may also comprise fewer or more components than shown in the figure, or some components may be combined, or a different arrangement of components. Other electronic products, now existing or hereafter developed, that may be adapted to the present invention, are also included within the scope of the present invention and are hereby incorporated by reference.
In the above embodiments, all or part may be implemented by an application program, hardware, firmware, or any combination thereof. When implemented using an application program, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of an application program functional unit.
The integrated unit, if implemented in the form of an application functional unit and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in the form of a computer application program product, stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
It should be noted that the above-mentioned numbers of the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention, and all equivalent structures or equivalent processes performed by the present invention or directly or indirectly applied to other related technical fields are also included in the scope of the present invention.

Claims (8)

1. A Redis single-instance protection processing method is applied to a Redis cluster, and is characterized by comprising the following steps:
receiving an access request of a client to a Redis single instance through an access proxy;
calculating a request error rate on the Redis single instance in the current period;
judging whether the request error rate in the current period is greater than the error rate threshold value in the current period;
responding to the request error rate in the current period being greater than or equal to the error rate threshold in the current period, and performing differentiation processing on the access request according to the level of the access request to protect the Redis single instance;
the differentiating the access request according to the level of the access request comprises:
acquiring the request type of the access request or the feature code carried in the access request through the access agent;
identifying the priority of the access request according to the request type or identifying the service level of the access request according to the feature code;
sending an access request corresponding to a priority higher than a preset priority threshold or a service level higher than a preset level threshold to the Redis single instance, and refusing to receive the access request corresponding to the priority lower than the preset priority threshold or the service level lower than the preset level threshold.
2. The Redis single-instance protection processing method of claim 1, wherein the calculating the request error rate on the Redis single-instance within the current cycle comprises:
calculating a first number of access requests on the Redis single instance in a current period;
calculating a second number of access request errors on the Redis single instance within the current period;
and calculating the request error rate in the current period according to the first quantity and the second quantity.
3. The Redis single-instance protection processing method of claim 2, wherein the calculating the second number of access request errors on the Redis single-instance within the current cycle comprises:
acquiring connection time of the access request on the Redis single instance in the current period, calculating the number of target connection time which is greater than or equal to a preset connection time threshold value, and determining the number of the target connection time as the second number; or
Acquiring the response time of the access request on the Redis single instance in the current period, calculating the number of target response times which are greater than or equal to a preset response time threshold value, and determining that the number of the target response times is the second number.
4. A Redis single-instance protection processing method according to any of claims 1 to 3, wherein the method further comprises:
calculating a request error rate on the Redis single instance in a next period;
judging whether the request error rate in the next period is smaller than an error rate threshold value in the next period;
and in response to the request error rate in the next period being less than or equal to the error rate threshold in the next period, performing normal processing on the access request to recover normal service of the Redis single instance.
5. A Redis single-instance protection processing method according to any of claims 1 to 3, wherein the method further comprises:
acquiring the CPU utilization rate of the Redis single instance in the current period;
judging whether the CPU utilization rate is greater than a preset utilization rate threshold value or not;
responding to the CPU utilization rate being larger than or equal to the preset utilization rate threshold value, and increasing an error rate threshold value in the next period;
and in response to the CPU utilization rate being lower than the preset utilization rate threshold, reducing the error rate threshold in the next period.
6. A Redis single-instance protection processing apparatus, operating in a Redis cluster, the apparatus comprising:
the receiving module is used for receiving an access request of a client to the Redis single instance through an access agent;
the calculation module is used for calculating the request error rate on the Redis single instance in the current period;
the judging module is used for judging whether the request error rate in the current period is greater than the error rate threshold value in the current period;
the processing module is used for responding to the condition that the request error rate in the current period is larger than or equal to the error rate threshold value in the current period, and carrying out differentiated processing on the access request according to the level of the access request so as to protect the Redis single instance;
the processing module performs differentiated processing on the access request according to the level of the access request, and the differentiated processing comprises the following steps:
obtaining the request type of the access request or the feature code carried in the access request through the access agent;
identifying the priority of the access request according to the request type or identifying the service level of the access request according to the feature code;
sending an access request corresponding to a priority higher than a preset priority threshold or a service level higher than a preset level threshold to the Redis single instance, and refusing to receive the access request corresponding to the priority lower than the preset priority threshold or the service level lower than the preset level threshold.
7. A computer device comprising a memory and a processor, the memory having stored thereon a downloaded program of a Redis single-instance protection processing method executable on the processor, the downloaded program of the Redis single-instance protection processing method when executed by the processor implementing the Redis single-instance protection processing method as claimed in any one of claims 1 to 5.
8. A computer-readable storage medium, having stored thereon a downloaded program of a Redis single-instance protection handling method, the downloaded program of the Redis single-instance protection handling method being executable by one or more processors to implement the Redis single-instance protection handling method as claimed in any one of claims 1 to 5.
CN201911243569.XA 2019-12-06 2019-12-06 Redis single instance protection processing method and device, computer equipment and storage medium Active CN110971697B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911243569.XA CN110971697B (en) 2019-12-06 2019-12-06 Redis single instance protection processing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911243569.XA CN110971697B (en) 2019-12-06 2019-12-06 Redis single instance protection processing method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110971697A CN110971697A (en) 2020-04-07
CN110971697B true CN110971697B (en) 2022-08-16

Family

ID=70033265

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911243569.XA Active CN110971697B (en) 2019-12-06 2019-12-06 Redis single instance protection processing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110971697B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111666194B (en) * 2020-05-21 2022-02-08 平安科技(深圳)有限公司 Pressurization parameter self-adaptive adjusting method and device, computer equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107948250A (en) * 2017-11-02 2018-04-20 努比亚技术有限公司 A kind of method of adjustment and equipment of user's visit capacity
CN109257294A (en) * 2018-09-07 2019-01-22 武汉斗鱼网络科技有限公司 Service dynamic down method, device, server and storage medium based on redis
CN110120973A (en) * 2019-04-28 2019-08-13 华为技术有限公司 A kind of request control method, relevant device and computer storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9740547B2 (en) * 2015-01-30 2017-08-22 International Business Machines Corporation Storing data using a dual path storage approach
US9686124B2 (en) * 2015-09-22 2017-06-20 Veniam, Inc. Systems and methods for managing a network of moving things
US10200945B2 (en) * 2016-04-22 2019-02-05 Veniam, Inc. Systems and methods for managing mobility of users in a network of moving things at the edge
CN105915621A (en) * 2016-05-11 2016-08-31 深圳市永兴元科技有限公司 Data access method and pretreatment server
US10171967B2 (en) * 2017-04-26 2019-01-01 Veniam, Inc. Fast discovery, service-driven, and context-based connectivity for networks of autonomous vehicles
CN107688607A (en) * 2017-07-26 2018-02-13 努比亚技术有限公司 The method and mobile terminal of a kind of database access, computer-readable recording medium
CN108491450B (en) * 2018-02-26 2021-09-21 平安普惠企业管理有限公司 Data caching method, device, server and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107948250A (en) * 2017-11-02 2018-04-20 努比亚技术有限公司 A kind of method of adjustment and equipment of user's visit capacity
CN109257294A (en) * 2018-09-07 2019-01-22 武汉斗鱼网络科技有限公司 Service dynamic down method, device, server and storage medium based on redis
CN110120973A (en) * 2019-04-28 2019-08-13 华为技术有限公司 A kind of request control method, relevant device and computer storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向崩溃预测的寄存器软错误故障传播分析;薛利兴等;《计算机工程与应用》;20171015(第20期);全文 *

Also Published As

Publication number Publication date
CN110971697A (en) 2020-04-07

Similar Documents

Publication Publication Date Title
US8949566B2 (en) Locking access to data storage shared by a plurality of compute nodes
CN112650576B (en) Resource scheduling method, device, equipment, storage medium and computer program product
CN109960575B (en) Computing capacity sharing method, system and related equipment
CN111131505A (en) Data transmission method, equipment, system, device and medium based on P2P network
CN108833205B (en) Information processing method, information processing device, electronic equipment and storage medium
CN115277566B (en) Load balancing method and device for data access, computer equipment and medium
CN110995539A (en) Business system monitoring method and device and computer equipment
CN109309735B (en) Connection processing method, server, system and storage medium
CN110708366A (en) Plug-in process management method, related method and related device
CN109597798A (en) Network file delet method, device, computer equipment and storage medium
CN108028806B (en) Method and device for allocating virtual resources in Network Function Virtualization (NFV) network
CN110958250B (en) Port monitoring method and device and electronic equipment
CN110971697B (en) Redis single instance protection processing method and device, computer equipment and storage medium
CN113791867B (en) Method and application for adjusting KVM virtual machine service process priority
CN105373393A (en) Method for realizing hot plug of equipment in OS in non-event driven mode
US20150156132A1 (en) Determining Available User Interface Functionality Based on Backend Server Load
CN112770275A (en) Message pushing method, system and related equipment
CN116880990A (en) Task execution method, device, electronic equipment and computer readable storage medium
CN109194703B (en) Processing method of communication load between cloud platform hosts, electronic device and medium
CN109165135B (en) Data management method, computer readable storage medium and terminal equipment
CN111431764B (en) Node determining method, device, system and medium
CN114257632B (en) Method and device for reconnecting broken wire, electronic equipment and readable storage medium
JP2020038506A (en) Information processing system, information processing method, and program
CN110535977B (en) File distribution method and device, computer device and storage medium
CN109614242B (en) Computing capacity sharing method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant