CN113127557B - Data persistence method and device based on redis performance and electronic equipment - Google Patents

Data persistence method and device based on redis performance and electronic equipment Download PDF

Info

Publication number
CN113127557B
CN113127557B CN201911412031.7A CN201911412031A CN113127557B CN 113127557 B CN113127557 B CN 113127557B CN 201911412031 A CN201911412031 A CN 201911412031A CN 113127557 B CN113127557 B CN 113127557B
Authority
CN
China
Prior art keywords
master
consumption value
slave group
system resource
group
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
CN201911412031.7A
Other languages
Chinese (zh)
Other versions
CN113127557A (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.)
China Mobile Communications Group Co Ltd
China Mobile Group Sichuan Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Group Sichuan 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 China Mobile Communications Group Co Ltd, China Mobile Group Sichuan Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN201911412031.7A priority Critical patent/CN113127557B/en
Publication of CN113127557A publication Critical patent/CN113127557A/en
Application granted granted Critical
Publication of CN113127557B publication Critical patent/CN113127557B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Abstract

The invention discloses a data persistence method and device based on redis performance and electronic equipment, wherein the method comprises the following steps: calculating system resource consumption values of a master group and a slave group in a redis cluster, wherein nodes with the same epoch in the redis cluster are one master group and one slave group; determining a master-slave group with the minimum system resource consumption value according to the system resource consumption values of the master-slave group; and under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold value, performing data persistence processing on nodes meeting preset conditions in the master-slave group. The embodiment of the invention judges whether the nodes in the master-slave group meet the condition of starting persistence or not by calculating the system resource consumption value of each master-slave group in the redis cluster, and when the use condition of the node resources meets the requirement, the node persistence is started, otherwise, the node persistence is closed, thereby avoiding the influence of the persistence under the high concurrency environment on the redis performance.

Description

