Log management method, device and electronic device

By electing management nodes in CDN edge nodes and using tree log data structures for log classification storage, the problem of mixed CDN edge node log management is solved, efficient log isolation and storage is achieved, costs are reduced and management efficiency is improved.

CN118400386BActive Publication Date: 2024-10-18HANGZHOU YOUYUN TECH CO LTD
View PDF 14 Cites 0 Cited by

Patent Information

Application Number
CN202410842735.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-18
Estimated Expiration
2044-06-26

AI Technical Summary

Technical Problem

CDN edge nodes lack effective isolation and classification mechanisms for multi-tenant logs, resulting in mixed logs that are difficult to manage.

Method used

By electing a management node from multiple CDN edge nodes, uniformly reading the logs and classifying and storing them in a tree log data structure, using the domain name field as the classification dimension, and storing them in different storage devices according to preset isolation rules, this is achieved Effective isolation and management of logs.

Benefits of technology

It achieves classified management of mixed logs, reduces the total cost of log storage, and improves the efficiency and reliability of log processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118400386B_ABST
    Figure CN118400386B_ABST
Patent Text Reader

Abstract

The present specification provides a log management method and device and an electronic device. The method is applied to a management node selected from an edge cluster composed of multiple CDN edge nodes, and the management node performs the following steps to process the logs on each CDN edge node: read the logs stored in the CDN edge node, extract the domain name field from the log; take the domain name field as the classification dimension, and store the domain name field and the corresponding log in a tree-shaped log data structure; wherein the log data structure is composed of a first-level node, a second-level node under the first-level node, a third-level node under the second-level node, and a log list associated with the third-level node, the first-level node is used to store the top-level domain name in the domain name field, the second-level node is used to store the second-level domain name in the domain name field, the third-level node is used to store the remaining content in the domain name field except the top-level domain name and the second-level domain name, and the log list is used to store the log corresponding to the domain name field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of communications, and in particular to a log management method and device and an electronic device. Background Art

[0002] Content Delivery Network (CDN) is a cluster of servers distributed in different geographical locations. CDN can use these servers in different geographical locations to assign the nearest server to the end user, so as to quickly provide the Internet content (such as HTML web pages, JavaScript files, style sheets, images and videos, etc.) required by the end user.

[0003] CDN edge nodes are computers located at the logical limit or "edge" of the CDN, which provide entry points into the CDN. The main purpose of CDN edge nodes is to store content as close as possible to the client computer making the request, thereby reducing latency and improving page load times.

[0004] CDN edge nodes face the problem of difficult log management. Specifically, since each CDN edge node can connect to multiple different tenants (i.e., users who use the node), and each tenant generates corresponding logs; these logs lack effective isolation and classification mechanisms in CDN edge nodes, resulting in logs being mixed together and difficult to manage. Summary of the invention

[0005] The embodiments of this specification provide a log management method, device and electronic device to solve the problem that mixed logs are difficult to manage.

[0006] According to a first aspect of an embodiment of this specification, a log management method is provided, which is applied to a management node elected from an edge cluster consisting of multiple CDN edge nodes, wherein the management node performs the following steps to process logs on each CDN edge node:

[0007] Read the log stored in the CDN edge node, and extract the domain name field from the log;

[0008] Taking the domain name field as a classification dimension, the domain name field and the corresponding log are stored in a tree-shaped log data structure; wherein the log data structure is composed of a first-level node, a second-level node under the first-level node, a third-level node under the second-level node, and a log list associated with the third-level node, the first-level node is used to store the top-level domain name in the domain name field, the second-level node is used to store the second-level domain name in the domain name field, the third-level node is used to store the remaining content in the domain name field except the top-level domain name and the second-level domain name, and the log list is used to store the log corresponding to the domain name field.

[0009] Optionally, the management node is selected from the multiple CDN edge nodes in the following manner:

[0010] The election time point is calculated according to the current time point and the log collection cycle, and at the election time point, a CDN edge node is elected as the management node through the key-value pair storage service corresponding to the edge cluster.

[0011] Optionally, the step of calculating the election time point according to the current time point and the log collection cycle, and electing a CDN edge node as a management node through a key-value pair storage service corresponding to the edge cluster at the election time point includes:

[0012] CDN edge node i calculates m=t mod P, where i is the sequence number of the CDN edge node, m is the remainder, t is the current time point, and P is the log collection period;

[0013] When m is 0, a set instruction with a key of t and a value of i is sent to the key-value pair storage service corresponding to the edge cluster, and the key-value pair storage service sets the CDN edge node i corresponding to the first received set instruction as the management node.

[0014] Optionally, before sending a set instruction with a key of t and a value of i to the key-value pair storage service corresponding to the edge cluster, the method further includes:

[0015] Send a get instruction with the key tp to the key-value pair storage service corresponding to the edge cluster, query whether the key tp is set in the key-value pair storage service, and the value corresponding to the key tp is i; wherein tp=tP;

[0016] If yes, set the load balancing factor to a first value; if no, set the load balancing factor to a second value which is smaller than the first value;

[0017] Calculate the sleep duration based on the set load balancing factor and the resource usage rate of the CDN edge node i, and perform sleep for the sleep duration;

[0018] After the sleep is over, a step of sending a set instruction with a key of t and a value of i to a key-value pair storage service corresponding to the edge cluster is executed.

