File access method of distributed cache system, medium, equipment and program product
By dispersing the metadata information and file data in the distributed cache system, the metadata server is overloaded and node cache pressure is solved. Improved system performance.
Patent Information
- Application Number
- CN202411163120.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-11-15
AI Technical Summary
The existing distributed cache systems have performance bottlenecks in both tree structures and central structures. The metadata server is overloaded and the number of network requests increases, resulting in high file read delays.
By using multiple client nodes as the first service nodes of different files in the distributed cache system, each node maintains metadata information and caches target files through the second service node to avoid the concentration of metadata information in the metadata server. Reduce network IO requests.
It reduces the load of the metadata server, avoids excessive node cache pressure, reduces network IO requests, and improves the performance of the distributed cache system.
Smart Images

Figure CN118972452A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a file access method, medium, device and program product of a distributed cache system. Background Art
[0002] For distributed cache systems, a tree structure or a centralized structure can generally be used. In a tree structure, all nodes need to request files through the root node of the tree structure and the child nodes adjacent to the root node, which causes the root node and its adjacent child nodes to become the performance bottleneck of the distributed cache system. In addition, each node needs to cache file data as much as possible, which puts a lot of cache pressure on the node. In a centralized structure, a metadata server is required to maintain metadata information about which node all files are cached on. When a new cache is added or evicted, each node needs to synchronize the update information to the metadata server, resulting in an increase in the load on the metadata server. In addition, each node needs to access the metadata server first when accessing a file, which increases the number of network requests and increases the latency of file reading.
[0003] Therefore, no matter whether the distributed cache system adopts a tree structure or a centralized structure, it will have different disadvantages, and it is urgent to design a different file access method. Summary of the invention
[0004] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In a first aspect, the present disclosure provides a file access method of a distributed cache system, comprising: In response to an access request for a target file, metadata information of the target file is read from a first service node of the target file, the metadata information being used to indicate a cache path of the target file, the first service node of the target file being any client node in a distributed cache system, and a plurality of client nodes in the distributed cache system being used as first service nodes for different files respectively, and one first service node being used to maintain metadata information of at least one file; According to the metadata information, a second service node for caching the target file is accessed, and the target file is read from the second service node, where the second service node is any client node in the distributed cache system.
[0006] In a second aspect, the present disclosure provides a file access device of a distributed cache system, comprising: A first reading module is configured to read metadata information of a target file from a first service node of the target file in response to an access request for the target file, wherein the metadata information is used to indicate a cache path of the target file, the first service node of the target file is any client node in a distributed cache system, and a plurality of client nodes in the distributed cache system are respectively used as first service nodes for different files, and one first service node is used to maintain metadata information of at least one file; The second reading module is configured to access a second service node for caching the target file according to the metadata information, and read the target file from the second service node, where the second service node is any client node in the distributed cache system.
[0007] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect.
[0008] In a fourth aspect, the present disclosure provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect.
[0009] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which implements the steps of the method described in the first aspect when executed by a processor.
[0010] Through the above technical solution, by using multiple client nodes in the distributed cache system as the first service nodes for different files respectively, and using the first service node to maintain the metadata information of at least one file and caching the target file through the second service node, when any node accesses the target file, the metadata information of the target file is read from the first service node corresponding to the target file, and according to the metadata information, the second service node is accessed, and the target file is read from the second service node, it is possible to avoid centrally maintaining the metadata information of all files in the metadata server, but to disperse and store the metadata information of different files in different first service nodes, thereby avoiding the metadata server from becoming the performance bottleneck of the distributed cache system. Moreover, by caching different files through different second service nodes, it is also possible to avoid excessive cache pressure on a certain node in the distributed cache system. In addition, it is also possible to reduce the number of network IO requests and improve the performance of the distributed cache system.
[0011] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 The invention is a flowchart of a file access method of a distributed cache system according to some embodiments.
[0013] Figure 2 is a schematic diagram showing accessing a file according to some embodiments.
[0014] Figure 3 is a schematic diagram showing accessing a metadata server according to some embodiments.
[0015] Figure 4 The figure is a schematic diagram showing the structure of a file access device of a distributed cache system according to an exemplary embodiment.
[0016] Figure 5 It is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0017] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0018] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0019] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0020] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0021] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0022] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0023] Figure 1 FIG. 1 is a flowchart of a file access method of a distributed cache system according to some embodiments. Figure 1 As shown, the embodiment of the present disclosure provides a file access method of a distributed cache system, which can be executed by an electronic device, specifically, by a file access device of a distributed cache system, which can be implemented by software and / or hardware and configured in an electronic device. It should be noted that the electronic device can be a node in the distributed cache system, including but not limited to a client node. Figure 1 As shown, the method may include the following steps.
[0024] In step 110, in response to an access request for a target file, metadata information of the target file is read from a first service node of the target file, the metadata information is used to indicate a cache path of the target file, the first service node of the target file is any client node in a distributed cache system, and multiple client nodes in the distributed cache system are respectively used as first service nodes for different files, and a first service node is used to maintain metadata information of at least one file.
[0025] Here, in the distributed cache system, each file is cached in the second service node, and the first service node is used to maintain the metadata information of at least one file, that is, the first service node maintains the metadata information of the file that the first service node is responsible for. In other words, in the distributed cache system, all nodes with the role of the first service node are responsible for maintaining the metadata information of one or more files that they are responsible for, so that the metadata information of all files is dispersed on each first service node. For example, the first service node can maintain the metadata information of the target file.
[0026] The metadata information is used to indicate the cache path of the target file, and the cache path points to the second service node where the target file is located. For example, the metadata information is used to describe in which second service node or nodes the file is cached. That is to say, in the distributed cache system, different files are jointly maintained by the first service node and the second service node corresponding to the file.
[0027] It should be noted that multiple client nodes in the distributed cache system are used as first service nodes for different files. That is, metadata information corresponding to different files can be maintained by at least one first service node. Moreover, data corresponding to the files are cached by at least one second service node. That is, metadata information of different files is dispersedly stored in different first service nodes in the distributed cache system, and different files are dispersedly cached in different second service nodes in the distributed cache system.
[0028] In the embodiment of the present disclosure, both the first service node and the second service node may be client nodes selected from the distributed cache system. At least one client node may be selected from the client nodes of the distributed cache system as the first service node for maintaining metadata information of the file, and at least one client node may be selected from the client nodes of the distributed cache system as the second service node for caching the file.
[0029] It should be understood that the client node in the distributed cache system does not necessarily refer to the terminal device. There may be multiple levels / layers of nodes between the source data server and the terminal device. For each node on the entire data link, the data source node of the node is the data server of the node, and the node can be called the client node of the data server. For example, terminal device A obtains data from edge node B, edge node B obtains data from backbone node C, and backbone node C obtains data from data storage node D in the computer room. Correspondingly, on this link, terminal device A is the client node of edge node B, edge node B is the server of terminal device A, edge node B is the client node of backbone node C, backbone node C is the server of edge node B, backbone node C is the client node of data storage node D, and data storage node D is the server of backbone node C.
[0030] That is to say, the role of each node in the distributed cache system may be different in different scenarios, and may be a client role or a server role.
[0031] When any node in the distributed cache system accesses a target file, the node accesses a first service node corresponding to the target file, and reads metadata information of the target file from the first service node.
[0032] It is worth noting that by maintaining the metadata information of the file through the first service node, it is possible to avoid the metadata server of the distributed cache system maintaining the metadata information of all files, thereby preventing the metadata server from becoming the performance bottleneck of the distributed cache system. Moreover, by caching different files through different second service nodes, it is also possible to avoid excessive cache pressure on a certain node.
[0033] In step 120, according to the metadata information, a second service node for caching the target file is accessed, and the target file is read from the second service node.
[0034] Here, the second service node is any client node in the distributed cache system. Since the second service node is used to actually cache the target file, after the electronic device obtains the metadata information of the target file from the first service node, it accesses the second service node based on the metadata information and reads the target file from the second service node.
[0035] In the disclosed embodiment, when accessing a target file, each node in the distributed cache system first accesses the first service node corresponding to the target file, obtains metadata information of the target file from the first service node, then accesses the corresponding second service node through the metadata information, and reads the target file from the cache of the second service node.
[0036] That is, when a node in the distributed cache system needs to access a file, the node first accesses the first service node corresponding to the file, and the first service node tells the node to access the second service node to read the file.
[0037] It is worth noting that when the electronic device accesses the target file for the first time, the target file can be accessed through the above steps 110 to 120. When the electronic device accesses the same target file for the second time or later, since the electronic device has obtained the metadata information of the target file, the electronic device can directly execute step 120 to read the target file from the second service node without obtaining the metadata information of the target file from the first service node.
[0038] In some embodiments, in response to a non-first access request for a target file, a second service node corresponding to the metadata information is accessed according to the metadata information, and the target file is read from the second service node.
[0039] That is to say, when the node that is going to access the target file in the distributed cache system knows the metadata information of the target file, in the subsequent reading operation on the target file, it can directly initiate an access request to the second service node corresponding to the metadata information of the target file through the recorded metadata information of the target file to read the target file. This not only reduces the number of network IO (Input / Output) requests, but also the electronic device only needs one network IO request to read the target file in the optimal case, which greatly improves the performance of the distributed cache system.
[0040] Thus, by using multiple client nodes in the distributed cache system as the first service nodes for different files, and using the first service node to maintain the metadata information of at least one file and caching the target file through the second service node, when any node accesses the target file, the metadata information of the target file is read from the first service node corresponding to the target file, and the second service node is accessed according to the metadata information, and the target file is read from the second service node. It is possible to avoid centrally maintaining the metadata information of all files in the metadata server, and instead store the metadata information of different files in different first service nodes in a dispersed manner, thereby avoiding the metadata server from becoming a performance bottleneck of the distributed cache system. Moreover, by caching different files through different second service nodes, it is also possible to avoid excessive cache pressure on a certain node in the distributed cache system. In addition, it is also possible to reduce the number of network IO requests and improve the performance of the distributed cache system.
[0041] In some feasible implementations, the target file is divided into multiple segments of segmented data, and the multiple segments of segmented data are cached in multiple second service nodes in a dispersed manner, and the metadata information is used to indicate the cache path corresponding to each segment of segmented data.
[0042] Here, the first service node may split the target file into at least one logical segment data according to the preset segment data length. Exemplarily, the preset segment data length may be 16MB. That is, the target file is split according to 16MB as one segment data. Of course, the value of the preset segment data length may be set according to actual conditions, such as 20MB.
[0043] For each segmented data, the first service node arranges at least one client node in the distributed cache system as the second service node, and instructs at least one second service node to be responsible for caching all the data of the segmented data. The first service node maintains the metadata information of each segmented data to inform the node accessing the file of the cache path of the required segmented data.
[0044] Exemplarily, the first service node may select at least one client node from the client nodes of the distributed cache system as the second service node through a load balancing strategy, wherein the load balancing strategy may be to select the client node with the smallest current load as the second service node or to select the client node with the largest free capacity as the second service node.
[0045] Of course, in other examples, a client node that has recently joined and / or is expected to have the longest active time may be selected from the client nodes of the distributed cache system as the second service node.
[0046] It should be understood that the first service node can select at least one client node from the client nodes maintained by the first service node as the second service node. The client node maintained by the first service node can be a client node that has requested metadata information from the first service node. When the client node requests metadata information from the first service node, the first service node adds the client node to the node list maintained by the first service node. The first service node can select at least one client node from the node list as the second service node for caching segmented data, and instruct each second service node to cache its corresponding segmented data.
[0047] Therefore, each first service node only needs to maintain the metadata information of each segmented data of the corresponding target file, which greatly reduces the amount and complexity of the metadata that needs to be maintained. Moreover, since the second service nodes where each segmented data is located are relatively fixed, the metadata information does not need to be updated frequently, unless the second service node that caches the segmented data fails / exits, or a new second service node joins the first service node, the metadata information needs to be updated. In addition, since the first service node maintains the metadata information of each segmented data, the first service node does not need to maintain where the data area where the file length changes is cached, nor does it need to frequently update the metadata information maintained by the first service node as new file data is cached or old file data is evicted.
[0048] Since the file is divided into at least one segmented data and cached in at least one second service node, each second service node only needs to cache the segmented data assigned to the second service node by the first service node, without having to cache all the data of the file, thereby greatly reducing the cache pressure of each node and avoiding the waste of storage resources caused by the same file being cached on multiple client nodes.
[0049] Accordingly, in step 120, the second service node for caching the segmented data of the target file may be accessed according to the metadata information, and the corresponding segmented data may be read from the second service node.
[0050] Here, the metadata information read may be metadata information of any segmented data, so that the electronic device can access the second service node for caching the segmented data of the target file through the metadata information to read the corresponding segmented data.
[0051] For example, when any client node in the distributed cache system needs to access at least one target segment data of a target file, the client node accesses the first service node corresponding to the target file, obtains metadata information of the target segment data, and then accesses the second service node that caches the target segment data through the metadata information to read the target segment data from the second service node.
[0052] It is worth noting that the target segmented data may be a segmented data in at least one segmented data obtained by splitting, or may be a sub-segment in the segmented data obtained by splitting.
[0053] In some embodiments, in step 120, a second service node for caching the target file may be accessed according to the metadata information, and the target file sent by the second service node may be received.
[0054] The second service node is used to read the target file from the source data server of the distributed cache system when the target file is not cached, cache the target file in the second service node, and send the target file to the node accessing the target file.
[0055] It is worth noting that when the second service node has cached the target file, it directly sends the target file to the first service node. When the target file is not cached, it reads the target file from the source data server, sends the target file to the node that reads the target file, and caches the target file in the second service node.
[0056] Of course, when the target file is cached in different second service nodes as segmented data, the second service node is used to send the target segmented data to the node that reads the target segmented data when the target segmented data has been cached, and to read the target segmented data from the source data server when the target segmented data has not been cached, and send the target segmented data to the node that reads the target segmented data, and cache the target segmented data in the second service node.
[0057] Exemplarily, the electronic device may send an access request for reading the target segmented data to the second service node corresponding to the metadata information of the target segmented data, and receive the target segmented data sent by the second service node in response to the access request.
[0058] The source data server is a server for storing original file data. When the second service node does not cache the target segmented data that the second service node is responsible for caching, the second service node performs a back-to-source operation to read the target segmented data from the source data server. Then, the second service node returns the target segmented data to the node that sent the access request, and caches the target segmented data locally in the second service node.
[0059] At this time, the second service node has cached the target segment data. When the target segment data is read again, the second service node directly returns the target segment data to the node that reads the target segment data without having to read the target segment data from the source data server.
[0060] It should be noted that when the second service node designated by the first service node fails or exits, the client node cannot read the target segmented data from the second service node. Accordingly, the client node can query the metadata information of the target segmented data from the first service node again, and the first service node can replace the second service node corresponding to the target segmented data, so that the client node can access the new second service node through the new metadata information and read the target segmented data.
[0061] Therefore, through the above implementation, each node in the distributed cache system no longer caches the file data it reads, but splits the file into at least one segmented data, and at least one second service node caches the data of the segmented data. When other nodes need to read the file, they read the file data from the second service node that caches the segmented data, which greatly reduces the pressure on the cache space of each node and can also avoid the data of the same file from existing in multiple nodes in the distributed cache system, avoiding the waste of cache space. Moreover, by storing files in segments, the metadata information of the files maintained by each first service node is the metadata information of each segmented data, which greatly reduces the amount and complexity of the metadata that needs to be maintained and avoids frequent updates of metadata information.
[0062] Figure 2 FIG. 1 is a schematic diagram of accessing a file according to some embodiments. Figure 2As shown, assuming that node C in the distributed cache system needs to read the file data of the target segmented data [20MB, 24MB], the metadata information of each segmented data of the target file is maintained in the first service node A, assuming that [20MB, 24MB] is cached in the second service node B, then node C asks the first service node A for the metadata information of [20MB, 24MB], and the first service node A returns the metadata information of [20MB, 24MB] to node C to inform that the target segmented data [20MB, 24MB] is cached in the second service node B. Node C requests the second service node B to read the target segmented data according to the metadata information. If the second service node B does not cache the target segmented data, the second service node B reads the target segmented data from the source data server, returns the read target segmented data to node C, and fills the target segmented data into the local cache of the second service node B. Subsequently, if node D in the distributed cache system requests the second service node B to read the target segment data of [20MB, 24MB], since the second service node B has cached the target segment data of [20MB, 24MB], the second service node B directly returns the target segment data to node D. It should be noted that node D has already recorded the metadata information that the target segment data of [20MB, 24MB] is cached in the second service node B, so node D does not need to read the metadata information from the first service node A again.
[0063] In some feasible implementations, in step 110, in response to the first access request for the target file, the node information of the first service node of the target file is obtained from the metadata server of the distributed cache system, the first service node is accessed based on the node information, and the metadata information of the target file is read from the first service node.
[0064] Here, each client node in the distributed cache system needs to access the metadata server of the distributed cache system when accessing the target file for the first time. The metadata server is used to maintain the client nodes that access the target file, determine the first service node corresponding to the target file from the maintained client nodes, and send the node information of the first service node to the maintained client nodes.
[0065] That is, the metadata server will record the node information corresponding to all client nodes accessing the same file in the maintained client list, and the metadata server will select at least one client node from the maintained client list as the first service node, so that the first service node maintains the metadata information of the file. In addition, the metadata server sends the node information of the first service node to the client nodes in the maintained client list, so as to inform all client nodes in the client list to access the file through the first service node.
[0066] Figure 3 FIG. 1 is a schematic diagram showing accessing a metadata server according to some embodiments. Figure 3 As shown, assuming that A, B, C, and D are client nodes accessing the same target file, A, B, C, and D are recorded in the client list of the metadata server. The metadata server selects the first client node A from A, B, C, and D as the first service node corresponding to all client nodes accessing the target file, and sends the node information of A to all client nodes in the client list to notify all client nodes in the client list that the first service node corresponding to the target file is A. Afterwards, when client nodes A, B, C, and D need to read the target file, they all obtain the metadata information of the target file by accessing client node A.
[0067] When a new client node accesses the target file, the new client node will also be added to the client list of the metadata server. The metadata server notifies the new client node that the first service node corresponding to the target file is A, so that the new client node can obtain the metadata information of the target file by accessing client node A.
[0068] It is worth noting that when a client node in the distributed cache system accesses a file for the first time, the client node accesses the metadata server, the metadata server records all client nodes accessing the same file, and determines the first service node corresponding to the file from all recorded client nodes.
[0069] Exemplarily, the first client node among all client nodes that accesses the file can be used as the first service node. Then, the metadata server notifies all recorded client nodes of the node information of the first service node. When the client node needs to access the file, the client node accesses the corresponding first service node according to the node information and obtains the metadata information of the file from the first service node. Then, the client node accesses the corresponding second service node according to the metadata information and obtains the file from the second service node.
[0070] When a client node in a distributed cache system does not access a file for the first time, since the client node has obtained the metadata information of the file when it first accessed the file, the client node can directly access the corresponding second service node through the recorded metadata information to obtain the file from the second service node.
[0071] Therefore, through the above implementation, the client node in the distributed cache system only needs to access the metadata server when reading file data for the first time, instead of accessing the metadata server every time, so that the number of network IO requests can be greatly reduced. In the best case, only one network IO request is required to access the file, so that the performance of the distributed cache system can be greatly improved.
[0072] In some achievable implementations, the first service node has a backup node, the backup node has metadata information of at least one file maintained by the first service node, and the backup node is used to take over the working logic of the first service node when a node abnormality occurs in the first service node. Accordingly, when a node abnormality occurs in the first service node, the metadata information of the target file is read from the backup node corresponding to the first service node.
[0073] Here, each first service node in the distributed cache system may have at least one backup node. Exemplarily, all client nodes accessing the same file except the first service node may be used as backup nodes of the first service node. For example, A, B, C, and D are client nodes accessing the same target file, and A is the first service node corresponding to all client nodes accessing the target file, then one or more of B, C, and D may be used as backup nodes of the first service node.
[0074] The backup node of the first service node, like the first service node, also maintains metadata information of at least one file maintained by the first service node. Exemplarily, the first service node can synchronize the metadata information of the file maintained by the first service node to the backup node of the first service node.
[0075] When a node abnormality occurs in the first service node, the backup node of the first service node takes over the working logic of the first service node. The node abnormality may refer to the first service node exiting the distributed cache system or the first service node failing.
[0076] In the case where the first service node exits, the first service node can designate a target backup node among the backup nodes as a successor backup node before exiting to take over the working logic of the first service node. That is, when the target backup node serves as the new first service node and accesses the metadata information of the file maintained by the new first service node, the client node accesses the new first service node to obtain the metadata information.
[0077] When the first service node fails, the client node maintained by the first service node can directly request metadata information from the backup node according to the order of the backup nodes. When the backup node receives the request, the role of the backup node is converted to the first service node and reports to the metadata server.
[0078] It is worth noting that the first service node or the metadata server can notify all associated client nodes of the relevant information of the backup node of the first service node. When the first service node fails, the client node can directly request metadata information from the backup node.
[0079] It should be understood that when a backup node is converted to a first service node, the metadata server or the new first service node can select a client node from the maintained client nodes to upgrade to a backup node. When the first service node has no backup node, if an abnormality occurs in the first service node, the client node can request the metadata server, and the metadata server determines a new first service node.
[0080] Therefore, through the backup node, when a node abnormality occurs in the first service node, the client node in the distributed cache system can also access the file through the backup node.
[0081] In some achievable implementations, the first service node is used to determine a third service node from the client node when the load of the first service node is greater than a first preset threshold, and report the node information of the third service node to the metadata server, and the third service node has the same working logic as the first service node. The metadata server is used to, when receiving an access request from a new client node to the first service node, divert the access request to the third service node.
[0082] Here, the load of the first service node being greater than the first preset threshold may mean that the number of access requests received by the first service node is greater than the first preset threshold. When the load of the first service node is greater than the first preset threshold, the first service node may become a performance bottleneck of the distributed cache system. Therefore, the first service node may determine a third service node from the client nodes of the distributed cache system. The third service node has the same working logic as the first service node. In other words, the third service node also has metadata information of files that are consistent with those of the first service node.
[0083] The first service node reports the node information of the third service node to the metadata server, and the metadata server diverts the access request of the new client node to the first service node to the third service node according to the node information of the third service node.
[0084] Exemplarily, a client node whose load is less than a third preset threshold value among the client nodes of the distributed cache system may be determined as the third service node. Of course, a client node with the smallest load among the client nodes of the distributed cache system may also be determined as the third service node. In other examples, the third service node may also be selected from the backup nodes of the first service node.
[0085] When a new client node accesses a target file for the first time, the new client node needs to access the metadata server. The metadata server can then inform the new client node of the node information of the third service node, so that the new client node can access the third service node to obtain the corresponding metadata information, thereby diverting the access request originally intended for the first service node to the third service node, thereby achieving load balancing.
[0086] It should be noted that the new client node may refer to the client node corresponding to the access request for accessing the target file received by the metadata server after the third service node is determined. For example, before the third service node is determined, client nodes A, B, and C access the metadata server to obtain metadata information, and after the third service node is determined, client nodes D and E access the metadata server, and client nodes D and E are new client nodes. In other words, client nodes A, B, and C read the target file by accessing the first service node, and client nodes D and E read the target file by accessing the third service node.
[0087] Therefore, through the above implementation, the distributed cache system can achieve load balancing and avoid a certain first service node becoming a performance bottleneck of the distributed cache system.
[0088] In some feasible implementations, the first service node is used to determine a fourth service node for caching files corresponding to the second service node from the client nodes when the load of the second service node is greater than a second preset threshold, and to divert access requests from new client nodes to the second service node to the fourth service node.
[0089] Here, the load of the second service node being greater than the second preset threshold may mean that the number of access requests received by the second service node is greater than the second preset threshold. When the load of the second service node is greater than the second preset threshold, the second service node may become a performance bottleneck of the distributed cache system. Therefore, the first service node may determine the fourth service node for caching the file corresponding to the second service node from the client nodes of the distributed cache system, and divert the access request of the new client node to the second service node to the fourth service node, so as to reduce the load of the second service node, thereby achieving load balancing.
[0090] Exemplarily, a client node with a load less than a fourth preset threshold among the client nodes of the distributed cache system may be determined as the fourth service node. Of course, a client node with the smallest load among the client nodes of the distributed cache system may also be determined as the fourth service node.
[0091] It is worth noting that the determined fourth service node is used to cache the file or segmented data cached by the second service node. The first service node will record the corresponding metadata information. When a new client node needs to access a file that is managed by the first service node, the first service node sends metadata information indicating that the file is cached in the fourth service node to the new client node, so that the new client node can access the fourth service node through the metadata information to read the file.
[0092] It should be noted that the new client node refers to the client node corresponding to the access request initiated by the different client nodes received by the first service node after the fourth service node is determined. For example, before the fourth service node is determined, client nodes A, B, and C access the first service node, and after the fourth service node is determined, client nodes A, D, and E access the first service node, then client nodes D and E are new client nodes. In other words, client nodes A, B, and C read files by accessing the second service node, and client nodes D and E read files by accessing the fourth service node.
[0093] Therefore, through the above implementation, the distributed cache system can achieve load balancing and avoid a certain second service node becoming a performance bottleneck of the distributed cache system.
[0094] In an embodiment of the present disclosure, a distributed cache system is provided, the distributed cache system comprising: A first service node is used to maintain metadata information of at least one file, wherein the metadata information is used to indicate a cache path of the target file, the first service node of the target file is any client node in the distributed cache system, and multiple client nodes in the distributed cache system are respectively used as first service nodes for different files; A second service node, used for caching the target file, wherein the second service node is any client node in the distributed cache system; The client node is used to respond to an access request for a target file, read metadata information of the target file from a first service node of the target file, and access a second service node for caching the target file based on the metadata information, and read the target file from the second service node.
[0095] Optionally, the target file is divided into multiple segments of segmented data, and the multiple segments of segmented data are cached in multiple second service nodes in a dispersed manner, and the metadata information is used to indicate the cache paths corresponding to each segment of the segmented data; The client node is used to access a second service node for caching the segmented data of the target file according to the metadata information, and read the corresponding segmented data from the second service node.
[0096] Optionally, the distributed cache system further comprises a metadata server, which is used to maintain a client node accessing the target file, determine a first service node corresponding to the target file from the maintained client nodes, and send node information of the first service node to the maintained client node; The client node is used to: In response to a first access request for a target file, obtaining node information of a first service node of the target file from a metadata server of the distributed cache system; The first service node is accessed according to the node information, and metadata information of the target file is read from the first service node.
[0097] Optionally, the first service node is used to determine a third service node from the client node when the load of the first service node is greater than a first preset threshold, and report node information of the third service node to the metadata server, and the third service node has the same working logic as the first service node; The metadata server is used for, when receiving an access request from a new client node to the first service node, diverting the access request to the third service node.
[0098] Optionally, the second service node is used to read the target file from the source data server of the distributed cache system when the target file is not cached, cache the target file in the second service node, and send the target file to a node accessing the target file.
[0099] The client node is used to access a second service node for caching the target file according to the metadata information, and receive the target file sent by the second service node.
[0100] Optionally, the first service node has a backup node, the backup node has metadata information of at least one file maintained by the first service node, and the backup node is used to take over the working logic of the first service node when a node abnormality occurs in the first service node; The client node is used to read the metadata information of the target file from the backup node corresponding to the first service node when a node abnormality occurs in the first service node.
[0101] Optionally, the first service node is used to determine a fourth service node from the client nodes for caching files corresponding to the second service node when the load of the second service node is greater than a second preset threshold, and to divert access requests from new client nodes to the second service node to the fourth service node.
[0102] Figure 4 FIG. 1 is a schematic diagram showing a structure of a file access device of a distributed cache system according to an exemplary embodiment. Figure 4 As shown, the embodiment of the present disclosure provides a file access device 400 of a distributed cache system, and the file access device 400 of the distributed cache system includes: The first reading module 401 is configured to read metadata information of the target file from a first service node of the target file in response to an access request for the target file, wherein the metadata information is used to indicate a cache path of the target file, the first service node of the target file is any client node in the distributed cache system, and a plurality of client nodes in the distributed cache system are respectively used as first service nodes for different files, and one first service node is used to maintain metadata information of at least one file; The second reading module 402 is configured to access a second service node for caching the target file according to the metadata information, and read the target file from the second service node, where the second service node is any client node in the distributed cache system.
[0103] Optionally, the target file is divided into multiple segments of segmented data, and the multiple segments of segmented data are cached in multiple second service nodes in a dispersed manner, and the metadata information is used to indicate the cache paths corresponding to each segment of the segmented data; The second reading module 402 is specifically configured as follows: According to the metadata information, a second service node for caching the segmented data of the target file is accessed, and the corresponding segmented data is read from the second service node.
[0104] Optionally, the first reading module 401 is specifically configured as follows: In response to a first access request for a target file, obtaining node information of a first service node of the target file from a metadata server of the distributed cache system, wherein the metadata server is used to maintain client nodes accessing the target file, determine a first service node corresponding to the target file from the maintained client nodes, and send the node information of the first service node to the maintained client nodes; The first service node is accessed according to the node information, and metadata information of the target file is read from the first service node.
[0105] Optionally, the first service node is used to determine a third service node from the client node when the load of the first service node is greater than a first preset threshold, and report node information of the third service node to the metadata server, and the third service node has the same working logic as the first service node; The metadata server is used for, when receiving an access request from a new client node to the first service node, diverting the access request to the third service node.
[0106] Optionally, the second reading module 402 is specifically configured as follows: According to the metadata information, a second service node for caching the target file is accessed, and the target file sent by the second service node is received, wherein the second service node is used to read the target file from the source data server of the distributed cache system when the target file is not cached, cache the target file in the second service node, and send the target file to the node accessing the target file.
[0107] Optionally, the first service node has a backup node, the backup node has metadata information of at least one file maintained by the first service node, and the backup node is used to take over the working logic of the first service node when a node abnormality occurs in the first service node; The file access device 400 of the distributed cache system further includes: The third reading module is configured to read the metadata information of the target file from the backup node corresponding to the first service node when a node abnormality occurs in the first service node.
[0108] Optionally, the first service node is used to determine a fourth service node from the client nodes for caching files corresponding to the second service node when the load of the second service node is greater than a second preset threshold, and to divert access requests from new client nodes to the second service node to the fourth service node.
[0109] The logic of the method executed by each functional module in the file access device 400 of the above-mentioned distributed cache system can refer to the part of the method related to the above-mentioned embodiment, and will not be repeated here.
[0110] Reference below Figure 5 , which shows a schematic diagram of the structure of an electronic device (e.g., a client node in a distributed file system, which may be a terminal device) 500 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0111] like Figure 5 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 to a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0112] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0113] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0114] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0115] In some embodiments, the nodes in the distributed cache system can communicate using any currently known or future developed network protocol such as HTTP (HyperTextTransfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0116] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0117] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: in response to an access request for a target file, reads metadata information of the target file from the first service node of the target file, the metadata information is used to indicate a cache path of the target file, the first service node of the target file is any client node in a distributed cache system, and multiple client nodes in the distributed cache system are respectively used as first service nodes for different files, and one of the first service nodes is used to maintain metadata information of at least one file; according to the metadata information, accesses a second service node for caching the target file, and reads the target file from the second service node, the second service node is any client node in the distributed cache system.
[0118] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0119] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0120] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a module does not, in some cases, limit the module itself.
[0121] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0122] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0123] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0124] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0125] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims
1. A file access method for a distributed cache system, characterized in that: include: In response to an access request for a target file, metadata information of the target file is read from a first service node of the target file, the metadata information being used to indicate a cache path of the target file, the first service node of the target file being any client node in a distributed cache system, and a plurality of client nodes in the distributed cache system being used as first service nodes for different files respectively, and one first service node being used to maintain metadata information of at least one file; According to the metadata information, a second service node for caching the target file is accessed, and the target file is read from the second service node, where the second service node is any client node in the distributed cache system.
2. The method according to claim 1, characterized in that The target file is divided into multiple segments of segmented data, and the multiple segments of segmented data are cached in multiple second service nodes in a dispersed manner, and the metadata information is used to indicate the cache path corresponding to each segment of the segmented data; The step of accessing a second service node for caching the target file according to the metadata information, and reading the target file from the second service node includes: According to the metadata information, a second service node for caching the segmented data of the target file is accessed, and the corresponding segmented data is read from the second service node.
3. The method according to claim 1, characterized in that The step of reading metadata information of the target file from a first service node of the target file in response to an access request for the target file includes: In response to a first access request for a target file, obtaining node information of a first service node of the target file from a metadata server of the distributed cache system, wherein the metadata server is used to maintain client nodes accessing the target file, determine a first service node corresponding to the target file from the maintained client nodes, and send the node information of the first service node to the maintained client nodes; The first service node is accessed according to the node information, and metadata information of the target file is read from the first service node.
4. The method according to claim 3, characterized in that The first service node is used to determine a third service node from the client node when the load of the first service node is greater than a first preset threshold, and report node information of the third service node to the metadata server, wherein the third service node has the same working logic as the first service node; The metadata server is used for, when receiving an access request from a new client node to the first service node, diverting the access request to the third service node.
5. The method according to claim 1, characterized in that The step of accessing a second service node for caching the target file according to the metadata information, and reading the target file from the second service node includes: According to the metadata information, a second service node for caching the target file is accessed, and the target file sent by the second service node is received, wherein the second service node is used to read the target file from the source data server of the distributed cache system when the target file is not cached, cache the target file in the second service node, and send the target file to the node accessing the target file.
6. The method according to any one of claims 1 to 5, characterized in that The first service node has a backup node, the backup node has metadata information of at least one file maintained by the first service node, and the backup node is used to take over the working logic of the first service node when a node abnormality occurs in the first service node; The method further comprises: When a node exception occurs in the first service node, metadata information of the target file is read from a backup node corresponding to the first service node.
7. The method according to any one of claims 1 to 5, characterized in that The first service node is used to determine a fourth service node for caching files corresponding to the second service node from the client nodes when the load of the second service node is greater than a second preset threshold, and to divert access requests from new client nodes to the second service node to the fourth service node.
8. A file access device for a distributed cache system, characterized in that: include: A first reading module is configured to read metadata information of a target file from a first service node of the target file in response to an access request for the target file, wherein the metadata information is used to indicate a cache path of the target file, the first service node of the target file is any client node in a distributed cache system, and a plurality of client nodes in the distributed cache system are respectively used as first service nodes for different files, and one first service node is used to maintain metadata information of at least one file; The second reading module is configured to access a second service node for caching the target file according to the metadata information, and read the target file from the second service node, where the second service node is any client node in the distributed cache system.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Training system, training data access method and device, electronic equipment and medium
CN112839071A
Server cluster system and metadata access method and device
CN114827145A
File caching method and device based on distributed file system, terminal and medium
CN117453643A
Client caching method and system for parallel file system
CN117851363A
Cited By
File attribute processing method and device of distributed file system, equipment and medium
CN120803732A