Data persistence method and device based on redis performance and electronic equipment
Technical Field
The present invention relates to the field of data processing, and in particular, to a data persistence method and apparatus based on redis performance, and an electronic device.
Background
A Remote Dictionary Server (Remote Dictionary Server) is an open source, is written in ANSI C language, supports network, can be based on memory and can also be a persistent log-type, key-Value database, and provides API (Application Programming Interface) of multiple languages.
In the prior art, the redis supports two persistence methods, which are aof (Only add File) persistence and rdb (Relational Database) persistence, aof persistence writes the operation log of the redis into a File in an add mode, and rdb persistence backs the Database record of the redis in the memory to the disk at regular time. However, whether aof persistence or rdb persistence is adopted, long-term opening affects performance of redis-cluster, and especially, opening persistence in a redis-cluster with high concurrency and high performance requirements may cause blocking of user processes and seriously affect performance.
Disclosure of Invention
The embodiment of the invention provides a data persistence method and device based on redis performance and electronic equipment, which can solve the problem of how to minimize the influence on the performance when a high-concurrency high-performance cluster is subjected to data persistence.
In order to solve the technical problem, the invention is realized as follows:
in a first aspect, a data persistence method based on redis performance is provided, where the method includes:
calculating system resource consumption values of a master group and a slave group in a redis cluster, wherein nodes with the same epoch in the redis cluster are one master group and one slave group;
determining a master-slave group with the minimum system resource consumption value according to the system resource consumption values of the master-slave group;
and under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold value, performing data persistence processing on nodes meeting preset conditions in the master-slave group.
In a second aspect, a data persistence apparatus based on a redis performance is provided, the apparatus including:
the computing module is used for computing system resource consumption values of a master group and a slave group in the redis cluster, wherein nodes with the same epoch in the redis cluster are the master group and the slave group;
the determining module is used for determining the master-slave group with the minimum system resource consumption value according to the system resource consumption values of the master-slave group;
and the execution module is used for performing data persistence processing on the nodes meeting the preset conditions in the master-slave group under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold value.
In a third aspect, an electronic device is provided, including: memory, a processor and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the method according to the first aspect.
In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, realizes the steps of the method according to the first aspect.
In the embodiment of the invention, the system resource consumption value of the master group and the slave group in the redis cluster is calculated, the master group and the slave group with the minimum system resource consumption value are determined according to the system resource consumption value, and finally, under the condition that the system resource consumption value of the master group and the slave group with the minimum system resource consumption value is smaller than the first threshold value, data persistence processing is carried out on the nodes meeting the preset conditions in the master group and the slave group. The embodiment of the invention judges whether the nodes in the master-slave group meet the condition of starting persistence or not by calculating the system resource consumption value of each master-slave group in the redis cluster, and when the use condition of the node resources meets the requirement, the node persistence is started, otherwise, the node persistence is closed, thereby avoiding the influence of the persistence under the high concurrency environment on the redis performance.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a flow chart illustrating a data persistence method based on redis performance according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a data persistence apparatus based on redis performance according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present 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 embodiment of the invention provides a data persistence method and device based on redis performance and electronic equipment. In the embodiment of the invention, a judgment device is added at the front end of a redis cluster, each master node and a slave node corresponding to the master node are taken as a group, and the epochs (epochs) of each group of master-slave groups are the same; firstly, selecting a master-slave group with the minimum resource utilization from nodes with the same epoch through calculation, continuously judging whether cluster node conditions are met or not downwards when the conditions are met, starting persistence processing when the conditions are met, and finishing the judgment of the master-slave group and continuously judging a next master-slave group with the same epoch when any step is not met.
Redis is used as a memory database and mainly aims to provide efficient and rapid data access, and a Redis cluster mainly ensures high concurrency and high performance of access; the embodiment of the invention can flexibly and automatically adjust whether the current redis cluster is suitable for data persistence in the existing service scene, automatically turn on rdb persistence once the service resources are free, and automatically turn off persistence once the service is busy, thereby avoiding the influence of persistence on the redis performance when the persistence is high and complicated, and also avoiding data loss by persisting data in a reasonable time.
Fig. 1 is a flowchart of a data persistence method for redis performance according to an embodiment of the present invention. As shown, the data persistence method of the redis capability may include steps shown in step S101 to step S103.
In step S101, system resource consumption values of master and slave groups in the redis cluster are calculated.
And the nodes with the same epoch in the redis cluster are a master-slave group.
In the embodiment of the invention, the redis cluster is divided into a plurality of master-slave groups according to whether epochs are the same or not, and then the system resource consumption value of each master-slave group is calculated.
In step S102, a master-slave group with the minimum system resource consumption value is determined according to the system resource consumption values of the master-slave group.
In the embodiment of the invention, the master-slave group with the minimum system resource consumption value is selected according to the calculated system resource consumption values of the master-slave groups. So as to determine the master-slave set in the group with the most idle traffic resource.
In step S103, when the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than the first threshold, data persistence processing is performed on nodes satisfying a preset condition in the master-slave group.
According to the embodiment of the invention, the system resource consumption value of the master group and the slave group in the redis cluster is calculated, the master group and the slave group with the minimum system resource consumption value are determined according to the system resource consumption value, and finally, under the condition that the system resource consumption value of the master group and the slave group with the minimum system resource consumption value is smaller than the first threshold value, data persistence processing is carried out on the nodes meeting the preset conditions in the master group and the slave group. The embodiment of the invention judges whether the nodes in the master-slave group meet the condition of starting persistence or not by calculating the system resource consumption value of each master-slave group in the redis cluster, and when the use condition of the node resources meets the requirement, the node persistence is started, otherwise, the node persistence is closed, thereby avoiding the influence of the persistence under the high concurrency environment on the redis performance.
The embodiment of the invention aims to minimize the influence on the performance of a high-concurrency and high-performance cluster under the condition of data persistence, and does not influence the performance due to the data persistence when the traffic is high or the resource is in short use. Because aof persistence is to append data by time interval, and rdb persistence is to backup data all at a time, in order to randomly switch on or off the persistence status at irregular time, and in order to backup and restore data quickly, the embodiment of the present invention employs rdb persistence.
In a possible embodiment of the present invention, calculating a system resource consumption value of a master-slave group in a redis cluster includes:
calculating the system resource consumption value of a master group and a slave group in the redis cluster according to the following formula:
Figure BDA0002350229010000051
wherein f (m, c) is the system resource consumption value of the master-slave group; m is n The memory consumption value of the nth node in the master-slave group is obtained; c. C n Is the CPU consumption value of the nth node in the master-slave set.
In a possible embodiment of the present invention, before performing data persistence processing on nodes satisfying a preset condition in the master-slave group, the method may further include:
and judging whether the nodes in the master-slave group meet preset conditions or not.
The determining whether the nodes in the master-slave group satisfy the preset condition may include:
judging whether the memory consumption value of the nodes in the master-slave set is smaller than a second threshold value or not and whether the CPU consumption value of the nodes in the master-slave set is smaller than a third threshold value or not;
and if the memory consumption value of the nodes in the master-slave group is smaller than the second threshold value and the CPU consumption value of the nodes in the master-slave group is smaller than the third threshold value, judging that the nodes with the memory consumption value smaller than the second threshold value and the CPU consumption value smaller than the third threshold value meet the preset conditions.
In the embodiment of the present invention, if it is determined that the node in the master-slave group with the minimum system resource consumption value satisfies the preset condition, it indicates that the resource utilization rate of the node in the master-slave group is low and the service resource is idle, at this time, data persistence processing may be performed, and the performance of redis is not affected.
Specifically, the average value of the node memory consumption value and the node CPU consumption value of each node satisfying the preset condition may be further determined, and the node with the smallest average value is selected for persistence. And the node with the minimum average value of the node memory consumption value and the node CPU consumption value is subjected to persistence, so that the influence on the redis performance can be further reduced.
In a possible embodiment of the present invention, the method for persisting data based on redis performance may further include:
and if the system resource consumption value of the master-slave group with the minimum system resource consumption value is greater than or equal to the first threshold value, closing the data persistence processing.
That is, when it is determined that the system resource consumption value of the master-slave group with the minimum system resource consumption value in the redis cluster is greater than or equal to the first threshold, it indicates that the service resource is relatively busy, and at this time, the data persistence processing is not suitable for performing, and the data persistence processing is closed, so as to avoid affecting the performance of the redis.
In a possible embodiment of the present invention, the method for persisting data based on redis performance may further include:
and under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than the first threshold value, the nodes in the master-slave group can not meet the preset condition, and the data persistence processing is closed.
That is, under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than the first threshold, it is determined that all nodes in the master-slave group cannot meet the preset condition, which indicates that the service resource is busy, and at this time, the data persistence processing is not suitable for data persistence processing, and the data persistence processing is closed, so as to avoid affecting the performance of redis.
In a specific embodiment of the present invention, a redis cluster includes 3 hosts, 9 nodes in total, 3 master nodes, and 6 slave nodes, which form a master-slave architecture. Each host 1697 CPU has 64G memory, and each node allocates 10G of memory.
The distribution of the nodes in the redis cluster is shown in table 1.
TABLE 1
ip address Master node Slave node 1 Slave node 2
10.192.168.97 master1 master3_slave1 master2_slave2
10.192.168.98 master2 master1_slave1 master3_slave2
10.192.168.99 master3 master2_slave1 master1_slave2
The frequency configured for the cluster is calculated for every 10 minutes of collection, and then 100 ten thousand keys are imported, so that the total size is about 2G.
By monitoring the redis log, about 5 minutes or so, the master2_ slave2, master1_ slave2 and master3_ slave2 automatically turn on rdb persistence, the current f (m, c), cpu and memory usage are all more than 50%, and by continuously observing a period of time to detect the irregular insertion key in the period of time, the memory and cpu are both more than 50% in the period of time, and the rdb persistence is always turned on by default, and the three nodes perform rdb persistence in an irregular period.
The method comprises the steps of concurrently (10000 clients simultaneously access) reading keys for a redis cluster through a program, finding that the current f (m, c) <0.5 (wherein 0.5 is a first threshold), the memory <75% (wherein 75% is a second threshold), and the CPU >50% (wherein 50% is a third threshold) through monitoring, finding that the system resource consumption value of a master-slave group with the minimum system resource consumption value is smaller than the first threshold through log output, judging the memory consumption value and the CPU consumption value, wherein the CPU consumption value exceeds the third threshold, displaying that rdb persistence is unavailable, and then automatically closing the rdb persistence. When the CPU consumption value is judged to be less than the third threshold value, rdb persistence is started.
And (3) concurrently increasing the redis-cluster to 100000, discovering that f (m, c) >0.5, the memory <75% and the cpu >50% through monitoring, and discovering that the system resource consumption value of the master group and the slave group with the minimum system resource consumption value is smaller than a first threshold value through log output, wherein the fact that the rdb persistence is unavailable is displayed, and then the rdb persistence is automatically closed. Rdb persistence is turned on after subsequent determinations of f (m, c) <0.5, memory <75%, cpu < 50%.
In the embodiment of the invention, each group of nodes with the same epoch is a group of master-slave groups, the master-slave group with the minimum system resource consumption value in the master-slave group is selected firstly, under the condition that the resource use of the master-slave group meets the judgment condition, the node with the minimum resource use in each group of master-slave groups is selected, whether the resource use of the node meets the judgment condition is judged, if yes, the rdb persistence of the node is started, otherwise, the node is not started, and if the condition is met in the starting process, the node is started until the condition is not met.
The embodiment of the invention also provides a data persistence device based on the redis performance. As shown in fig. 2, a schematic diagram of a data persistence apparatus based on redis performance provided in an embodiment of the present invention. As shown, the apparatus comprises: a calculation module 201, a determination module 202 and an execution module 203.
The calculation module 201 is configured to calculate system resource consumption values for master and slave groups in a redis cluster. And the nodes with the same epoch in the redis cluster are a master-slave group.
The determining module 202 is configured to determine a master-slave set with the minimum system resource consumption value according to the system resource consumption values of the master-slave sets.
The execution module 203 is configured to perform data persistence processing on nodes satisfying a preset condition in the master-slave group when the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold.
In the embodiment of the present invention, a system resource consumption value of a master-slave group in a redis cluster is calculated by a calculating module 201, then a determining module 202 determines the master-slave group with the minimum system resource consumption value according to the system resource consumption value, and finally an executing module 203 performs data persistence processing on a node that meets a preset condition in the master-slave group when the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold. The embodiment of the invention judges whether the nodes in the master-slave group meet the condition of starting persistence or not by calculating the system resource consumption value of each master-slave group in the redis cluster, and when the use condition of the node resources meets the requirement, the node persistence is started, otherwise, the node persistence is closed, thereby avoiding the influence of the persistence under the high concurrency environment on the redis performance.
In one possible embodiment of the present invention, the calculation module 201 may be configured to:
calculating the system resource consumption value of a master-slave group in the redis cluster according to the following formula:
Figure BDA0002350229010000081
wherein f (m, c) is the system resource consumption value of the master-slave group; m is n The memory consumption value of the nth node in the master-slave group is obtained; c. C n Is the CPU consumption value of the nth node in the master-slave set.
In one possible embodiment of the present invention, the data persistence device based on the redis performance may further include: and a judging module.
The judging module is configured to judge whether the nodes in the master-slave group meet preset conditions.
In one possible embodiment of the present invention, the determining module may be configured to:
judging whether the memory consumption value of the nodes in the master-slave group is smaller than a second threshold value or not and whether the CPU consumption value of the nodes in the master-slave group is smaller than a third threshold value or not;
and if the memory consumption value of the nodes in the master-slave group is smaller than the second threshold value and the CPU consumption value of the nodes in the master-slave group is smaller than the third threshold value, judging that the nodes with the memory consumption value smaller than the second threshold value and the CPU consumption value smaller than the third threshold value meet the preset conditions.
In one possible embodiment of the present invention, the apparatus may further include: a first shutdown module.
The first closing module is configured to close the data persistence processing if the system resource consumption value of the master-slave group with the smallest system resource consumption value is greater than or equal to a first threshold.
In one possible embodiment of the present invention, the apparatus may further include: and a second shutdown module.
The second closing module is configured to close the data persistence processing if the nodes in the master-slave group do not satisfy the preset condition under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than the first threshold value.
The functions of the data persistence device based on the redis performance in the present invention have been described in detail in the above method embodiments, so that the description of the present embodiment is not detailed, and reference may be made to the related description in the foregoing embodiments, and no further description is given here.
Fig. 3 is a schematic diagram of a hardware structure of an electronic device for implementing various embodiments of the present invention, where the electronic device 300 includes but is not limited to: radio frequency unit 301, network module 302, audio output unit 303, input unit 304, sensor 305, display unit 306, user input unit 307, interface unit 308, memory 309, processor 310, and power supply 311. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 3 does not constitute a limitation of the electronic device, and that the electronic device may include more or fewer components than shown, or combine certain components, or a different arrangement of components. In the embodiment of the present invention, the electronic device includes, but is not limited to, a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted terminal, a wearable device, a pedometer, and the like.
Wherein, the processor 310 may be configured to:
calculating system resource consumption values of a master group and a slave group in a redis cluster, wherein nodes with the same epoch in the redis cluster are the master group and the slave group;
determining a master-slave group with the minimum system resource consumption value according to the system resource consumption values of the master-slave group;
and under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold value, performing data persistence processing on nodes meeting preset conditions in the master-slave group.
In the embodiment of the invention, the system resource consumption value of the master group and the slave group in the redis cluster is calculated, the master group and the slave group with the minimum system resource consumption value are determined according to the system resource consumption value, and finally, under the condition that the system resource consumption value of the master group and the slave group with the minimum system resource consumption value is smaller than the first threshold value, data persistence processing is carried out on the nodes meeting the preset conditions in the master group and the slave group. The embodiment of the invention judges whether the nodes in the master-slave group meet the condition of starting persistence or not by calculating the system resource consumption value of each master-slave group in the redis cluster, and when the use condition of the node resources meets the requirement, the node persistence is started, otherwise, the node persistence is closed, thereby avoiding the influence of the persistence under the high concurrency environment on the redis performance.
It should be understood that, in the embodiment of the present invention, the radio frequency unit 301 may be used for receiving and sending signals during a message sending and receiving process or a call process, and specifically, receives downlink data from a base station and then processes the received downlink data to the processor 310; in addition, the uplink data is transmitted to the base station. In general, radio frequency unit 301 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, and the like. In addition, the radio frequency unit 301 can also communicate with a network and other devices through a wireless communication system.
The electronic device provides wireless broadband internet access to the user via the network module 302, such as assisting the user in sending and receiving e-mails, browsing web pages, and accessing streaming media.
The audio output unit 303 may convert audio data received by the radio frequency unit 301 or the network module 302 or stored in the memory 309 into an audio signal and output as sound. Also, the audio output unit 303 may provide audio output related to a specific function performed by the electronic apparatus 300 (e.g., a call signal reception sound, a message reception sound, etc.). The audio output unit 303 includes a speaker, a buzzer, a receiver, and the like.
The input unit 304 is used to receive audio or video signals. The input Unit 304 may include a Graphics Processing Unit (GPU) 3041 and a microphone 3042, and the Graphics processor 3041 processes image data of a still picture or video obtained by an image capturing apparatus (such as a camera) in a video capturing mode or an image capturing mode. The processed image frames may be displayed on the display unit 306. The image frames processed by the graphic processor 3041 may be stored in the memory 309 (or other storage medium) or transmitted via the radio frequency unit 301 or the network module 302. The microphone 3042 may receive sounds and may be capable of processing such sounds into audio data. The processed audio data may be converted into a format output transmittable to a mobile communication base station via the radio frequency unit 301 in case of the phone call mode.
The electronic device 300 also includes at least one sensor 305, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor that adjusts the brightness of the display panel 3061 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 3061 and/or the backlight when the electronic device 300 is moved to the ear. As one type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), detect the magnitude and direction of gravity when stationary, and can be used to identify the posture of an electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), and vibration identification related functions (such as pedometer, tapping); the sensors 305 may also include fingerprint sensors, pressure sensors, iris sensors, molecular sensors, gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which are not described in detail herein.
The display unit 306 is used to display information input by the user or information provided to the user. The Display unit 306 may include a Display panel 3061, and the Display panel 3061 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
The user input unit 307 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic device. Specifically, the user input unit 307 includes a touch panel 3071 and other input devices 3072. The touch panel 3071, also referred to as a touch screen, may collect touch operations by a user on or near the touch panel 3071 (e.g., operations by a user on or near the touch panel 3071 using a finger, a stylus, or any suitable object or attachment). The touch panel 3071 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 310, and receives and executes commands sent by the processor 310. In addition, the touch panel 3071 may be implemented using various types of resistive, capacitive, infrared, surface acoustic wave, and the like. The user input unit 307 may include other input devices 3072 in addition to the touch panel 3071. Specifically, the other input devices 3072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described herein.
Further, the touch panel 3071 may be overlaid on the display panel 3061, and when the touch panel 3071 detects a touch operation on or near the touch panel, the touch operation is transmitted to the processor 310 to determine the type of the touch event, and then the processor 310 provides a corresponding visual output on the display panel 3061 according to the type of the touch event. Although the touch panel 3071 and the display panel 3061 are shown in fig. 3 as two separate components to implement the input and output functions of the electronic device, in some embodiments, the touch panel 3071 and the display panel 3061 may be integrated to implement the input and output functions of the electronic device, which is not limited herein.
The interface unit 308 is an interface for connecting an external device to the electronic apparatus 300. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device having an identification module, an audio input/output (I/O) port, a video I/O port, an earphone port, and the like. The interface unit 308 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic apparatus 300 or may be used to transmit data between the electronic apparatus 300 and an external device.
The memory 309 may be used to store software programs as well as various data. The memory 309 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 309 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The processor 310 is a control center of the electronic device, connects various parts of the whole electronic device by using various interfaces and lines, performs various functions of the electronic device and processes data by operating or executing software programs and/or modules stored in the memory 309 and calling data stored in the memory 309, thereby performing overall monitoring of the electronic device. Processor 310 may include one or more processing units; preferably, the processor 310 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 310.
The electronic device 300 may further include a power supply 311 (such as a battery) for supplying power to various components, and preferably, the power supply 311 may be logically connected to the processor 310 through a power management system, so as to implement functions of managing charging, discharging, and power consumption through the power management system.
In addition, the electronic device 300 includes some functional modules that are not shown, and are not described in detail herein.
Preferably, an embodiment of the present invention further provides an electronic device, which includes a processor 310, a memory 309, and a computer program stored in the memory 309 and capable of running on the processor 310, where the computer program, when executed by the processor 310, implements each process of the above data persistence method embodiment based on redis performance, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above data persistence method embodiment based on redis performance, and can achieve the same technical effect, and is not described herein again to avoid repetition. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (9)