[0019] Optionally, the sleep duration T'=(T×r)×F; wherein T is the default sleep duration, r is the resource utilization rate, and F is the set load balancing factor;

[0020] The resource utilization rate r=(h / MA)+(d / D); wherein MA is the total memory of CDN edge node i, h is the used memory of CDN edge node i, D is the total external memory of CDN edge node i, and d is the used external memory of CDN edge node i.

[0021] Optionally, after storing the domain name field in the tree-shaped log data structure, the method further includes:

[0022] After the domain name fields of the logs on all CDN edge nodes are stored in the tree-shaped log data structure, the logs in the log list of the log data structure are stored in different storage devices according to the preset isolation rules;

[0023] The preset isolation rules include:

[0024] For logs that do not care about log integrity, store them on the local mechanical disk of the management node;

[0025] Logs that are concerned about log integrity and can tolerate short-term failures of the log service are stored on disks mounted on redundant arrays of disks on the management node.

[0026] Logs that are concerned about log integrity and cannot tolerate short-term failures of the log service are stored in the external distributed storage corresponding to the edge cluster.

[0027] Optionally, the different storage devices correspond to different root paths, and the root path of the storage device corresponding to the log configuration in the log list is configured with a path data structure of a key-value pair; wherein the key of the key-value pair is the domain name of the log, and the value is the root path.

[0028] Optionally, the log data structure provides an add instruction and a flush instruction;

[0029] The domain name field is used as a classification dimension, and the domain name field and the corresponding log are stored in a tree-shaped log data structure, including:

[0030] Calling the add instruction provided by the log data structure to send the domain name field and the corresponding log to the log data structure, and the log data structure uses the domain name field as a classification dimension to store the domain name field and the corresponding log;

[0031] The storing the logs in the log list of the log data structure to different storage devices according to the preset isolation rule includes:

[0032] Calling the Flush instruction provided by the log data structure, wherein the Flush instruction does not carry any parameters, the log data structure traverses all domain name fields consisting of the first-level nodes, the second-level nodes, and the third-level nodes, and stores the logs in the log list associated with the third-level node corresponding to each domain name field to different storage devices according to the preset isolation rule;

[0033] After all log lists are stored, clear all log lists.

[0034] Optionally, the log data structure further provides a Length instruction; after storing the domain name field and the corresponding log into the tree-shaped log data structure, it also includes:

[0035] Calling the Length instruction provided by the log data structure, wherein the Length instruction carries the domain name field, and the log data structure queries the list length of the log list associated with the third-level node corresponding to the domain name field in response to the Length instruction;

[0036] When the length of the list reaches a preset length, the Flush instruction provided by the log data structure is called, and the Flush instruction carries the domain name field, and the log data structure stores the logs in the log list associated with the third-level node corresponding to the domain name field to different storage devices according to the preset isolation rule; and, after the storage is completed, the log list is stored.

[0037] Optionally, the management node generates a local file whose file name contains t;

[0038] After reading the logs stored in all CDN edge nodes and storing the domain name fields extracted from all logs and the corresponding logs in the log data structure, the management node deletes the local files whose file names contain t; and sends a del instruction with a key of t to the key-value pair storage service to delete the key-value pair with a key of t and a value of i set in the key-value pair storage service.

[0039] Optionally, before reading the logs stored in the CDN edge node, the following steps are also included:

[0040] Check whether there is a local file whose file name contains t in the local file;

[0041] The reading of the logs stored in the CDN edge node includes:

[0042] If it exists, read the log file whose file name contains t in the CDN edge node; the CDN edge node divides the local log into several log files based on the log collection cycle, and each log file contains the election time point t of each log collection cycle.

[0043] According to a second aspect of an embodiment of this specification, a log management device is provided, which is applied to a management node selected from an edge cluster consisting of multiple CDN edge nodes, and the management node executes the following units to process logs on each CDN edge node:

[0044] A reading unit, reading a log stored in a CDN edge node, and extracting a domain name field from the log;

[0045] A storage unit uses the domain name field as a classification dimension to store the domain name field and the corresponding log into a tree-shaped log data structure; wherein the log data structure is composed of a first-level node, a second-level node under the first-level node, a third-level node under the second-level node, and a log list associated with the third-level node, the first-level node is used to store the top-level domain name in the domain name field, the second-level node is used to store the second-level domain name in the domain name field, the third-level node is used to store the remaining content in the domain name field except the top-level domain name and the second-level domain name, and the log list is used to store the log corresponding to the domain name field.

[0046] According to a third aspect of the embodiments of this specification, there is provided an electronic device, including:

[0047] processor;

[0048] a memory for storing processor-executable instructions;

[0049] Wherein, the processor is configured as any of the above-mentioned log management methods.

[0050] The embodiment of the present specification provides a log management solution, which selects a management node from multiple CDN edge nodes, and the management node uniformly reads the logs in all CDN edge nodes, and sends the logs and the domain name fields of the logs to a tree-shaped log data structure. The log data structure uses the domain name field as a classification dimension, and uniformly stores the logs with the same domain name field in a log list; thereby achieving classification of mixed logs. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 is a flow chart of a log management method provided by an embodiment of this specification;

[0052] Figure 2 It is a schematic diagram of a three-layer node of a log data structure provided in an embodiment of this specification;

[0053] Figure 3 is a flowchart of the election of a management node provided in an embodiment of this specification;

[0054] Figure 4 It is a hardware structure diagram of a log management device provided in an embodiment of this specification;

