Big data storage method based on abnormal data
Through real-time monitoring and feature extraction, Redis buffer queue adjustment and mean shift algorithm clustering, the problem of insufficient resource management and anomaly detection in traditional big data storage methods is solved, and efficient abnormal data processing and accurate detection are achieved.
Patent Information
- Application Number
- CN202411081304.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-08-08
AI Technical Summary
Traditional big data storage methods cannot respond to real-time data anomalies in a timely manner, and resource management and task allocation are insufficient, resulting in low resource utilization, insufficient processing capabilities, lack of unified data transmission and processing specifications, low data processing efficiency, and inaccurate abnormal data detection. .
By monitoring the target data source in real time, extracting data flow characteristics, detecting abnormal data, building a Redis buffer queue, adjusting the queue length in real time, calculating the comprehensive load, dynamically adjusting the number of thread pools, and using the mean shift algorithm for data grid division And clustering, calculate the exception factor, encapsulate the abnormal data packet and transmit it to the Redis buffer queue.
It realizes the timely identification and processing of abnormal data, optimizes resource management, improves data processing efficiency, standardizes the transmission and processing process of abnormal data, and improves the accuracy and reliability of abnormal detection.
Smart Images

Figure CN118626274B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data management, and in particular to a big data storage method based on abnormal data. Background Art
[0002] Big data refers to a collection of data that is huge in scale, diverse in types, and complex to process. These data usually cover multiple fields and sources, including structured data (such as tabular data in databases), semi-structured data (such as XML files, JSON files, etc.) and unstructured data (such as text, audio, video, images, etc.).
[0003] Traditional methods usually require offline data processing and cannot respond to real-time data anomalies in a timely manner. Traditional methods may have deficiencies in resource management and task allocation, resulting in low resource utilization or insufficient processing capacity. Traditional methods may lack unified data transmission and processing specifications, resulting in non-standardized and uncontrollable data processing processes. Traditional methods may not be able to dynamically adjust according to actual read and write pressures, resulting in low data processing efficiency. Finally, traditional methods' abnormal data detection may be relatively simple and unable to accurately capture various complex abnormal situations. Summary of the invention
[0004] The purpose of the present invention is to propose a big data storage method based on abnormal data in view of the problems existing in the background technology.
[0005] The technical solution of the present invention: a big data storage method based on abnormal data, comprising:
[0006] Performing real-time monitoring on each data stream to be collected included in the target data source to obtain multiple data streams, and performing feature extraction on the multiple data streams to obtain data stream features of the multiple data streams;
[0007] Performing data anomaly detection on the multiple data streams based on the data stream characteristics, thereby obtaining abnormal data;
[0008] Construct a Redis buffer queue, and encapsulate the abnormal data to obtain an abnormal data packet, and transmit the abnormal data packet to the Redis buffer queue. The Redis buffer queue adjusts the length of the Redis buffer queue in real time according to the periodic load rate, and monitors the Redis buffer queue regularly according to the queue monitoring table to obtain queue monitoring table data;
[0009] Regularly collect the queue monitoring table data to calculate the comprehensive load of the Redis buffer, and allocate read and write tasks based on the comprehensive load of the Redis buffer;
[0010] Calculate the read-write pressure in real time, compare the read-write pressure with the preset maximum pressure threshold, if the read-write pressure is greater than the preset maximum pressure threshold, dynamically increase the thread pool, and compare the read-write pressure with the preset minimum pressure threshold, if the read-write pressure is less than the preset minimum pressure threshold, dynamically recycle the idle thread pool.
[0011] Preferably, performing data anomaly detection on the multiple data streams based on the data stream features to obtain abnormal data includes:
[0012] Gridding the data space of the multiple data streams to obtain a plurality of data grid units;
[0013] Clustering the data points in the data grid unit according to the data stream characteristics based on a mean shift algorithm, thereby obtaining a cluster center of the data points in the data grid unit;
[0014] The total anomaly factor of the data grid unit is calculated based on the cluster center, and the total anomaly factor calculation formula is as follows:
[0015] ;
[0016] in, represents the total anomaly factor of each of the data grid cells, represents the total set of data grid cells, and , represents the total number of the data grid cells in the data space of the multiple data streams, represents the density anomaly factor of each of the data grid cells, Representing the distance anomaly factor of each of the data grid cells;
[0017] The density anomaly factor of the data grid unit is calculated based on the cluster center, and the density anomaly factor calculation formula is as follows:
[0018] ;
[0019] in, represents the reachable density from the total set of data grid cells g to its neighbors o, represents the reachable density of the data points corresponding to the total set of data grid units g and its cluster center, and , represents the k nearest neighbor set of the total set g of the data grid cells, and , represents the number of k nearest neighbors of the total set g of the data grid cells, represents the neighbor o of the data grid cell, represents the data point corresponding to the cluster center of the data grid unit in the total set g of data grid units, represents another data grid unit in the total set g of data grid units, represents the reachable distance between two data grid cells, and , represents the neighbor o density parameter of the data grid cell, represents the Euclidean distance between the centroids of two data grid cells, A data point density parameter corresponding to the cluster center of the data grid unit in the total set g of data grid units;
[0020] The distance anomaly factor of the data grid unit is calculated based on the cluster center, and the distance anomaly factor calculation formula is as follows:
[0021] ;
[0022] The total abnormal factor of the data grid unit is compared with a preset abnormal threshold value, so as to obtain the abnormal data in the data grid unit.
[0023] Preferably, the abnormal data packet format is as follows:
[0024] ;
[0025] in, Indicates the abnormal data packet, Indicates the target IP address. Indicates the source IP address. Indicates the length of the abnormal data packet, represents the abnormal data, Indicates the cyclic redundancy check code of the data field, and the format of the abnormal data is as follows:
[0026] ;
[0027] in, Indicates the buffer ID, Indicates the queue number. Indicates the data processing node ID, Indicates the timestamp, Indicates the data area.
[0028] Preferably, the Redis buffer queue adjusts the length of the Redis buffer queue in real time according to the periodic load rate, including:
[0029] The processing cycle of the data processing node is obtained in real time, and the cycle load rate of the Redis buffer queue of each processing cycle is calculated. The cycle load rate calculation formula is as follows:
[0030] ;
[0031] in, represents the cycle duty ratio, Indicates the number of elements in the Redis buffer queue, Indicates the length of the Redis buffer queue;
[0032] Calculate the initial size of the Redis buffer queue. The calculation formula for the initial size of the Redis buffer queue is as follows:
[0033] ;
[0034] in, Indicates the initial size of the Redis buffer queue, represents the initial period of the data processing node, represents the initial enqueue rate of the data processing node during the initial cycle;
[0035] The length of the Redis buffer queue is adjusted based on the periodic load rate of the Redis buffer queue by a length adjustment formula, and the length adjustment formula is as follows:
[0036] ;
[0037] in, Indicates the processing cycle of the data processing node The length of the Redis buffer queue, Indicates the maximum length of the Redis buffer queue, represents the adjustment factor, Indicates the real-time length of the Redis buffer queue, Indicates the initial size of the Redis buffer queue, Indicates the preset minimum load rate, Indicates the preset maximum load rate, Indicates the periodic load rate of the Redis buffer queue.
[0038] Preferably, the queue monitoring table is as follows:
[0039] ;
[0040] in, represents the queue monitoring table, Indicates the buffer ID, Indicates the queue number. Indicates the number of queue elements. Indicates the queue length, represents the queue entry rate, Indicates the dequeue rate.
[0041] Preferably, the Redis buffer comprehensive load calculation formula is as follows:
[0042] ;
[0043] in, represents the comprehensive load of the i-th Redis buffer, Indicates the number of Redis buffers, represents the load weight, Indicates the length of the Redis buffer queue; Indicates the number of elements in the Redis buffer queue; Represents the enqueue rate of the data processing node; j represents the jth Redis buffer among N Redis buffers.
[0044] Preferably, the read and write task allocation based on the comprehensive load of the Redis buffer includes:
[0045] Sorting the Redis buffer based on the comprehensive load of the Redis buffer to obtain a buffer sequence;
[0046] Select the Redis buffer with the smallest comprehensive load of the Redis buffer from the buffer sequence;
[0047] The idle thread is woken up from the Redis buffer, and the read and write tasks are performed through the idle thread.
[0048] Preferably, the reading and writing pressure calculation formula is as follows:
[0049] ;
[0050] in, Indicates the read-write pressure, , and Respectively represent the preset pressure weights, Indicates the number of Redis buffers, represents the comprehensive load of the i-th Redis buffer, Indicates the CPU utilization of the Redis buffer. Indicates the memory utilization of the Redis buffer.
[0051] Compared with the prior art, the above technical solution of the present invention has the following beneficial technical effects:
[0052] 1. The present invention can monitor the collected data stream in real time, and quickly identify abnormal data through feature extraction and data anomaly detection, so as to process it in time. Moreover, by constructing a Redis buffer queue and adjusting the queue length in real time according to the periodic load rate, calculating the comprehensive load and performing read and write task allocation, the system resources can be effectively managed, the data processing efficiency can be improved, and the number of thread pools can be dynamically adjusted according to the read and write pressure, so that the thread pool can be dynamically increased to cope with challenges under high pressure, and the idle thread pool can be recovered under low pressure to avoid resource waste, thereby optimizing data processing efficiency.
[0053] 2. The present invention encapsulates abnormal data packets and transmits them to the Redis buffer queue, and defines the format of the abnormal data packets, which helps to standardize the transmission and processing flow of abnormal data. In addition, by clustering data grid units using the mean shift algorithm and calculating the abnormal factors, the abnormal data can be detected more accurately, thereby improving the accuracy and reliability of anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic flow chart of an overall method in an embodiment of the present invention;
[0055] Figure 2 A schematic diagram of a process of data anomaly detection in an embodiment of the present invention;
[0056] Figure 3 A schematic diagram of a process for adjusting the queue length of a Redis buffer zone in an embodiment of the present invention;
[0057] Figure 4 A flowchart of read and write task allocation in an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0058] Embodiment 1, as Figure 1 As shown, the big data storage method based on abnormal data proposed by the present invention includes:
[0059] S1. Real-time monitoring of each data stream to be collected included in the target data source is performed to obtain multiple data streams, and feature extraction is performed on the multiple data streams to obtain data stream features of the multiple data streams;
[0060] S2, performing data anomaly detection on multiple data streams based on data stream characteristics, thereby obtaining abnormal data;
[0061] S3, build a Redis buffer queue, and encapsulate the abnormal data to obtain an abnormal data packet, and transmit the abnormal data packet to the Redis buffer queue. The Redis buffer queue adjusts the length of the Redis buffer queue in real time according to the periodic load rate, and monitors the Redis buffer queue regularly according to the queue monitoring table, so as to obtain the queue monitoring table data;
[0062] S4. Regularly collect queue monitoring table data to calculate the comprehensive load of the Redis buffer, and allocate read and write tasks based on the comprehensive load of the Redis buffer;
[0063] S5. Calculate the read-write pressure in real time, compare the read-write pressure with the preset maximum pressure threshold, if the read-write pressure is greater than the preset maximum pressure threshold, dynamically increase the thread pool, and compare the read-write pressure with the preset minimum pressure threshold, if the read-write pressure is less than the preset minimum pressure threshold, dynamically recycle the idle thread pool.
[0064] In the present invention, data stream refers to a collection of data that is continuously generated and flows, which is data generated in real time or continuously generated; Redis buffer queue refers to a queue structure that uses Redis as a buffer to store and process data, which can provide efficient data reading and writing capabilities; periodic load rate refers to the system load rate calculated based on a certain time period (such as per second, per minute); thread pool is a mechanism for managing and reusing threads, which can pre-create a group of threads and maintain their life cycle for processing concurrent tasks.
[0065] Embodiment 2, as Figure 2-4 As shown, the big data storage method based on abnormal data proposed by the present invention, compared with the first embodiment, this embodiment also includes: performing data anomaly detection on multiple data streams based on data stream characteristics, thereby obtaining abnormal data, including:
[0066] A1. Gridding the data space of multiple data streams to obtain multiple data grid units;
[0067] A2. Clustering the data points in the data grid cells according to the data stream characteristics based on the mean shift algorithm, thereby obtaining the cluster center of the data points in the data grid cells;
[0068] A3. Calculate the total anomaly factor of the data grid unit based on the cluster center. The total anomaly factor calculation formula is as follows:
[0069] ;
[0070] in, represents the total anomaly factor of each data grid cell, represents the total set of data grid cells, and , The total number of data grid cells in the data space representing multiple data streams, represents the density anomaly factor of each data grid cell, Represents the distance anomaly factor of each data grid cell;
[0071] A4. Calculate the density anomaly factor of the data grid unit based on the cluster center. The density anomaly factor calculation formula is as follows:
[0072] ;
[0073] in, represents the reachability density from the total set of data grid cells g to its neighbors o, represents the reachable density of the data points corresponding to the total set of data grid cells g and their cluster centers, and , represents the set of k nearest neighbors of the total set of data grid cells g, and , represents the number of k nearest neighbors of the total set of data grid cells g, represents the neighbor o of the data grid cell, represents the data point corresponding to the cluster center of the data grid cell in the total set of data grid cells g, represents another data grid cell in the total set of data grid cells g, represents the reachable distance between two data grid cells, and , represents the neighbor o density parameter of the data grid cell, represents the Euclidean distance between the centroids of two data grid cells, Represents the data point density parameter corresponding to the cluster center of the data grid unit in the total set of data grid units g;
[0074] A5. Calculate the distance anomaly factor of the data grid unit based on the cluster center. The distance anomaly factor calculation formula is as follows:
[0075] ;
[0076] A6. Compare the total abnormal factor of the data grid unit with the preset abnormal threshold value to obtain the abnormal data in the data grid unit.
[0077] In this embodiment, the mean shift algorithm is a density-based clustering algorithm, which calculates the gradient of data points in the feature space and drifts the data points to the area with the highest density, thereby achieving clustering.
[0078] In an optional embodiment, the abnormal data packet format is as follows:
[0079] ;
[0080] in, Indicates abnormal data packets. Indicates the target IP address. Indicates the source IP address. Indicates the length of the abnormal data packet. Indicates abnormal data. Indicates the cyclic redundancy check code of the data field, and the format of the abnormal data is as follows:
[0081] ;
[0082] in, Indicates the buffer ID, Indicates the queue number. Indicates the data processing node ID, Indicates the timestamp, Indicates the data area.
[0083] In an optional embodiment, the Redis buffer queue adjusts the length of the Redis buffer queue in real time according to the periodic load rate, including:
[0084] B1. Obtain the processing cycle of the data processing node in real time, and calculate the cycle load rate of the Redis buffer queue in each processing cycle. The cycle load rate calculation formula is as follows:
[0085] ;
[0086] in, Indicates the cycle duty ratio, Indicates the number of elements in the Redis buffer queue. Indicates the length of the Redis buffer queue;
[0087] B2. Calculate the initial size of the Redis buffer queue. The calculation formula for the initial size of the Redis buffer queue is as follows:
[0088] ;
[0089] in, Indicates the initial size of the Redis buffer queue. represents the initial cycle of the data processing node, Indicates the initial enqueue rate during the initial cycle of the data processing node;
[0090] B3. The length of the Redis buffer queue is adjusted by a length adjustment formula based on the periodic load rate of the Redis buffer queue. The length adjustment formula is as follows:
[0091] ;
[0092] in, Indicates the processing cycle of the data processing node The length of the Redis buffer queue, Indicates the maximum length of the Redis buffer queue. represents the adjustment factor, Indicates the real-time length of the Redis buffer queue. Indicates the initial size of the Redis buffer queue. Indicates the preset minimum load rate, Indicates the preset maximum load rate, Indicates the periodic load rate of the Redis buffer queue.
[0093] In an optional embodiment, the queue monitoring table is as follows:
[0094] ;
[0095] in, Indicates the queue monitoring table. Indicates the buffer ID, Indicates the queue number. Indicates the number of queue elements. Indicates the queue length, represents the queue entry rate, Indicates the dequeue rate.
[0096] In an optional embodiment, the Redis buffer comprehensive load calculation formula is as follows:
[0097] ;
[0098] in, Represents the comprehensive load of the i-th Redis buffer, Indicates the number of Redis buffers. represents the load weight, Indicates the length of the Redis buffer queue; Indicates the number of elements in the Redis buffer queue; Represents the enqueue rate of the data processing node; j represents the jth Redis buffer among N Redis buffers.
[0099] In an optional embodiment, read and write task allocation is performed based on the comprehensive load of the Redis buffer, including:
[0100] C1. Sort the Redis buffer based on the comprehensive load of the Redis buffer to obtain a buffer sequence;
[0101] C2. Select the Redis buffer with the smallest comprehensive Redis buffer load from the buffer sequence;
[0102] C3. Wake up the idle thread from the Redis buffer and perform read and write tasks through the idle thread.
[0103] In an optional embodiment, the calculation formula for reading and writing pressure is as follows:
[0104] ;
[0105] in, Indicates read and write pressure, , and Respectively represent the preset pressure weights, Indicates the number of Redis buffers. Represents the comprehensive load of the i-th Redis buffer, Indicates the CPU utilization of the Redis buffer. Indicates the memory utilization of the Redis buffer.
[0106] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited thereto, and various changes can be made within the knowledge scope of technicians in the relevant technical field without departing from the purpose of the present invention.
Claims
1. A big data storage method based on abnormal data, characterized in that: include: Performing real-time monitoring on each data stream to be collected included in the target data source to obtain multiple data streams, and performing feature extraction on the multiple data streams to obtain data stream features of the multiple data streams; Performing data anomaly detection on the multiple data streams based on the data stream characteristics, thereby obtaining abnormal data; Construct a Redis buffer queue, and encapsulate the abnormal data to obtain an abnormal data packet, and transmit the abnormal data packet to the Redis buffer queue. The Redis buffer queue adjusts the length of the Redis buffer queue in real time according to the periodic load rate, and monitors the Redis buffer queue regularly according to the queue monitoring table to obtain queue monitoring table data; Regularly collect the queue monitoring table data to calculate the comprehensive load of the Redis buffer, and allocate read and write tasks based on the comprehensive load of the Redis buffer; The queue monitoring table is as follows: ; in, represents the queue monitoring table, Indicates the buffer ID, Indicates the queue number. Indicates the number of queue elements. Indicates the queue length, represents the queue entry rate, Indicates the dequeue rate; The Redis buffer comprehensive load calculation formula is as follows: ; in, represents the comprehensive load of the i-th Redis buffer, Indicates the number of Redis buffers, represents the load weight, Indicates the length of the Redis buffer queue; Indicates the number of elements in the Redis buffer queue; Indicates the enqueue rate of the data processing node; j indicates the jth Redis buffer in N Redis buffers; The read and write task allocation based on the comprehensive load of the Redis buffer includes: Sorting the Redis buffer based on the comprehensive load of the Redis buffer to obtain a buffer sequence; Select the Redis buffer with the smallest comprehensive load of the Redis buffer from the buffer sequence; Waking up an idle thread from the Redis buffer and executing read and write tasks through the idle thread; Calculate the read-write pressure in real time, compare the read-write pressure with a preset maximum pressure threshold, and dynamically increase the thread pool if the read-write pressure is greater than the preset maximum pressure threshold, and compare the read-write pressure with a preset minimum pressure threshold, and dynamically recycle the idle thread pool if the read-write pressure is less than the preset minimum pressure threshold; The Redis buffer queue adjusts the length of the Redis buffer queue in real time according to the periodic load rate, including: The processing cycle of the data processing node is obtained in real time, and the cycle load rate of the Redis buffer queue of each processing cycle is calculated. The cycle load rate calculation formula is as follows: ; in, represents the cycle duty ratio, Indicates the number of elements in the Redis buffer queue, Indicates the length of the Redis buffer queue; Calculate the initial size of the Redis buffer queue. The calculation formula for the initial size of the Redis buffer queue is as follows: ; in, Indicates the initial size of the Redis buffer queue, represents the initial period of the data processing node, represents the initial enqueue rate of the data processing node during the initial cycle; The length of the Redis buffer queue is adjusted based on the periodic load rate of the Redis buffer queue by a length adjustment formula, and the length adjustment formula is as follows: ; in, Indicates the processing cycle of the data processing node The length of the Redis buffer queue, Indicates the maximum length of the Redis buffer queue, represents the adjustment factor, Indicates the real-time length of the Redis buffer queue, Indicates the initial size of the Redis buffer queue, Indicates the preset minimum load rate, Indicates the preset maximum load rate, Indicates the periodic load rate of the Redis buffer queue.
2. The big data storage method based on abnormal data according to claim 1 is characterized in that: The performing data anomaly detection on the multiple data streams based on the data stream features to obtain abnormal data includes: Gridding the data space of the multiple data streams to obtain a plurality of data grid units; Clustering the data points in the data grid unit according to the data stream characteristics based on a mean shift algorithm, thereby obtaining a cluster center of the data points in the data grid unit; The total anomaly factor of the data grid unit is calculated based on the cluster center, and the total anomaly factor calculation formula is as follows: ; in, represents the total anomaly factor of each of the data grid cells, represents the total set of data grid cells, and , represents the total number of the data grid cells in the data space of the multiple data streams, represents the density anomaly factor of each of the data grid cells, Representing the distance anomaly factor of each of the data grid cells; The density anomaly factor of the data grid unit is calculated based on the cluster center, and the density anomaly factor calculation formula is as follows: ; in, represents the reachable density from the total set of data grid cells g to its neighbors o, represents the reachable density of the data points corresponding to the total set of data grid units g and its cluster center, and , represents the k nearest neighbor set of the total set g of the data grid cells, and , represents the number of k nearest neighbors of the total set g of the data grid cells, represents the neighbor o of the data grid cell, represents the data point corresponding to the cluster center of the data grid unit in the total set g of data grid units, represents another data grid unit in the total set g of data grid units, represents the reachable distance between two data grid cells, and , represents the neighbor o density parameter of the data grid cell, represents the Euclidean distance between the centroids of two data grid cells, A data point density parameter corresponding to the cluster center of the data grid unit in the total set g of data grid units; The distance anomaly factor of the data grid unit is calculated based on the cluster center, and the distance anomaly factor calculation formula is as follows: ; The total abnormal factor of the data grid unit is compared with a preset abnormal threshold value, so as to obtain the abnormal data in the data grid unit.
3. The big data storage method based on abnormal data according to claim 1 is characterized in that: The abnormal data packet format is as follows: ; in, Indicates the abnormal data packet, Indicates the target IP address. Indicates the source IP address. Indicates the length of the abnormal data packet, represents the abnormal data, Indicates the cyclic redundancy check code of the data field, and the format of the abnormal data is as follows: ; in, Indicates the buffer ID, Indicates the queue number. Indicates the data processing node ID, Indicates the timestamp, Indicates the data area.
4. The big data storage method based on abnormal data according to claim 1 is characterized in that: The calculation formula of the read-write pressure is as follows: ; in, Indicates the read-write pressure, , and Respectively represent the preset pressure weights, Indicates the number of Redis buffers, represents the comprehensive load of the i-th Redis buffer, Indicates the CPU utilization of the Redis buffer. Indicates the memory utilization of the Redis buffer.