1. A data persistence method based on a redis performance, comprising:
calculating system resource consumption values of a master group and a slave group in a redis cluster, wherein nodes with the same epoch in the redis cluster are the master group and the slave group;
determining a master-slave group with the minimum system resource consumption value according to the system resource consumption values of the master-slave group;
under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold value, performing data persistence processing on nodes meeting preset conditions in the master-slave group; the preset conditions include: the memory consumption value of the node is smaller than a second threshold value and the CPU consumption value of the node is smaller than a third threshold value;
the calculating system resource consumption values of the master and slave groups in the redis cluster comprises:
calculating the system resource consumption value of a master-slave group in the redis cluster according to the following formula:
Figure FDA0003810124770000011
wherein f (m, c) is the system resource consumption value of the master-slave group; m is n The memory consumption value of the nth node in the master-slave group is obtained; c. C n Is the CPU consumption value of the nth node in the master-slave set.
2. The method according to claim 1, wherein before performing data persistence processing on nodes satisfying a preset condition in the master-slave group, the method further comprises:
and judging whether the nodes in the master-slave group meet preset conditions or not.
3. The method according to claim 2, wherein the determining whether the nodes in the master-slave group satisfy a predetermined condition comprises:
judging whether the memory consumption value of the nodes in the master-slave group is smaller than a second threshold value or not and whether the CPU consumption value of the nodes in the master-slave group is smaller than a third threshold value or not;
and if the memory consumption value of the nodes in the master-slave group is smaller than a second threshold value and the CPU consumption value of the nodes in the master-slave group is smaller than a third threshold value, judging that the nodes with the memory consumption value smaller than the second threshold value and the CPU consumption value smaller than the third threshold value meet preset conditions.
4. The method of claim 1, further comprising:
and if the system resource consumption value of the master-slave group with the minimum system resource consumption value is greater than or equal to a first threshold value, closing the data persistence processing.
5. The method of claim 1, further comprising:
and under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold value, the nodes in the master-slave group do not meet preset conditions, and then data persistence processing is closed.
6. An apparatus for data persistence based on a redis capability, the apparatus comprising:
the computing module is used for computing system resource consumption values of a master group and a slave group in the redis cluster, wherein nodes with the same epoch in the redis cluster are the master group and the slave group;
the determining module is used for determining the master-slave group with the minimum system resource consumption value according to the system resource consumption values of the master-slave group;
the execution module is used for performing data persistence processing on nodes meeting preset conditions in the master-slave group under the condition that the system resource consumption value of the master-slave group with the minimum system resource consumption value is smaller than a first threshold value; wherein the preset conditions include: the memory consumption value is smaller than a second threshold value and the CPU consumption value is smaller than a third threshold value;
the calculating module is specifically configured to calculate a system resource consumption value of a master-slave group in a redis cluster as shown in the following formula:
Figure FDA0003810124770000021
wherein f (m, c) is the system resource consumption value of the master-slave group; m is n The memory consumption value of the nth node in the master-slave group is obtained; c. C n Is the CPU consumption value of the nth node in the master-slave set.
7. The apparatus of claim 6, further comprising:
and the judging module is used for judging whether the nodes in the master-slave group meet the preset conditions or not.
8. The apparatus of claim 7, wherein the determining module is configured to:
judging whether the memory consumption value of the nodes in the master-slave group is smaller than a second threshold value or not and whether the CPU consumption value of the nodes in the master-slave group is smaller than a third threshold value or not;
and if the memory consumption value of the nodes in the master-slave group is smaller than a second threshold value and the CPU consumption value of the nodes in the master-slave group is smaller than a third threshold value, judging that the nodes with the memory consumption value smaller than the second threshold value and the CPU consumption value smaller than the third threshold value meet preset conditions.
9. An electronic device, comprising: memory, processor and computer program stored on the memory and executable on the processor, which computer program, when executed by the processor, carries out the steps of the method according to any one of claims 1 to 5.
CN201911412031.7A 2019-12-31 2019-12-31 Data persistence method and device based on redis performance and electronic equipment Active CN113127557B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911412031.7A CN113127557B (en) 2019-12-31 2019-12-31 Data persistence method and device based on redis performance and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911412031.7A CN113127557B (en) 2019-12-31 2019-12-31 Data persistence method and device based on redis performance and electronic equipment