[0055] Figure 5 It is a module of the log management device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0056] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0057] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0058] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0059] As mentioned above, due to the lack of effective isolation and classification mechanisms at CDN edge nodes, it is difficult to effectively manage logs.

[0060] To this end, this specification aims to provide a log management solution that can achieve the management and processing of multi-tenant logs. Specifically, a management node can be selected from multiple CDN edge nodes, and the management node uniformly reads the logs in all CDN edge nodes, and sends the logs and the domain name fields of the logs to a tree-shaped log data structure. The log data structure uses the domain name field as the classification dimension, and uniformly stores the logs with the same domain name field in a log list; thereby achieving the classification of mixed logs.

[0061] In addition, logs can be stored in a hierarchical and isolated manner according to specific business needs, thereby reducing the total cost of log storage while meeting the needs for log management.

[0062] The following combination Figure 1 The log management method flow chart shown can be applied to a management node selected from an edge cluster consisting of multiple CDN edge nodes. The management node performs the following steps to process logs on each CDN edge node:

[0063] Step 110: Read the log stored in the CDN edge node, and extract the domain name field from the log;

[0064] Step 120: Taking the domain name field as a classification dimension, the domain name field and the corresponding log are stored in a tree-shaped log data structure; wherein the log data structure is composed of a first-level node, a second-level node under the first-level node, a third-level node under the second-level node, and a log list associated with the third-level node, the first-level node is used to store the top-level domain name in the domain name field, the second-level node is used to store the second-level domain name in the domain name field, the third-level node is used to store the remaining content in the domain name field except the top-level domain name and the second-level domain name, and the log list is used to store the log corresponding to the domain name field.

[0065] In this specification, for the convenience of reading and understanding, the technical concepts, parameters, etc. used in the embodiments are defined as follows:

[0066] The edge cluster can be represented as a node set M consisting of N CDN edge nodes, where M is {M1, M2, ..., Mi, Mj, ..., Mn}, where Mi represents the i-th CDN edge node, Mj represents the j-th CDN edge node, and 1

[0067] The management node is defined as C.

[0068] The tree-like log data structure is defined as TR.

[0069] Exemplarily, the tree-shaped log data structure may be a data structure similar to a compressed Trie. Figure 2 The schematic diagram of the log data structure shown in the figure shows that RT is composed of three layers of nodes, namely, the first-level node (top layer), the second-level node (second layer) under the first-level node, the third-level node (third layer) under the second-level node, and the log list associated with the third-level node;

[0070] ​The first-level node is used to store the top-level domain name (such as com) in the domain name field, the second-level node is used to store the second-level domain name (such as uyun.com) in the domain name field, and the third-level node is used to store the remaining content in the domain name field except the top-level domain name and the second-level domain name (such as Figure 2 The log list is used to store the logs corresponding to the domain name field.

[0071] In this specification, the management node may be selected from the multiple CDN edge nodes in the following manner:

[0072] The election time point is calculated according to the current time point and the log collection cycle, and at the election time point, a CDN edge node is elected as the management node through the key-value pair storage service corresponding to the edge cluster.

[0073] Exemplarily, the key-value pair storage service may be defined as R, where R may be a storage service external to the edge cluster or a storage service internal to the edge cluster.

[0074] In actual applications, in order to reduce implementation costs, external key-value storage services are usually used, which eliminates the need for additional modifications to the original CDN edge cluster.

[0075] For the external key-value storage service R, you can use software such as Redis, Memcached, ZooKeeper, etc. to implement the functions of R.

[0076] R provides a variety of atomic instructions, such as set, get, and del. The set instruction can only successfully set the corresponding value if the key does not exist, otherwise the setting fails. The get instruction is used to get the corresponding value according to the key. The del instruction is used to delete the corresponding key-value pair according to the key.

[0077] In an exemplary embodiment, the step of calculating the election time point according to the current time point and the log collection period, and electing a CDN edge node as a management node through a key-value pair storage service corresponding to the edge cluster at the election time point includes:

[0078] CDN edge node i calculates m=t mod P, where i is the sequence number of the CDN edge node, m is the remainder, t is the current time point, and P is the log collection period;

[0079] When m is 0, a set instruction with a key of t and a value of i is sent to the key-value pair storage service corresponding to the edge cluster, and the key-value pair storage service sets the CDN edge node i corresponding to the first received set instruction as the management node.

[0080] In this specification, CDN edge node i may be the CDN edge node with sequence number i in the aforementioned node set M, where i is used to indicate that each CDN edge node in the edge cluster will perform the same election process.

[0081] The current time point is defined as t. To facilitate software calculation, t here can be a time point converted to a string type (such as a timestamp), and P is similar. In order to avoid the impact of time asynchrony on the election, the CDN edge nodes can use a time synchronization protocol such as NTP (Network Time Protocol) to ensure the time synchronization of all CDN edge nodes.

[0082] The log collection period is defined as P. The default value of P can be flexibly set according to needs, for example, it can be set to 300 seconds.

[0083] By calculating m=t mod P, if the remainder m is not 0, it means that the current time point has not reached the election time point, then m can be calculated again after a preset sleep time (such as 1 second); and this process is repeated until m is 0.

[0084] When m is 0, it means that the current time point has reached the election time point, then CDN edge node i can send a set instruction with key t and value i to R; although multiple or even each CDN edge node will send a set instruction, since the set instruction can only successfully set the corresponding value when the key does not exist, for R, it will only respond to the first set instruction received, that is, set the key-value pair of the first set instruction received.<t,i> , to set the CDN edge node i corresponding to the set instruction as the management node.

[0085] After the first set instruction is set, when R receives the set instruction sent by other CDN edge nodes, since the value of key t has been set, other set instructions will be invalid, thus ensuring that key t will only correspond to one value i, thereby ensuring that there is only one management node in a log collection cycle P starting from time point t.

[0086] Correspondingly, after a log collection cycle P starting from time point t ends or the management node has processed all logs, it can also send a del command with key t to R to delete the key-value pair with key t and value i set in R.

[0087] Through the above embodiment, it is possible to elect a management node within a log collection cycle.

[0088] In an exemplary embodiment, since different CDN edge nodes have different resource usage rates, the following load balancing strategy may also be used when electing a management node to elect a management node with stronger log processing capabilities.

[0089] Specifically, before sending a set instruction with a key of t and a value of i to the key-value pair storage service corresponding to the edge cluster, the following may also be included:

[0090] CDN edge node i sends a get instruction with the key tp to the key-value pair storage service corresponding to the edge cluster, querying whether the key tp is set in the key-value pair storage service, and whether the value corresponding to the key tp is i;

[0091] If yes, set the load balancing factor to a first value; if no, set the load balancing factor to a second value which is smaller than the first value;

[0092] Calculate the sleep duration based on the set load balancing factor and the resource usage rate of the CDN edge node i, and perform sleep for the sleep duration;

[0093] After the sleep is over, a step of sending a set instruction with a key of t and a value of i to a key-value pair storage service corresponding to the edge cluster is executed.

[0094] In this specification, tp=tP is defined, and tp is the same as t and P and can also be a time value of a character string type.

[0095] The load balancing factor is defined as F, the first value can be 1.2, and the second value can be 1. For the key tp in R and the corresponding value is i, it means that the current CDN edge node i has other log processing tasks. In order to avoid the problem of excessive load caused by the node executing multiple tasks at the same time, by increasing its load balancing factor (set to the first value), it needs to perform a longer sleep, thereby reducing its load.

[0096] In this specification, the sleep duration can be proportional to the resource utilization rate, that is, the CDN edge nodes with lower resource utilization rate will execute a shorter sleep duration, so that the CDN edge nodes with higher resource utilization rate can end sleep earlier; since the CDN edge nodes with higher resource utilization rate are still in sleep, the CDN edge nodes with lower resource utilization rate are more likely to become elected nodes.

[0097] Exemplarily, the sleep duration T'=(T×r×F; wherein T is the default sleep duration, r is the resource utilization rate, and F is the set load balancing factor.

[0098] The resource utilization rate r=(h / MA)+(d / D); wherein MA is the total memory of CDN edge node i, h is the used memory of CDN edge node i, D is the total external memory of CDN edge node i, and d is the used external memory of CDN edge node i.

[0099] Through the above embodiments, a CDN edge node with a higher resource utilization rate can perform a longer sleep period, thereby reducing its load; and a CDN edge node with a lower resource utilization rate can perform a shorter sleep period, so that it can send set instructions faster and have a greater chance of becoming a management node, which can achieve effective management of logs and improve its own resource utilization rate.

[0100] Please combine the following Figure 3 The election flow chart of the management node, the election procedure of any CDN edge node i calculates m, if m is not equal to 0, it sleeps for 1 second and then calculates m again, if m is equal to 0, then sends a get command to R to query whether there is a key of tp and the corresponding value is i; if yes, increase the load balancing factor F to the first value, if not, decrease the load balancing factor to the second value, and perform sleep (sleep duration T'); after the sleep ends, send a set command to R to compete with other CDN edge nodes to become a management node.

[0101] If it becomes a management node, the management node can generate a local file with the file name containing t, and then execute the above steps 110 and 120 to achieve classified management of logs of multiple CDN edge nodes in the edge cluster. In actual applications, the management node can concurrently execute steps 110 and 120 on multiple CDN edge nodes, and the processing efficiency of log management can be improved through concurrency.

[0102] With respect to the above step 120, the domain name field is used as a classification dimension, and the domain name field and the corresponding log are stored in a tree-shaped log data structure.

[0103] In this specification, the log data structure TR provides an add instruction, a Length instruction and a Flush instruction; wherein the Add instruction needs to carry 2 parameters (domain name field and the log corresponding to the domain name field), the Length instruction needs to carry 1 parameter (domain name field), and the Flush instruction can carry 1 parameter or no parameter.

[0104] The following first introduces the add command, which is used by the management node to call and store logs in TR.

[0105] Exemplarily, the above-mentioned storing the domain name field and the corresponding log into a tree-shaped log data structure using the domain name field as a classification dimension may include:

[0106] The add instruction provided by the log data structure is called to send the domain name field and the corresponding log to the log data structure, and the log data structure uses the domain name field as a classification dimension to store the domain name field and the corresponding log.

[0107] In this embodiment, after receiving the add instruction, TR will first parse the domain name field carried by the add instruction to obtain three parts: the top-level domain name, the second-level domain name and the remaining content of the domain name.

[0108] Then, the top-level domain name, second-level domain name, and remaining content of the domain name are routed in TR in turn. If the top-level domain name exists in the TR, the second-level domain name is further routed in the second-level node under the first-level node of the top-level domain name; if the second-level domain name is routed, the remaining content is further routed in the third-level node under the second-level node of the second-level domain name; if the third-level node of the remaining content is routed, the log corresponding to the domain name field is written into the log list associated with the third-level node, thereby completing the storage of a log.

[0109] If any of the top-level domain name, second-level domain name, and the remaining content of the domain name is not routed, it means that the domain name is added for the first time, and then the corresponding node and log list are required. For example, if there is no route to the top-level domain name, you need to create a first-level node to store the top-level domain name, and create a second-level node under the created first-level node to store the second-level domain name, and create a third-level node under the created second-level node to store the remaining content; in addition, you need to create a log list, associate the created log list with the created third-level node, and write the log corresponding to the domain name field into the created log list.

[0110] If the route is to the top-level domain name but not to the second-level domain name, you need to create a second-level node under the first-level node of the top-level domain name to store the second-level domain name, and create a third-level node under the created second-level node to store the remaining content; in addition, you need to create a log list, associate the created log list with the created third-level node, and write the log corresponding to the domain name field into the created log list.

[0111] If the route is to the top-level domain name and the second-level domain name, but not to the remaining content, you need to create a third-level node under the second-level node of the second-level domain name to be routed to store the remaining content; in addition, you need to create a log list, associate the created log list with the created third-level node, and write the log corresponding to the domain name field into the created log list.

[0112] In this specification, after executing step 120, the management node may further include:

[0113] After the domain name fields of the logs on all CDN edge nodes are stored in the tree-shaped log data structure, the logs in the log list of the log data structure are stored in different storage devices according to preset isolation rules.

[0114] The preset isolation rules include:

[0115] L1: For logs that do not care about log integrity, they are stored in the local mechanical disk of the management node;

[0116] L2: logs that care about log integrity and can tolerate short-term log service failures are stored on disks mounted with redundant arrays of disks on the management node;

[0117] L3: Logs that care about log integrity and cannot tolerate short-term failures of the log service are stored in the external distributed storage corresponding to the edge cluster.

[0118] In this specification, the default path of the root path of the storage device is defined as DP, and different storage devices correspond to different root paths; and the root path of the storage device corresponding to the log configuration in the log list is configured as a key-value pair path data structure SP; wherein the key of the key-value pair of SP is the domain name of the log, and the value is the root path.

[0119] Combined with the above preset isolation rules, for the logs in L1, the domain name of the log is used as the configuration key in SP, and the local mechanical disk of the management node is used as the value corresponding to the root path configuration key;

[0120] For the logs in L2, the domain name of the log is used as the configuration key in SP, and the disk with the redundant array of disks mounted on the management node is used as the value corresponding to the root path configuration key;

[0121] For logs in L3, configure the key with the domain name of the log in SP, and use external distributed storage as the root path to configure the value corresponding to the key.

[0122] Through the above embodiment, different log file root path strategies are corresponding to the business requirement levels to ensure the isolation of different tenants.

[0123] In this specification, each CDN edge node can divide the local log into several log files with the log collection period P as the division time length, and the file name of each log file contains the current time point t.

[0124] Accordingly, the above step 110 may include the management node reading a log file whose file name contains t in the CDN edge node;

[0125] When the management node reads a log file whose file name contains t+P (the log of the next log collection cycle, which needs to be processed by the management node elected in the next cycle), it means that the logs collected in the log collection cycle that the current management node is responsible for processing have been read. After the domain name fields of the logs on all CDN edge nodes that have been read are stored in the log data structure TR, the logs classified by TR (different log lists) can be stored in isolation.

[0126] In an exemplary embodiment, storing the logs in the log list of the log data structure to different storage devices according to the preset isolation rule may include:

[0127] The Flush instruction provided by the log data structure is called, and the Flush instruction does not carry any parameters. The log data structure traverses all domain name fields composed of the first-level nodes, the second-level nodes and the third-level nodes, and stores the logs in the log list associated with the third-level node corresponding to each domain name field to different storage devices according to the preset isolation rule; and after all log lists are stored, all log lists are cleared.

[0128] In this embodiment, after the current management node stores all the collected logs in the log collection cycle it is responsible for processing in TR, it can call the Flush instruction without parameters to store the logs in the log list of TR in different storage devices. Combined with the path data structure SP shown in the above embodiment, the root path of each log configuration is determined by querying SP, so that the log is stored in the corresponding storage device.

[0129] In an exemplary embodiment, the log list of the log data structure may be set to have a maximum length of TRL, that is, the log list may write at most TRL logs;

[0130] Accordingly, after storing the domain name field and the corresponding log into the tree-shaped log data structure, the following steps may also be included:

[0131] Calling the Length instruction provided by the log data structure, wherein the Length instruction carries the domain name field, and the log data structure queries the list length of the log list associated with the third-level node corresponding to the domain name field in response to the Length instruction;

[0132] When the length of the list reaches a preset length, the Flush instruction provided by the log data structure is called, and the Flush instruction carries the domain name field, and the log data structure stores the logs in the log list associated with the third-level node corresponding to the domain name field to different storage devices according to the preset isolation rule; and, after the storage is completed, the log list is stored.

[0133] Through the above embodiment, since the log list is set with a maximum length, when the log list is full (that is, the list length reaches the preset length), temporary storage can be triggered, so that the logs in the log list are transferred to the storage device; thus, the problem of subsequent logs being unable to be written occurs. In addition, by setting the maximum length, the storage pressure of TR can be reduced. Since TR can clear the logs in time when the log list is full and release storage resources, it is not necessary for TR to have storage resources that can meet the writing of massive logs, thereby reducing the use cost of TR.

[0134] In this specification, after reading the logs stored in all CDN edge nodes and storing the domain name fields extracted from all logs and the corresponding logs in the log data structure, the management node can also delete local files whose file names contain t; and send a del instruction with a key of t to the key-value pair storage service to delete the key-value pair with a key of t and a value of i set in the key-value pair storage service.

[0135] In addition, the present specification also provides related embodiments of log management failure recovery. If the management node is interrupted by external forces (such as node failure, forced termination by human intervention, etc.) during the log management process, the management node may restart and before reading the log stored in the CDN edge node in step 110, it may also include:

[0136] Check whether there is a local file whose file name contains t in the local file;

[0137] Accordingly, when executing step 110, the following steps may be included:

[0138] If it exists, read the log file whose file name contains t in the CDN edge node; the CDN edge node divides the local log into several log files based on the log collection cycle, and each log file contains the election time point t of each log collection cycle.

[0139] In this embodiment, when an external force is interrupted, the management node has not yet stored the domain name fields extracted from all logs and the corresponding logs into the log data structure, so the local file whose file name contains t will not be deleted;

[0140] Therefore, as long as the restarted management node reads a local file with the file name containing t, it can trigger the fault recovery operation, that is, read the log file with the file name containing t in the CDN edge node;

[0141] Since the CDN edge node divides the local log into several log files based on the log collection cycle, the current management node only needs to read the log file whose file name contains t in the CDN edge node to restore the interrupted log management process.

[0142] It should be noted that the logs read from the log file will be overwritten and written to the TR, and the logs written before the fault interruption will be overwritten. Therefore, after the fault is restored, reading the log file again will not cause the problem of log duplication.

[0143] Corresponding to the aforementioned log management method embodiment, this specification also provides an embodiment of a log management device. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the device in which it is located reading the corresponding computer program in the non-volatile memory into the memory and running it. From the hardware level, such as Figure 4 The following is a hardware structure diagram of the device where the log management device of this manual is located, except Figure 4 In addition to the processor, network interface, memory and non-volatile memory shown, the device in which the apparatus in the embodiment is located may also include other hardware according to the actual communication function, which will not be described in detail.

[0144] See also Figure 5 , is a module diagram of a log management device provided in an embodiment of this specification, and the device corresponds to Figure 1 The illustrated embodiment is applied to a management node selected from an edge cluster consisting of multiple CDN edge nodes, and the management node executes the following units to process logs on each CDN edge node:

[0145] A reading unit 310 reads a log stored in a CDN edge node and extracts a domain name field from the log;

[0146] The storage unit 320 uses the domain name field as a classification dimension to store the domain name field and the corresponding log into a tree-shaped log data structure; wherein the log data structure is composed of a first-level node, a second-level node under the first-level node, a third-level node under the second-level node, and a log list associated with the third-level node, wherein the first-level node is used to store the top-level domain name in the domain name field, the second-level node is used to store the second-level domain name in the domain name field, the third-level node is used to store the remaining content in the domain name field except the top-level domain name and the second-level domain name, and the log list is used to store the log corresponding to the domain name field.

[0147] Optionally, the management node is elected from the multiple CDN edge nodes by the following election unit:

[0148] The election unit calculates an election time point according to the current time point and the log collection cycle, and elects a CDN edge node as a management node through a key-value pair storage service corresponding to the edge cluster at the election time point.

[0149] Optionally, the election unit further comprises:

[0150] The calculation subunit, CDN edge node i calculates m=t mod P, where i is the sequence number of the CDN edge node, m is the remainder, t is the current time point, and P is the log collection period;

[0151] The setting subunit, when m is 0, sends a set instruction with a key of t and a value of i to the key-value pair storage service corresponding to the edge cluster, and the key-value pair storage service sets the CDN edge node i corresponding to the first received set instruction as the management node.

[0152] Optionally, before the setting subunit, the device further includes:

[0153] The query subunit sends a get instruction with a key of tp to the key-value pair storage service corresponding to the edge cluster, and queries whether the key of tp is set in the key-value pair storage service, and the value corresponding to the key of tp is i; wherein tp=tP;

[0154] The load balancing subunit sets the load balancing factor to a first value if yes; if no, sets the load balancing factor to a second value which is less than the first value; calculates the sleep duration based on the set load balancing factor and the resource utilization rate of the CDN edge node i, and performs sleep for the sleep duration; after the sleep ends, executes the setting subunit.

[0155] Optionally, the sleep duration T'=(T×r)×F; wherein T is the default sleep duration, r is the resource utilization rate, and F is the set load balancing factor;

[0156] The resource utilization rate r=(h / MA)+(d / D); wherein MA is the total memory of CDN edge node i, h is the used memory of CDN edge node i, D is the total external memory of CDN edge node i, and d is the used external memory of CDN edge node i.

[0157] Optionally, after the storage unit 320, the method further includes:

[0158] The isolation unit stores the logs in the log list of the log data structure to different storage devices according to a preset isolation rule after the domain name fields of the logs on all CDN edge nodes are stored in the tree-shaped log data structure;

[0159] The preset isolation rules include:

[0160] For logs that do not care about log integrity, store them on the local mechanical disk of the management node;

[0161] Logs that are concerned about log integrity and can tolerate short-term failures of the log service are stored on disks mounted on redundant arrays of disks on the management node.

[0162] Logs that are concerned about log integrity and cannot tolerate short-term failures of the log service are stored in the external distributed storage corresponding to the edge cluster.

[0163] Optionally, the different storage devices correspond to different root paths, and the root path of the storage device corresponding to the log configuration in the log list is configured with a path data structure of a key-value pair; wherein the key of the key-value pair is the domain name of the log, and the value is the root path.

[0164] Optionally, the log data structure provides an add instruction and a flush instruction;

[0165] The storage unit 320 is further used to call the add instruction provided by the log data structure to send the domain name field and the corresponding log to the log data structure, and the log data structure uses the domain name field as a classification dimension to store the domain name field and the corresponding log;

[0166] The isolation unit is further used to call the Flush instruction provided by the log data structure, and the Flush instruction does not carry any parameters. The log data structure traverses all domain name fields composed of first-level nodes, second-level nodes and third-level nodes, and stores the logs in the log list associated with the third-level node corresponding to each domain name field in different storage devices according to the preset isolation rules; and after all log lists are stored, all log lists are cleared.

[0167] Optionally, the log data structure also provides a Length instruction; the isolation unit also includes calling the Length instruction provided by the log data structure, and the Length instruction carries the domain name field, and the log data structure queries the list length of the log list associated with the third-level node corresponding to the domain name field in response to the Length instruction; when the list length reaches a preset length, calling the Flush instruction provided by the log data structure, and the Flush instruction carries the domain name field, and the log data structure stores the logs in the log list associated with the third-level node corresponding to the domain name field to different storage devices according to preset isolation rules; and, after the storage is completed, the log list is stored.

[0168] Optionally, the management node generates a local file whose file name contains t;

[0169] After the reading unit 310, it also includes:

[0170] A deleting unit deletes a local file whose file name contains t; and sends a del instruction with a key of t to the key-value pair storage service to delete a key-value pair with a key of t and a value of i set in the key-value pair storage service.

[0171] Optionally, before the reading unit 310, the method further includes:

[0172] The checking unit checks whether there is a local file whose file name contains t in the local file;

[0173] If it exists, the reading unit 310 further reads the log file whose file name contains t in the CDN edge node; the CDN edge node divides the local log into several log files based on the log collection cycle, and each log file contains the election time point t of each log collection cycle.

[0174] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0175] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0176] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. Ordinary technicians in this field can understand and implement it without paying creative work.