Publications (2)

Publication Number Publication Date
CN113127557A CN113127557A (en) 2021-07-16
CN113127557B true CN113127557B (en) 2022-12-13

Family

ID=76770213

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911412031.7A Active CN113127557B (en) 2019-12-31 2019-12-31 Data persistence method and device based on redis performance and electronic equipment

Country Status (1)

Country Link
CN (1) CN113127557B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102508881A (en) * 2011-10-18 2012-06-20 国网电力科学研究院 Method for clustering multiple nodes of memory database of power information system
CN105657057A (en) * 2012-12-31 2016-06-08 华为技术有限公司 Calculation and storage fused cluster system
CN105989160A (en) * 2015-03-03 2016-10-05 大唐软件技术股份有限公司 Memory data persistence method and apparatus for Redis database
CN106453512A (en) * 2016-09-05 2017-02-22 努比亚技术有限公司 Redis cluster information monitoring device and method
CN107590023A (en) * 2017-08-10 2018-01-16 上海壹账通金融科技有限公司 Data processing method, electronic equipment and computer-readable recording medium
CN107589907A (en) * 2017-08-10 2018-01-16 上海壹账通金融科技有限公司 Data processing method, electronic equipment and computer-readable recording medium
CN109815049A (en) * 2017-11-21 2019-05-28 北京金山云网络技术有限公司 Node delay machine restoration methods, device, electronic equipment and storage medium
CN110365752A (en) * 2019-06-27 2019-10-22 北京大米科技有限公司 Processing method, device, electronic equipment and the storage medium of business datum

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108287854B (en) * 2017-01-10 2021-06-22 网宿科技股份有限公司 Method and system for data persistence in stream calculation
US10613944B2 (en) * 2017-04-18 2020-04-07 Netapp, Inc. Systems and methods for backup and restore of distributed master-slave database clusters
US20190086452A1 (en) * 2017-09-18 2019-03-21 Elutions IP Holdings S.à.r.l. Systems and methods for managing resource consumption

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102508881A (en) * 2011-10-18 2012-06-20 国网电力科学研究院 Method for clustering multiple nodes of memory database of power information system
CN105657057A (en) * 2012-12-31 2016-06-08 华为技术有限公司 Calculation and storage fused cluster system
CN105989160A (en) * 2015-03-03 2016-10-05 大唐软件技术股份有限公司 Memory data persistence method and apparatus for Redis database
CN106453512A (en) * 2016-09-05 2017-02-22 努比亚技术有限公司 Redis cluster information monitoring device and method
CN107590023A (en) * 2017-08-10 2018-01-16 上海壹账通金融科技有限公司 Data processing method, electronic equipment and computer-readable recording medium
CN107589907A (en) * 2017-08-10 2018-01-16 上海壹账通金融科技有限公司 Data processing method, electronic equipment and computer-readable recording medium
CN109815049A (en) * 2017-11-21 2019-05-28 北京金山云网络技术有限公司 Node delay machine restoration methods, device, electronic equipment and storage medium
CN110365752A (en) * 2019-06-27 2019-10-22 北京大米科技有限公司 Processing method, device, electronic equipment and the storage medium of business datum

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Java对象持久化层的检索性能优化研究;肖燕娟;《现代计算机(专业版)》;20080625(第6期);164-166+177 *
Persistence and Recovery for In-Memory NoSQL Services: A Measurement Study;Xianqiang Bao 等;《2016 IEEE International Conference on Web Services (ICWS)》;20160901;530-537 *
Redis数据库特性分析;马豫星;《物联网技术》;20150315(第03期);111-112 *