[0177] above Figure 5 The internal functional modules and structural schematic diagram of the log management device are described. Its actual execution subject can be an electronic device, including:

[0178] processor;

[0179] a memory for storing processor-executable instructions;

[0180] The processor is configured to execute any one of the above-mentioned log management method embodiments.

[0181] In the above-mentioned embodiment of the electronic device, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can be any conventional processor, etc., and the aforementioned memory can be a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk or a solid-state drive. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.

[0182] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the electronic device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0183] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention disclosed herein. The specification is intended to cover any variations, uses, or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not disclosed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0184] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

Claims

1. A log management method, characterized in that: Applied to a management node elected from an edge cluster consisting of multiple CDN edge nodes, the management node performs the following steps to process logs on each CDN edge node: Read the log stored in the CDN edge node, and extract the domain name field from the log; Taking the domain name field as a classification dimension, the domain name field and the corresponding log are stored in a tree-shaped log data structure; wherein the log data structure is composed of a primary node, a secondary node under the primary node, a tertiary node under the secondary node, and a log list associated with the tertiary node, the primary node is used to store the top-level domain name in the domain name field, the secondary node is used to store the secondary domain name in the domain name field, the tertiary node is used to store the remaining content in the domain name field except the top-level domain name and the secondary domain name, and the log list is used to store the log corresponding to the domain name field; The management node is selected from the multiple CDN edge nodes in the following manner: CDN edge node i calculates m=t mod P, where i is the sequence number of the CDN edge node, m is the remainder, t is the current time point, and P is the log collection period; When m is 0, a get instruction with the key tp is sent to the key-value pair storage service corresponding to the edge cluster to query whether the key tp is set in the key-value pair storage service, and the value corresponding to the key tp is i; wherein tp=tP; If yes, set the load balancing factor to a first value; if no, set the load balancing factor to a second value which is smaller than the first value; The sleep duration is calculated based on the set load balancing factor and the resource utilization rate of the CDN edge node i, and the sleep duration is performed; wherein the sleep duration T'=(T×r)×F; T is the default sleep duration, r is the resource utilization rate, and F is the set load balancing factor; the resource utilization rate r=(h / MA)+(d / D); MA is the total memory of the CDN edge node i, h is the used memory of the CDN edge node i, D is the total external memory of the CDN edge node i, and d is the used external memory of the CDN edge node i; After the sleep ends, a set instruction with a key of t and a value of i is sent to the key-value pair storage service corresponding to the edge cluster, and the key-value pair storage service sets the CDN edge node i corresponding to the first received set instruction as the management node.

2. The method according to claim 1, characterized in that: After storing the domain name field in the tree-shaped log data structure, the method further includes: After the domain name fields of the logs on all CDN edge nodes are stored in the tree-shaped log data structure, the logs in the log list of the log data structure are stored in different storage devices according to the preset isolation rules; The preset isolation rules include: For logs that do not care about log integrity, store them on the local mechanical disk of the management node; Logs that are concerned about log integrity and can tolerate short-term failures of the log service are stored on disks mounted on redundant arrays of disks on the management node. Logs that are concerned about log integrity and cannot tolerate short-term failures of the log service are stored in the external distributed storage corresponding to the edge cluster.

3. The method according to claim 2, characterized in that The different storage devices correspond to different root paths, and the root path of the storage device corresponding to the log configuration in the log list is configured with a path data structure of a key-value pair; wherein the key of the key-value pair is the domain name of the log, and the value is the root path.

4. The method according to claim 2, characterized in that: The log data structure provides an add instruction and a flush instruction; The domain name field is used as a classification dimension, and the domain name field and the corresponding log are stored in a tree-shaped log data structure, including: Calling the add instruction provided by the log data structure to send the domain name field and the corresponding log to the log data structure, and the log data structure uses the domain name field as a classification dimension to store the domain name field and the corresponding log; The storing the logs in the log list of the log data structure to different storage devices according to the preset isolation rule includes: Calling the Flush instruction provided by the log data structure, wherein the Flush instruction does not carry any parameters, the log data structure traverses all domain name fields consisting of the first-level nodes, the second-level nodes, and the third-level nodes, and stores the logs in the log list associated with the third-level node corresponding to each domain name field to different storage devices according to the preset isolation rule; After all log lists are stored, clear all log lists.