Also Published As

Publication number Publication date
CN113127557A (en) 2021-07-16

Similar Documents

Publication Publication Date Title
CN108073458B (en) Memory recovery method, mobile terminal and computer-readable storage medium
CN108681498B (en) CPU occupancy rate monitoring method and device and mobile terminal
CN109976611B (en) Terminal device control method and terminal device
CN109522278B (en) File storage method and terminal equipment
CN109639887B (en) Control method and terminal equipment
CN109995862B (en) Resource scheduling method and terminal
US20230013341A1 (en) Call processing method and electronic device
CN108984066B (en) Application icon display method and mobile terminal
CN108920040B (en) Application icon sorting method and mobile terminal
CN108536349B (en) Icon management method and mobile terminal
CN110569119B (en) Background application program management method and terminal
CN111026674A (en) Data storage method and electronic equipment
CN108089935B (en) Application program management method and mobile terminal
CN108597495B (en) Method and device for processing voice data
US20200280841A1 (en) Information processing method for rf device and mobile terminal
CN111338745A (en) Deployment method and device of virtual machine and intelligent equipment
CN111240451B (en) Heat dissipation method, electronic device and computer-readable storage medium
CN111142731B (en) Display method and electronic equipment
CN109144860B (en) Operation method for control object and terminal equipment
CN112347067A (en) Log information management and control method and device and computer readable storage medium
CN111309390A (en) Method for acquiring configuration information and electronic equipment
CN108628534B (en) Character display method and mobile terminal
CN108646966B (en) Screen-off time adjusting method and device
CN110928616A (en) Shortcut icon management method and electronic equipment
CN113127557B (en) Data persistence method and device based on redis performance and electronic equipment

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