5. The method according to claim 4, characterized in that The log data structure also provides a Length instruction; after storing the domain name field and the corresponding log into the tree-shaped log data structure, it also includes: Calling the Length instruction provided by the log data structure, wherein the Length instruction carries the domain name field, and the log data structure queries the list length of the log list associated with the third-level node corresponding to the domain name field in response to the Length instruction; When the length of the list reaches a preset length, the Flush instruction provided by the log data structure is called, and the Flush instruction carries the domain name field, and the log data structure stores the logs in the log list associated with the third-level node corresponding to the domain name field to different storage devices according to the preset isolation rule; and, after the storage is completed, the log list is stored.

6. The method according to claim 1, characterized in that The management node generates a local file whose file name contains t; The management node reads the logs stored in all CDN edge nodes and stores the domain name fields extracted from all logs and the corresponding logs in the log data structure, and then deletes the local files whose file names contain t; And, sending a del instruction with a key of t to the key-value pair storage service to delete the key-value pair with a key of t and a value of i set in the key-value pair storage service.

7. The method according to claim 6, characterized in that Before reading the logs stored in the CDN edge node, it also includes: Check whether there is a local file whose file name contains t in the local file; The reading of the logs stored in the CDN edge node includes: If it exists, read the log file whose file name contains t in the CDN edge node; the CDN edge node divides the local log into several log files based on the log collection cycle, and each log file contains the election time point t of each log collection cycle.

8. A log management device, characterized in that: Applied to a management node elected from an edge cluster consisting of multiple CDN edge nodes, the management node executes the following units to process logs on each CDN edge node: A reading unit, reading a log stored in a CDN edge node, and extracting a domain name field from the log; A storage unit, taking the domain name field as a classification dimension, stores the domain name field and the corresponding log into a tree-shaped log data structure; wherein the log data structure is composed of a primary node, a secondary node under the primary node, a third-level node under the second-level node, and a log list associated with the third-level node, the primary node is used to store the top-level domain name in the domain name field, the second-level node is used to store the second-level domain name in the domain name field, the third-level node is used to store the remaining content in the domain name field except the top-level domain name and the second-level domain name, and the log list is used to store the log corresponding to the domain name field; The management node is elected from the multiple CDN edge nodes by the following election unit, and the election unit further includes: The calculation subunit, CDN edge node i calculates m=t mod P, where i is the sequence number of the CDN edge node, m is the remainder, t is the current time point, and P is the log collection period; The query subunit, when m is 0, sends a get instruction with a key of tp to the key-value pair storage service corresponding to the edge cluster, and queries whether the key of tp is set in the key-value pair storage service, and the value corresponding to the key of tp is i; wherein tp=tP; The load balancing subunit, if yes, sets the load balancing factor to a first value; if no, sets the load balancing factor to a second value less than the first value; calculates the sleep duration based on the set load balancing factor and the resource utilization rate of the CDN edge node i, and performs sleep for the sleep duration; wherein the sleep duration T'=(T×r)×F; T is the default sleep duration, r is the resource utilization rate, and F is the set load balancing factor; the resource utilization rate r=(h / MA)+(d / D); MA is the total memory of the CDN edge node i, h is the used memory of the CDN edge node i, D is the total external memory of the CDN edge node i, and d is the used external memory of the CDN edge node i; The setting subunit sends a set instruction with a key of t and a value of i to a key-value pair storage service corresponding to the edge cluster after the sleep ends, and the key-value pair storage service sets the CDN edge node i corresponding to the first received set instruction as a management node.

9. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • XML (Extensible Markup Language)-based log management method and system

    CN104778189A

  • Log processing method and device

    CN108234233A

  • Data backup method and device and readable storage medium

    CN111045869A

  • Log real-time attribution processing method, device and platform

    CN112286895A

  • CDN (Content Delivery Network) log statistical method and device and electronic equipment

    CN114443606A