CN117615013B - File searching method, device, equipment and readable storage medium - Google Patents

File searching method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN117615013B
CN117615013B CN202410079748.9A CN202410079748A CN117615013B CN 117615013 B CN117615013 B CN 117615013B CN 202410079748 A CN202410079748 A CN 202410079748A CN 117615013 B CN117615013 B CN 117615013B
Authority
CN
China
Prior art keywords
cache
target file
file
node
shared storage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410079748.9A
Other languages
Chinese (zh)
Other versions
CN117615013A (en
Inventor
梁世龙
张吉祥
程行峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Youyun Technology Co ltd
Original Assignee
Hangzhou Youyun Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Youyun Technology Co ltd filed Critical Hangzhou Youyun Technology Co ltd
Priority to CN202410079748.9A priority Critical patent/CN117615013B/en
Publication of CN117615013A publication Critical patent/CN117615013A/en
Application granted granted Critical
Publication of CN117615013B publication Critical patent/CN117615013B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a file searching method, a device, equipment and a readable storage medium, which are characterized in that an edge node at least comprises a shared storage node and at least two cache nodes, and the shared storage node is arranged to store various cache files for sharing access and reading by all the cache nodes, so that when the number of the cache nodes changes, the cache files stored in the shared storage node cannot be responded, and the cache hit can be realized by requesting to acquire the cached files from the shared storage node; and for the cache file which receives the request but cannot hit the cache node and stores the target file in the shared storage node, the shared storage node is firstly requested to acquire the target file instead of directly executing the source-returning processing, so that the integral cache hit rate is improved, the number of times of source-returning processing of the cache node is reduced, the problem of disk capacity increase caused by repeated source-returning of the same resource is avoided, and the disk utilization rate is improved.

Description

File searching method, device, equipment and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a readable storage medium for searching a file.
Background
CDN (Content Delivery Network ) caching is a mechanism for caching a great amount of information of websites by using CDN edge nodes distributed in various places so as to reduce the load of a central node and improve the response speed of the websites. CDN edge nodes are physical servers forming a CDN network and are generally composed of a load balancing node and a plurality of cache nodes. The load balancing node is used for loading the user request to the corresponding cache node and returning a response result; the cache node is used for acquiring a file requested by a user from a cache file locally stored in the node, returning the file to the load balancing node, and executing source returning processing when the resource file requested by the user is not stored in the node locally so as to acquire the resource file from the CDN source server and respond to the user request.
In the process of distributing user requests to each cache node by the load balancing node, a hash algorithm is generally adopted to make user requests requesting the same resource fall into the same cache node. However, the number of cache nodes is considered in the hash calculation mode, when the number of cache nodes changes due to the problems of adding, deleting, replacing, node failure and the like of the nodes, user requests of the same resource can be redistributed to other cache nodes, so that the requested resource file can not be found in the newly distributed cache nodes, namely, the cache can not be hit, the cache hit rate is greatly reduced, the source returning request and the bandwidth consumption are increased, and the user experience is affected.
Disclosure of Invention
In view of the above, the present application provides a method, an apparatus, a device and a readable storage medium for searching files.
Specifically, the application is realized by the following technical scheme:
according to a first aspect of an embodiment of the present application, a file searching method is provided, which is applied to a cache node in a CDN edge node of a content delivery network, where the edge node includes at least two cache nodes and a shared storage node; each cache node shares access to the cache files stored in the shared storage node; the method comprises the following steps:
receiving an access request for requesting access to a target file;
under the condition that the present cache node caches the target file to the shared storage node, responding to the fact that the cache of the target file is not expired, and executing query response processing on the target file;
Under the condition that the target file is not cached to the shared storage node by the caching node, query response processing is executed for the target file;
Wherein the query response processing includes:
Requesting the shared storage node to acquire the target file; and under the condition that the target file is acquired, responding to the access request according to the target file in response to the fact that the cache of the target file is not expired.
Optionally, in response to the access request being sent to the local cache node by the client, after receiving the access request, the method further includes:
generating a corresponding hash value according to the access request;
according to a mapping relation between a preset hash value and a cache node, forwarding the access request to the cache node corresponding to the hash value under the condition that the cache node corresponding to the hash value is not the cache node;
and receiving a response result of the access request returned by the cache node corresponding to the hash value, and sending the response result to a sender of the access request.
Optionally, the cache node is provided with cache entry information; the cache table item information is used for recording the information of the cache file cached in the shared storage node by the cache node; after receiving the access request, the method further comprises:
Acquiring a file identifier of the target file according to the access request;
And if the target table item containing the file identifier does not exist in the cache table item information, determining that the target file is not cached by the cache node to the shared storage node.
Determining that the cache node has cached the target file to the shared storage node in response to the target entry in the cache entry information; determining whether the cache of the target file is out of date according to the effective time included in the target table item and the system time of the cache node; the valid time indicates a cache valid period of the target file.
Optionally, the shared storage node synchronously stores the valid time of the cache file when storing the cache file, wherein the valid time indicates the cache valid period of the cache file; in the case where the target file is not cached to the shared storage node, before performing a query response process for the target file, the method further includes:
Requesting the shared storage node for obtaining the effective time of the target file;
Under the condition that the effective time is received, responding to the condition that the effective time is larger than the system time of the cache node, and starting to execute the query response processing;
And executing the source return processing in the condition that the effective time is not acquired.
Optionally, in the case that the target file has been cached to the shared storage node, the method further comprises: performing a source-back process in response to determining that the cache of the target file has expired; the query response processing includes: and executing the source returning process under the condition that the target file is not acquired.
Optionally, in a case where the target file is not cached to the shared storage node, the query response processing includes: and executing the source returning process in the case that the target file is not acquired or in the case that the target file is acquired and the cache of the target file is expired.
Optionally, the source return processing includes:
Requesting the CDN source server to acquire the target file;
responding to receiving a target file returned by the CDN source server, acquiring the effective time of the target file, and storing the target file and the effective time into the shared storage node; the effective time indicates the cache effective period of the target file;
responding to the access request according to the received target file;
and updating the information of the cache file which is used for recording and cached in the shared storage in the cache node according to the effective time.
Optionally, in a case where the cache of the target file has expired, before performing the source-back processing, the method further includes:
accessing the target file in the shared storage node, and locking the target file;
in response to determining that the cache of the accessed target file is not expired, unlocking the target file, acquiring the target file and responding to the access request;
and in response to determining that the cache of the accessed target file has expired, performing an unlocking operation on the target file after the execution of the source-returning process is completed.
Optionally, in a case where the target file is not acquired, before performing the source-back processing, the method further includes:
sending a file creation request to the shared storage node; the file creation request is used for requesting to create the target file in the shared storage node;
after receiving an indication message indicating that creation is completed, accessing the target file, and locking the target file;
Responding to the read data in the target file, unlocking the target file, obtaining the target file and responding to the access request;
And responding to the fact that the data in the target file cannot be read, and performing unlocking operation on the target file after the source returning processing is completed.
According to a second aspect of the embodiments of the present application, there is provided a file searching apparatus applied to a cache node in an edge node of a content delivery network CDN, the edge node including at least two cache nodes and a shared storage node; each cache node shares access to the cache files stored in the shared storage node; the device comprises:
An access request receiving module for receiving an access request for requesting access to a target file;
The first response processing module is used for responding to the fact that the cache of the target file is not expired under the condition that the local cache node caches the target file to the shared storage node, and executing query response processing on the target file;
The second response processing module is used for executing query response processing on the target file under the condition that the target file is not cached to the shared storage node by the caching node;
Wherein the query response processing includes:
Requesting the shared storage node to acquire the target file; and under the condition that the target file is acquired, responding to the access request according to the target file in response to the fact that the cache of the target file is not expired.
Optionally, in response to the access request being sent to the local cache node by the client, after receiving the access request, the apparatus further includes:
generating a corresponding hash value according to the access request;
according to a mapping relation between a preset hash value and a cache node, forwarding the access request to the cache node corresponding to the hash value under the condition that the cache node corresponding to the hash value is not the cache node;
and receiving a response result of the access request returned by the cache node corresponding to the hash value, and sending the response result to a sender of the access request.
Optionally, the cache node is provided with cache entry information; the cache table item information is used for recording the information of the cache file cached in the shared storage node by the cache node; after receiving the access request, the apparatus further comprises:
Acquiring a file identifier of the target file according to the access request;
And if the target table item containing the file identifier does not exist in the cache table item information, determining that the target file is not cached by the cache node to the shared storage node.
Determining that the cache node has cached the target file to the shared storage node in response to the target entry in the cache entry information; determining whether the cache of the target file is out of date according to the effective time included in the target table item and the system time of the cache node; the valid time indicates a cache valid period of the target file.
Optionally, the shared storage node synchronously stores the valid time of the cache file when storing the cache file, wherein the valid time indicates the cache valid period of the cache file; the second response module, prior to being used to perform query response processing for the target file, the apparatus further includes:
Requesting the shared storage node for obtaining the effective time of the target file;
Under the condition that the effective time is received, responding to the condition that the effective time is larger than the system time of the cache node, and starting to execute the query response processing;
And executing the source return processing in the condition that the effective time is not acquired.
Optionally, in a case that the target file has been cached to the shared storage node, the apparatus further comprises: performing a source-back process in response to determining that the cache of the target file has expired; the query response processing includes: and executing the source returning process under the condition that the target file is not acquired.
Optionally, in a case where the target file is not cached to the shared storage node, the query response processing includes: and executing the source returning process in the case that the target file is not acquired or in the case that the target file is acquired and the cache of the target file is expired.
Optionally, the source return processing includes:
Requesting the CDN source server to acquire the target file;
responding to receiving a target file returned by the CDN source server, acquiring the effective time of the target file, and storing the target file and the effective time into the shared storage node; the effective time indicates the cache effective period of the target file;
responding to the access request according to the received target file;
and updating the information of the cache file which is used for recording and cached in the shared storage in the cache node according to the effective time.
Optionally, in a case where the cache of the target file has expired, before performing the source-back processing, the apparatus further includes:
accessing the target file in the shared storage node, and locking the target file;
in response to determining that the cache of the accessed target file is not expired, unlocking the target file, acquiring the target file and responding to the access request;
and in response to determining that the cache of the accessed target file has expired, performing an unlocking operation on the target file after the execution of the source-returning process is completed.
Optionally, in a case where the target file is not acquired, before performing the source-back processing, the apparatus further includes:
sending a file creation request to the shared storage node; the file creation request is used for requesting to create the target file in the shared storage node;
after receiving an indication message indicating that creation is completed, accessing the target file, and locking the target file;
Responding to the read data in the target file, unlocking the target file, obtaining the target file and responding to the access request;
And responding to the fact that the data in the target file cannot be read, and performing unlocking operation on the target file after the source returning processing is completed.
According to a third aspect of embodiments of the present application, there is provided an electronic device including: a memory and a processor; the memory is used for storing a computer program; the processor is used for executing the file searching method by calling the computer program.
According to a fourth aspect of embodiments of the present application, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described file finding method.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
In the technical scheme provided by the application, the node architecture of the edge node is improved to at least comprise one shared storage node and at least two cache nodes, various cache files are stored by the shared storage node for shared access and reading by all the cache nodes, when the number of the cache nodes changes such as adding, deleting and replacing the nodes, the cache files stored in the shared storage node are not affected by the change of the cache nodes, and the cache hit can be realized by requesting to acquire the cached files from the shared storage node, so that the overall cache hit rate is improved. And for the cache file which receives the request but cannot hit the cache node and is stored in the shared storage node, based on the fact that the shared storage node possibly has the target file stored in the shared storage node by other cache nodes, the shared storage node is firstly requested to acquire the target file instead of directly executing the source-returning processing, so that the number of times of the source-returning processing of the cache node is reduced, the problem of disk capacity increase caused by repeated source-returning of the same resource is avoided, and the disk utilization rate is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application as claimed. Furthermore, not all of the above-described effects need be achieved in any one embodiment of the present application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
FIG. 1 is a schematic diagram of a node architecture of a CDN edge node in the related art;
FIG. 2 is a schematic diagram of a node architecture of a CDN edge node according to an exemplary embodiment of the present application;
FIG. 3 is a flow chart of a method for searching a file according to an exemplary embodiment of the present application;
FIG. 4 is a flow chart illustrating a cache node implementing request load balancing according to an exemplary embodiment of the present application;
FIG. 5 is a flow chart illustrating a method for determining whether a cache node hits a target file requested by a user in accordance with an exemplary embodiment of the present application;
FIG. 6 is a flow chart illustrating a process when the present cache node misses a target file requested by a user, according to an example embodiment of the present application;
FIG. 7 is a flowchart of a back source process, which is shown in accordance with an exemplary embodiment of the present application;
FIG. 8A is a flowchart illustrating a process for locking an open file and a return source in the event that a cached file has expired, in accordance with an exemplary embodiment of the present application;
FIG. 8B is a flowchart illustrating a process for locking an open file and a back source in the absence of a cached file in a shared storage node, according to an exemplary embodiment of the present application;
FIG. 9 is a flow chart of another method for file lookup according to an exemplary embodiment of the application;
FIG. 10 is a schematic diagram of a file finding apparatus according to an exemplary embodiment of the present application;
fig. 11 is a hardware schematic of an electronic device according to an exemplary embodiment of the application.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the application. Rather, they are merely examples of apparatus and methods consistent with aspects of the application as detailed in the accompanying claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first classification threshold may also be referred to as a second classification threshold, and similarly, a second classification threshold may also be referred to as a first classification threshold without departing from the scope of the application. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" depending on the context.
CDNs are a technology that accelerates content delivery by deploying server nodes around the globe, and CDN edge nodes are key components that make up the CDN network, located in the geographic location closest to the user, for storing and caching content that is needed by the user. For example, CDN edge nodes may cache popular or commonly used content on the node that, when requested by a user, may be obtained directly from the nearby edge nodes to reduce response time and bandwidth consumption.
In the related art, referring to fig. 1, the architecture of a CDN edge node is generally formed by one load balancing node (i.e., a load balancing device) and a plurality of cache nodes (i.e., cache servers). When a user initiates a request, the load balancing node is used for receiving the user request and distributing the request to nearby and available cache nodes, and the node reasonably distributes the request to each cache node according to a certain algorithm such as polling, minimum connection number and the like, so that load balancing is realized, and the influence on the performance of the whole CDN network due to overload of some cache nodes is avoided.
Cache nodes are the core of CDN edge nodes, and are mainly used for storing and distributing static or dynamic content, such as HTML, CSS, javaScript, pictures, videos, etc., and are usually located on network nodes around the world so as to provide services to users more quickly. When the caching node receives a request from the load balancing node, if the node is determined to have cached user request content locally and the cache is not expired, returning the cached user request content to the load balancing node; if it is determined that the locally cached user request content has expired or the locally uncached user request content, the cache node needs to execute the back-source processing, and needs to request the CDN source server to acquire the user request content, store the user request content from the source server in a local memory of the local cache node, and return the user request content to the load balancing node.
The cache hit rate refers to the proportion of whether the content corresponding to the user request exists in the cache node in the cache system or not; in the process that the load balancing node loads the user request to different cache nodes, the problem of cache hit rate needs to be considered. Gao Huancun hit rate indicates that most of the content required by the user request exists in the cache node, so that the load of the source server is reduced, the response speed is improved, and the network traffic consumption of the whole system is reduced; the low cache hit rate indicates that many users need to obtain content from the source server, which increases the load of the source server and also causes the waiting time of the users to be long.
At present, a common method for realizing load balancing is to perform hash calculation on a URI (Uniform Resource Identifier ) requested by a user, so as to ensure that resources identified by the same URI fall into the same cache node, and therefore the same resources acquired by the cache node after source retrieval can be continuously hit in a cache until the resource cache expires.
However, hash computation based on URIs requires mapping the request into each cache node available to the edge node, taking into account the number of cache nodes. When the edge nodes are added, deleted and replaced or the cache nodes are in fault, the number of available cache nodes is changed, the corresponding relation between the hash value and the cache nodes is also changed, and therefore the request content of each user is redistributed to different cache nodes. Because the user request content may not be cached in the newly allocated cache node, the cache cannot be hit, so that the cache hit rate is reduced; and the newly allocated cache nodes need to be re-sourced to acquire the resource files, so that the same resource file is stored in a plurality of cache nodes, the use capacity of the disk is increased, and the utilization rate of the disk is influenced.
In order to solve the above technical problems, the present application provides a new node architecture of a CDN edge node, as shown in fig. 2, where the CDN edge node at least includes a shared storage node and at least two cache nodes, and each cache node may directly receive an access request from a client for requesting a cache file, and perform a communication response to the access request. The shared storage node may implement file sharing using a file system such as NFS (Network FILE SYSTEM ), CIFS (ANDREW FILE SYSTEM, general internet file system), AFS (ANDREW FILE SYSTEM, anderwu file system), etc. that may provide a file-level shared storage service.
Based on the architecture of the edge node, the local memory of each cache node does not store the cache files required by the cache node any more, all the cache files frequently accessed by the user are uniformly stored in the shared storage node, each cache node can share and access the shared storage node, and the cache files required by the cache node in response to the user request can be acquired from the shared storage node. When any cache node cannot read the required cache file from the shared storage node or the read cache file is out of date, after the cache node executes the source returning processing, namely after requesting to acquire the required cache file from the CDN source server, the required cache file is restored to the shared storage node for sharing access by all the cache nodes in the edge node; that is, any one cache node stores a cache file in the shared storage node, and other cache nodes can obtain the cache file by accessing the shared storage node.
Based on the architecture of the new edge nodes, the application provides a file searching method, which is executed by each cache node in the edge nodes. Referring to fig. 3, the file searching method may include the steps of:
s301, receiving an access request for requesting access to a target file;
The access request refers to a request for a particular network resource, which may include, but is not limited to, content of a particular web page, a file, a particular data source, a picture, a video, etc. The access request may be a request sent to the local cache node by the client, or may be a request forwarded to the local cache node by other cache nodes in the CDN edge node after receiving the request sent by the client. That is, the cache nodes may communicate with each other in this embodiment, and the cache nodes may communicate directly with each other between clients, so that the clients may directly send requests to the cache nodes.
For each cache node, a plurality of domain name records can be added in a domain name resolution server, different domain names are mapped to the IP addresses of each cache node, and an external monitoring port, such as a monitoring 80 port, of an application program of the node is configured on each cache node in advance, so that a client is allowed to establish communication connection with the cache node through the monitoring port, and the cache node is enabled to directly receive a request from the client. Compared with the prior art that a load balancing node is used for receiving a client request and distributing the client request to a cache node, in the embodiment, the client directly sends the request to the cache node without passing through the load balancing node, so that the transmission delay of the request is reduced, the performance of the cache node is better utilized, and the response speed of a system is improved.
S302, under the condition that the present cache node caches the target file to the shared storage node, responding to the fact that the cache of the target file is not expired, and executing query response processing on the target file; wherein the query response processing includes: requesting the shared storage node to acquire the target file; responding to the access request according to the target file in response to the cache of the target file not being expired under the condition that the target file is acquired;
Based on that all the cache files are stored in the shared storage node, for each cache node, the cache node can judge whether the target file requested by the user is cached in the shared storage node according to the cache file information stored in the local memory of the cache node and used for recording the cache of the cache node to the shared storage node, and for the two conditions that the target file is cached and is not cached in the shared storage center, different processing modes are adopted respectively.
The cache file information is a data structure for tracking cache data, records key information such as a file unique identifier, a storage path, a size, a type, a cache validity period and the like of each cache file cached to the shared storage node, and can be used for rapidly positioning and accessing the cache data. The cached file information may be organized based on file names or file unique identifiers for quick lookup and access to cached data, e.g., may be organized and managed using a hash table, b+ tree, or other data structure.
Whether the cache of the target file is expired refers to the problem of effectiveness of the target file cached in the shared storage node, and is used for ensuring timely updating and effectiveness of the cached data. For the target file cached in the cache node, a cache time or a valid period is corresponding, and when the cache time exceeds the set valid period, it is determined that the cache of the target file has expired. Under the condition that the cache of the target file is out of date, the cache node needs to acquire the latest target file content from the CDN source server again.
Based on the above-mentioned cache file information in the present cache node memory, when it is determined that the target file requested by the user has been cached in the shared storage node, there is key information about the target file in the cache file information; according to the buffer validity period included in the key information, the present buffer node can quickly determine whether the buffer of the target file buffered to the shared storage node is out of date.
Under the condition that the target file requested by the user is determined to be cached in the shared storage node, namely the target file is stored in the shared storage, if the caching node determines that the cached target file is not expired, the caching node can directly request the shared storage node to acquire the target file, so that the target file requested by the user can be returned to the user in response to the received access request. That is, the present cache node executes the query response processing, that is, requests to obtain the target file from the shared storage node, and responds to the access request according to the received target file, under the condition that it is determined that the target file which is not expired is stored in the shared storage node, according to the cache file information in the local memory.
For example, after the user requests to access the text file 1.Txt, if it is determined that the text file 1.Txt is already stored in the shared storage node by the present cache node or other cache nodes in the edge node and it is determined that the cache of the text file 1.Txt is not expired after the access request is received, the query response is executed, that is, a request is sent to the shared storage node to obtain the text file 1.Txt, and after the text file 1.Txt is received, a response result of the access request is generated according to the text file 1.Txt and is returned to the user.
S303, executing the query response processing on the target file under the condition that the target file is not cached to the shared storage node by the caching node.
In this embodiment, the shared storage node stores the cache file requested by each cache node to the source server, and any one cache node requests to cache the cache file in the shared storage node, so that all the cache nodes in the edge node can share access and obtain the cache file. Therefore, based on the above-mentioned cache file information in the memory of the present cache node, when it is determined that the present cache node does not cache the target file to the shared storage node, it may be determined that the present cache node does not request to store the target file to the shared storage node, and it may not be able to directly determine whether there is the target file requested to be cached by other cache nodes in the shared storage node.
Based on the principle, under the condition that the caching node does not cache the target file to the shared storage node, the shared storage node is requested to acquire the target file, and if the target file can be acquired and is not expired, the acquired target file can be returned to the user in response to the received access request.
When the shared storage node caches the target file, the effective time indicating the cache effective period of the target file can be synchronously cached, and the effective time can be stored in a set position of the target file, so that the effective time of the cache file can be shared when each cache node shares and accesses the target file, the target file accessed by all the cache nodes is ensured to have the same life cycle, and the consistency of data information in each cache node is maintained. Based on the effective time in the shared storage node, after the target file is acquired, whether the target file is out of date can be judged according to the effective time.
Taking the case of a user request to access the text file 1.Txt as an example, after the access request is received, if the cache node is determined not to store the text file 1.Txt in the shared storage node, the query response is executed, then a request is sent to the shared storage node to obtain the text file 1.Txt, after the text file 1.Txt is received, it is determined that the text file 1.Txt is not expired according to the effective time of the text file 1.Txt, and a response result of the access request is generated and returned to the user.
In the embodiment of the disclosure, the architecture of the edge node is improved to at least include a shared storage node and at least two cache nodes, various cache files are stored by the shared storage node for shared access and reading by all the cache nodes, when the number of the cache nodes changes, such as adding, deleting and replacing the nodes, the cache files stored in the shared storage node are not affected by the change of the cache nodes, and the cache hit can still be realized by requesting to acquire the cached files from the shared storage node, so that the overall cache hit rate is improved. And for the cache file which receives the request but cannot hit the cache node and is stored in the shared storage node, based on the fact that the shared storage node possibly has the target file stored in the shared storage node by other cache nodes, the shared storage node is firstly requested to acquire the target file instead of directly executing the source-returning processing, so that the number of times of the source-returning processing of the cache node is reduced, the problem of disk capacity increase caused by repeated source-returning of the same resource is avoided, and the disk utilization rate is improved.
In some embodiments, for the case of caching the target file to the shared storage node in the step S302, the file searching method may further include the following steps: performing a source-back process in response to determining that the cache of the target file has expired; the query response process may include the steps of: and executing the source returning process under the condition that the target file is not acquired.
That is, for the present cache node, when it is determined that the shared storage node stores the target file but the target file has expired, the target file cannot be directly used for responding to the access request, and the target file needs to be updated first, that is, the present cache node needs to execute the source returning process; for the case that it is determined that the target file which is not expired is stored in the shared storage node, when query response processing is executed, there may be a refresh operation occurring prior to the operation of acquiring the target file, and when the target file is requested to be acquired, the target file is deleted, so that the target file cannot be acquired, in this case, the query response processing includes an operation of executing back-to-source processing on the target file which is not acquired, so as to acquire the target file from the source server. The refreshing operation means that other cache nodes respond to a refreshing request for refreshing the target file, so that the shared storage node is instructed to delete the target file, and refreshing of the target file is realized by re-sourcing.
The back source processing may at least include: the caching node requests the source server to acquire the target file, stores the received target file in the shared storage node, updates caching file information of a local memory of the caching node, and responds to the access request according to the target file.
Taking the user request to access the text file 1.Txt as an example, if it is determined that the text file 1.Txt stored in the shared storage node has expired and the text file 1.Txt needs to be updated, executing the source return processing; or in the process of executing the query response processing, for the case that the text file 1.Txt is not acquired from the shared storage node, that is, the text file 1.Txt is not stored in the shared storage node, the source server needs to be requested to acquire the text file 1.Txt, and the source return processing still needs to be executed.
In some embodiments, for the case of not caching the target file to the shared storage node in the foregoing step S303, the query response processing may include the following steps:
And under the condition that the target file is acquired, executing the source returning process in response to the expiration of the cache of the target file. Executing source returning processing under the condition that the target file is not acquired;
That is, under the condition that the present cache node does not cache the target file to the shared storage node, the target file is requested to be acquired from the shared storage node; if the shared storage node returns the target file, when the returned target file is determined to be out of date according to the effective time of the target file, the cache node updates the target file stored by the shared storage node, namely, the source returning processing is executed; if the shared storage node does not return the target file, that is, the target file is not cached in the shared storage node, the cache node requests to acquire the target file and stores the target file in the shared storage node, that is, the source returning processing is executed.
Taking a user request to access the text file 1.Txt as an example, after receiving the access request, if it is determined that the text file 1.Txt is not stored in the shared storage node by the cache node, in the process of executing the query response, determining that the text file 1.Txt has expired according to the valid time of the text file 1.Txt in response to receiving the text file 1.Txt, executing a source returning process to update the text file 1.Txt in the shared storage node; in response to not receiving the text file 1.Txt, a source return process is performed to obtain the text file 1.Txt and store it to the shared storage node.
In some embodiments, the cache nodes may communicate with each other, for the file lookup method shown in fig. 3, in a case where the access request is sent to the local cache node by the client through network transmission, and is not forwarded to the local cache node by other cache nodes in the local edge node, after step S301, referring to fig. 4, the method may further include the following steps to implement load balancing of the access request on the respective cache nodes, where the steps may include:
S401, generating a corresponding hash value according to the access request;
the hash value of the request can be generated according to the URI of the access request, so that the request for the same resource is loaded into the same cache node; to achieve more balanced load handling, the hash value of the request may also be generated from the URI and the IP address of the client sending the request.
S402, forwarding the access request to a cache node corresponding to the hash value according to a mapping relation between the preset hash value and the cache node under the condition that the cache node corresponding to the hash value is not the cache node;
Mapping the request to a cache node for processing the request is typically implemented using a hash table or a consistent hash algorithm, and may include the steps of: determining a list of available cache nodes, each cache node having a unique identifier or address; according to the specific parameters of the user request, calculating a hash value by using a hash function; and mapping the hash value to one of the cache nodes by modulo arithmetic or other mapping algorithms by using the calculated hash value and the cache node list.
The embodiment predefines a mapping algorithm, and maps out a cache node in the edge nodes based on the hash value generated in the step S401; when the cache node of the hash value mapping is not the same node as the cache node which receives the access request, the received access request is forwarded to the cache node of the hash value mapping for processing, so that the load balance of the access request on each cache node included in the edge node is realized through the cache node.
For example, the edge node includes 4 cache nodes, each cache node corresponds to a unique identifier, after a hash value corresponding to the access request is generated, the cache node mapped by the request can be determined through the hash value and the remainder 4, and the remainder 0, 1, 2 and 3 respectively correspond to one cache node.
S403, receiving a response result of the access request returned by the cache node corresponding to the hash value, and sending the response result to a sender of the access request.
Under the condition that the access request is forwarded to the cache node mapped by the hash value for processing, the cache node mapped by the hash value executes the file unlocking method provided by the application to generate the response result of the access request, the response result is returned to the cache node, and the response result is returned to the user side, namely the sender of the access request by the cache node.
In the embodiment of the disclosure, the requests are reasonably distributed to different cache nodes through the hash algorithm, so that load balancing of the user requests among the cache nodes can be realized, heavier load of a single cache node is avoided, and the response speed and performance of the whole system are improved.
In some embodiments, the cache file information in the local memory of the cache node described in the foregoing embodiments may be cache entry information set in each cache node; the cache table item information is used for recording the information of the cache file cached in the shared storage node by the cache node, so that the cache node can quickly determine whether the cache is hit in the cache node when receiving the access request.
Based on this, as shown in fig. 5, after receiving the access request, the method may further include the steps of determining whether a target file requested by the user is already stored in the shared storage node, which may include:
S501, acquiring a file identifier of the target file according to the access request;
the file identifier refers to a unique identifier of the target file requested to be accessed by the user, and can be used to find and access the target file in the shared storage node, and can include a hash value of the target file calculated according to a specific parameter in the access request, such as a hash value of the target file calculated according to a user request URI.
S502, detecting whether a target table item containing the file identifier exists in the cache table item information;
The cache entry information is a data structure for recording a cache file stored in the shared storage node by the edge node, and generally comprises information such as a file name, a size, valid time indicating a valid period of the cache file and the like; each cache entry corresponds to a cache file, and may be uniquely identified by an index or hash algorithm, which is typically stored in the memory of the cache node for quick access and update of the cache data.
In this embodiment, the file identifier of the target file is used to uniquely identify each cache entry, and after the file identifier of the target file is obtained, the file identifier of the target file is matched with each cache entry stored in the memory of the cache node, so as to determine whether the target entry containing the file identifier exists.
And S503, in response to the fact that the target table item does not exist, determining that the target file is not cached by the caching node to the shared storage node.
S504, in response to the existence of the target table item, determining that the target file is cached by the caching node to the shared storage node;
Based on the cache table item information, the cache file which is stored in the shared storage node by the edge node is recorded, and a target table item exists, which indicates that the cache file which is cached in the shared storage node by the edge node comprises the target file, namely, the cache node is determined to have cached the target file in the shared storage node; otherwise, if the target table item does not exist, the cache file cached by the cache node to the shared storage node does not include the target file, and the cache node does not cache the target file to the shared storage node.
After determining that the target file is cached to the shared storage node, responding to the fact that the target table item in the cache table item information contains a file identifier of the target file and valid time, wherein the valid time indicates the cache valid period of the target file, and the file searching method further comprises the step of determining whether the cache of the target file is valid or not by the cache node, and the method can be realized by the following steps:
And determining whether the cache of the target file is out of date according to the effective time included in the target table item and the system time of the cache node.
That is, after determining the target table entry indicating the target file from the cache table entry information of the present cache node, the valid time included in the target table entry is obtained, and meanwhile, the system time of the present cache node is obtained, and whether the cache of the target file is expired is determined by comparing the relative relationship between the valid time and the system time of the present cache node. Specifically, in the case where the effective time of the target file is earlier than or equal to (less than or equal to) the system time, determining that the cache of the target file has expired; in the event that the target file has a validity time later (greater) than the system time, it is determined that the target file's cache has not expired.
For example, if the effective time of the target file is 2023/06/07 04:00:00 and the system time is 2023/06/07 03:59:00, the effective time is later (greater than) the system time, and it is determined that the cache of the target file is not expired.
In some embodiments, the cached file stored by the shared storage node has the file identity as a file name; in the case that the target entry does not exist in the cache entry information in step S503, when the request for obtaining the target file from the shared storage node is sent, the file obtaining request may include the file identifier of the target file, so that the shared storage node queries, in response to receiving the file obtaining request, a cache file corresponding to a file name matching the file identifier carried by the request as the target file, generates a response result, and returns the response result to the local cache node.
In the embodiment of the disclosure, the cache file can be quickly queried and managed by setting the cache entry information for the cache node to record the cache file stored in the shared storage node by the cache node, and whether the target file requested by the user is stored in the shared storage node is determined by checking the cache entry in the memory of the cache node, so that the access times to the shared storage node are reduced, unnecessary network transmission between the cache node and the shared storage node is avoided, and bandwidth occupation and delay are reduced.
In some embodiments, the shared storage node stores the cache file simultaneously with the valid time of the cache file, where the valid time indicates the cache validity period of the cache file, that is, when each cache node shares access to the cache file stored in the shared storage node, the cache validity period of the cache file can be obtained not only by reading the content of the cache file, but also by reading the content of the cache file, so that when the cache node requests to obtain the cache file stored in the shared storage node by other cache nodes, the cache validity period of the requested cache file can be determined.
For example, after receiving a file storage request, the shared storage node adds the effective time to a preset position of a head of a cached file according to the effective time of the cached file carried by the file storage request, and stores the added file in a storage path designated by the cache node. Wherein the storage path may be determined by hash calculation from the URI.
Based on the cached files stored in the shared storage node and the valid time of the cached files, for the case that the target file is not cached in the shared storage node in step S303, before executing the query response processing for the target file in step S303, as shown in fig. 6, the method may further include the following steps:
s601, requesting the shared storage node for obtaining the effective time of the target file;
That is, when the target file is not cached in the shared storage node, the shared storage node is first requested to acquire the effective time of the target file. If the target file is cached in the shared storage node, the shared storage node returns the effective time of the target file; if the target file is not cached in the shared storage node, the shared storage node may not return the valid time of the target file or return the result to be empty.
S602, under the condition that the effective time is received, responding to the condition that the effective time is larger than the system time of the cache node, and starting to execute the query response processing;
And under the condition that the effective time of the target file is carried in the result returned by the shared storage node, indicating that the target file is cached in the shared storage node, and under the condition that the target file is not expired, the cache node requests the shared storage node to acquire the target file to respond to the user request, namely, starts to execute the query response processing.
S603, executing the source return processing under the condition that the effective time is smaller than or equal to the system time of the cache node or the effective time is not acquired.
And under the condition that the effective time is received, for the system time of the cache node with the effective time less than or equal to the effective time, the target file cached in the shared storage node is expired, and the target file needs to be updated, and then the cache node executes the source returning processing.
And under the condition that the effective time is not received, indicating that the target file is not cached in the shared storage node, and the caching node needs to request the source server to cache the target file in the shared storage node, namely executing the source returning process.
In the embodiment of the disclosure, the frequent reading operation on the shared storage node is reduced, the access pressure of the shared storage node is reduced, and the overall performance of the system is improved by requesting the effective time of acquiring the target file before the acquisition of the complete target file is requested and reading the complete target file under the condition that the target file is not expired.
In some embodiments, the local memory of the present cache node stores information for recording the cache file cached in the shared storage; for the back-source processing step described in any of the foregoing embodiments, referring to fig. 7, the back-source processing may be implemented in the following manner:
S701, requesting the CDN source server to acquire the target file;
the cache node sends a request to the source server through the network to request to acquire the target file. After receiving the request, the source server performs corresponding processing according to the file path of the request. In the event that the source server confirms that there is authority to provide the file to the caching node, the file content is sent back to the caching node as a response.
S702, responding to receiving a target file returned by the CDN source server, acquiring the effective time of the target file, and storing the target file and the effective time into the shared storage node; the effective time indicates the cache effective period of the target file;
after receiving the response of the source server, the valid time of the target file can be determined according to the time of receiving the target file and the preset cache valid period, or the source server can specify the valid time of the target file.
After receiving the response of the source server, the cache node uses a network transmission protocol to transmit the received file content and the effective time from the source server to the shared storage node; the shared storage node receives file content and valid time from the cache node over the network and stores it in a local shared storage. The specific storage manner may depend on the system design and requirements, for example, the files may be saved in a designated directory of a shared file system, such as NFS, and after the shared storage node receives the file content, the files may be written to the shared storage using a write operation provided by the file system, which may include operations such as creating a target file, writing the file content, writing the validity time, and the like.
In actual development, network transfer and file write operations may be implemented using corresponding APIs or libraries to store target files to shared storage nodes, depending on the type of file system employed.
S703, responding to the access request according to the received target file;
s704, updating information of the cache file which is used for recording and cached in the shared storage in the cache node according to the effective time;
For the case where the cache entry information is set in the present cache node according to the foregoing embodiment, the cache entry information may be updated according to the valid time.
Under the condition that the cache of the target file is out of date, updating the cache entry information comprises updating the effective time of the target file included in the target entry indicating the target file in the cache entry information, and updating the effective time stored in the target entry as follows: and receiving the obtained effective time when the target file returned by the CDN source server is received.
In the case that the target file is not acquired, the updating the cache entry information includes: generating a target table item of the target file according to the file identification of the target file and the effective time acquired when the target file returned by the CDN source server is received; and adding the target table entry into the cache table entry information.
In some embodiments, for the source-back processing described in the foregoing embodiments, a mode of "file lock" in combination with "pre-reading a target file in a shared storage node before source-back processing" may be used to avoid multiple repeated source-back of the same target file by different cache nodes. The file lock can be used for ensuring that only one cache node can perform read-write operation on the file in the shared storage node at the same time, so that the problems of data consistency and competition conflict caused by that a plurality of cache nodes read-write the same file at the same time are avoided. When one cache node needs to perform read-write operation on a target file, the cache node requests to a shared file storage node to acquire a file lock, and if the file lock is occupied by other cache nodes, the current node needs to wait for releasing the lock. After the file lock is acquired by the current cache node, other cache nodes can not execute read-write operation on the file until the current node releases the file lock.
Referring to fig. 8A, in the case that the cache of the target file has expired, before performing the source-back process, the file searching method further includes the following steps: accessing the target file in the shared storage node, and locking the target file; in response to determining that the cache of the accessed target file is not expired, unlocking the target file, acquiring the target file and responding to the access request; and in response to determining that the cache of the accessed target file has expired, performing an unlocking operation on the target file after the execution of the source-returning process is completed.
That is, for the target file whose cache has expired, the present cache node requests the shared storage node to read the expired target file and locks the open file. The cache file is locked and opened by adopting the following steps: using a file opening function provided by an operating system, such as an open () function, opening a target file to be accessed in a specified manner, such as a read mode, a write mode, or the like; after a file is opened, the file may be locked using a locking function provided by the operating system. For example, in a Linux system, a file may be locked using fcntl () function or flow () function, which may be in the form of a shared lock (read operation) or an exclusive lock (write operation), to ensure that other processes cannot modify the file contents during file operations. After the file is successfully locked, corresponding file reading or writing operation can be performed, and other cache nodes cannot write or modify the file in the period because the file is locked, namely cannot execute source-returning processing on the target file, so that repeated source returning of the same resource file is avoided.
Pre-reading before source return processing: acquiring effective time corresponding to the target file; acquiring the current system time of the cache node; judging whether the current time is greater than or equal to the effective time; if yes, starting to execute the back source processing, and unlocking the target file after the back source processing is finished so as to allow other processes to access the file; if not, namely other cache nodes have completed the source returning processing, reading the target file, updating the cache file information in the local memory of the cache node according to the effective time, responding to the access request and unlocking the target file.
Referring to fig. 8B, in a case where the target file is not acquired, the file unlocking method may further include the steps of: sending a file creation request to the shared storage node; the file creation request is used for requesting to create the target file in the shared storage node; after receiving an indication message indicating that creation is completed, accessing the target file, and locking the target file; responding to the read data in the target file, unlocking the target file, obtaining the target file and responding to the access request; and responding to the fact that the data in the target file cannot be read, and performing unlocking operation on the target file after the source returning processing is completed.
Similar to the foregoing processing manner in the case where the cache of the target file has expired, the target file is not read from the shared storage node, i.e., the target file is not included in the shared storage node. Thus, the target file is created under the designated directory of the shared storage node before the source return process, and after the target file is created, the target file is locked and opened.
Pre-reading before source return processing: based on the fact that the target file is a newly created file, if data can be read from the target file, the fact that before the target file is locked and opened by the cache node, the fact that other cache nodes perform source returning processing on the target file is characterized, and the data exist in the target file; if the data cannot be read from the target file, the back source processing is started to acquire the file content of the target file, the target file is written into the target file, and the target file is unlocked after the writing is completed.
In the embodiment of the disclosure, the target file is opened by using the file lock before the back source processing operation is executed, so that other cache nodes cannot write the same target file at the same time when the back source operation is executed, and by using the pre-reading operation, the cache nodes can judge whether the content of the target file is updated before the back source is executed, thereby avoiding multiple back sources and saving network bandwidth and back source time.
In the related art, the same resource may be cached in a plurality of cache nodes, when the resource is refreshed, the resource needs to be refreshed for all cache nodes, the refresh time is long and the performance is low, when the line of the directory is refreshed, the cache nodes need to be issued, and based on the relationship between the refresh directory time of each cache node and the number of the files in the directory, the refresh of different cache nodes is time-consuming.
Based on the architecture of the edge node shown in fig. 2 employed by the present application, in some embodiments, in response to receiving a refresh request indicating to perform a refresh operation on a target refresh file, the file lookup method may further include the steps of: and sending a deleting request for deleting the target refreshing file to the shared storage node.
When the shared storage node receives the deleting request, the file deleting operation is executed when the target refreshing file is found in the appointed path, and if the target refreshing file is not found, the file deleting operation is not executed, so that when a user requests the target refreshing file, the cache node receiving the request executes the source returning process, and the refreshing process of the target refreshing file is realized.
In the embodiment of the disclosure, since the cache files are shared, when a user initiates refreshing, the shared storage node is only required to be refreshed, namely, the cache files are directly deleted for refreshing, so that a refreshing task is issued to the shared storage node, the refreshing time is shortened, the refreshing performance of the system is improved, and the refreshing logic is simplified.
Next, in order to enable those skilled in the art to better understand the file searching method provided by the present application, the method of the present application is described by taking a scenario in which the number of nodes changes due to addition, deletion, replacement of cache nodes of edge nodes and node failure, and a text file a.txt requested by a user as an example.
Based on the node architecture schematic diagram of the CDN edge node shown in fig. 2, the embodiment of the present application may be implemented based on nginnx, with a cache node as an execution body, and the shared storage node uses an NFS file storage manner. The shared storage node starts the NFS server to provide a directory with larger capacity to the outside, the cache node starts the NFS client to share the directory for storing the cache file through the directory provided by the remote mount shared storage NFS server, when the data acquired by one cache node is stored as the cache file, the cache file is stored on the shared storage node, and all the cache nodes can find the cache file, so that the purpose of sharing the cache file is achieved.
In this embodiment, the cache file stored in the shared storage node includes file content and a cache valid timestamp, where the cache valid timestamp is added in a header setting position of the cache file; the buffer availability time stamp is used for indicating the buffer availability period of the buffer file. Based on this and the node architecture of the edge node, the source-back processing described in this embodiment includes: requesting a CDN source server to acquire file contents of the target file; responding to the received file content of the target file, and acquiring a cache effective time stamp of the target file; writing the cache effective time stamp and the content of the target file into the target file created under the appointed path in the shared storage node, wherein the cache effective time stamp is written into a head set position of the target file; responding to the received access request of the target file according to the file content of the target file.
Referring to fig. 9, the file searching method provided by the present application may include the following steps:
S901, receiving an access request from a client; the access request is used for requesting the text file A.txt;
S902, determining a request hash value corresponding to the access request according to the request URI and the IP address of the client;
s903, when the cache node mapped by the request hash value is not the own cache node, forwarding the access request to the cache node mapped by the request hash value, so that the cache node mapped by the request hash value executes the following steps;
s904, acquiring a file hash value of the text file requested by the user according to the request URI;
the file hash value is used to uniquely indicate the text file a.txt requested by the user.
S905, determining whether the local cache list item information of the cache node comprises a target list item of the file hash value of the text file according to the file hash value;
S906A, responding to the target table item, and determining whether the text file is out of date according to a cache effective time stamp and a system time stamp of the cache node which are included in the target table item;
the cache valid time stamp is used for indicating the cache valid period of the text file.
S907A, executing the source returning process under the condition that the buffer memory of the text file is out of date;
S908A, requesting to acquire the text file from the sharing cache node according to the storage path of the text file under the condition that the cache of the text file is not expired;
the storage path of the text file can be calculated by performing hash value calculation on the request URI. In this embodiment, each cached file cached in the shared storage node may be named with the file hash value corresponding to the file, so that when a text file is requested to be obtained, a file obtaining request is sent to the shared storage node, where the request may include the storage path and the file hash value, so that after the shared storage node receives the file obtaining request, the shared storage node matches a target file named as the file hash value from the specified path, and returns to the local storage node.
S909A, in the case of receiving the text file, reading a target file and responding to a user request;
S910A, executing source returning processing under the condition that the text file is not received; the back source processing comprises the following steps: requesting the text file from the source server, adding a cache valid time stamp into the header of the received text file, storing the cache valid time stamp in a shared cache node, updating the cache entry information and responding to a user request;
S906B, requesting the shared cache node to acquire a cache valid time stamp of the text file in response to the target table item not being included;
S907B, executing the source return processing under the condition that the buffer effective time stamp is not received;
S908B, under the condition that the cache effective time stamp is received, determining whether the text file is out of date according to the cache effective time stamp;
S909B, responding to the unexpired text file, requesting to acquire the text file from the sharing cache node, and responding to the access request according to the acquired text file;
And S910B, executing the source returning processing in response to the expiration of the text file.
Steps 906A-910A and 906B-910B respectively represent the processing flows of the present cache node in two different situations of determining whether the present cache node has cached the target file to the shared storage node according to the cache entry information stored in the local memory of the node after receiving the access request of the client.
Based on the whole flow of the file searching method, as the cache files are not stored in each cache node, various cache files are cached by adopting the shared storage node for shared access and reading of all the cache nodes, the sharing of the cache files is realized, and when the number of the cache nodes changes, such as adding, deleting and replacing the nodes, the cache files stored in the shared storage node are not affected by the change of the cache nodes. Therefore, when the cache nodes are added, deleted, replaced, and failed, after calculating the hash value based on the request URI to load the request to a different cache node, the newly allocated cache node may still be used to implement the request response for the same resource request by executing the processing flow after step S904 described above.
In the embodiment of the disclosure, the architecture of the edge node is improved to at least comprise a shared storage node and at least two cache nodes, and various cache files are stored by the shared storage node for shared access and reading by all the cache nodes, so that when the number of the cache nodes changes, the cache files cached in the shared storage node are not influenced, and cache hit can be realized by requesting to acquire the cached files from the shared storage node, thereby improving the overall cache hit rate; for various cache files cached by the shared storage node, the cache effective time stamp of the cache file is synchronously stored, so that the sharing of the memory information and the cache files in each cache node is realized, and the cache effective period of the cache file can be accurately obtained when the nodes other than the cache node are read to request the cache files cached in the shared storage node. And for the cache file which receives the request but cannot hit the cache node and is stored in the shared storage node, based on the fact that the shared storage node possibly has the target file stored in the shared storage node by other cache nodes, the shared storage node is firstly requested to acquire the target file instead of directly executing the source-returning processing, so that the number of times of the source-returning processing of the cache node is reduced, the problem of disk capacity increase caused by repeated source-returning of the same resource is avoided, and the disk utilization rate is improved.
Corresponding to the foregoing embodiment of the file searching method, referring to fig. 10, the present application further provides an embodiment of the file searching method apparatus, which is applied to a cache node in an edge node of a CDN of a content delivery network, where the edge node includes at least two cache nodes and a shared storage node; each cache node shares access to the cache files stored in the shared storage node; the device comprises:
An access request receiving module for receiving an access request for requesting access to a target file;
The first response processing module is used for responding to the fact that the cache of the target file is not expired under the condition that the local cache node caches the target file to the shared storage node, and executing query response processing on the target file;
The second response processing module is used for executing query response processing on the target file under the condition that the target file is not cached to the shared storage node by the caching node;
Wherein the query response processing includes:
Requesting the shared storage node to acquire the target file; and under the condition that the target file is acquired, responding to the access request according to the target file in response to the fact that the cache of the target file is not expired.
In some embodiments, in response to the access request being sent by the client to the local cache node, the apparatus further comprises, upon receiving the access request: generating a corresponding hash value according to the access request; according to a mapping relation between a preset hash value and a cache node, forwarding the access request to the cache node corresponding to the hash value under the condition that the cache node corresponding to the hash value is not the cache node; and receiving a response result of the access request returned by the cache node corresponding to the hash value, and sending the response result to a sender of the access request.
In some embodiments, the cache node is provided with cache entry information; the cache table item information is used for recording the information of the cache file cached in the shared storage node by the cache node; after receiving the access request, the apparatus further comprises:
Acquiring a file identifier of the target file according to the access request; determining that the target file is not cached to the shared storage node by the cache node if the target table item containing the file identifier does not exist in the cache table item information; determining that the cache node has cached the target file to the shared storage node in response to the target entry in the cache entry information; determining whether the cache of the target file is out of date according to the effective time included in the target table item and the system time of the cache node; the valid time indicates a cache valid period of the target file.
In some embodiments, the shared storage node synchronously stores an effective time of the cache file when storing the cache file, the effective time indicating a cache validity period of the cache file; the second response module, prior to being used to perform query response processing for the target file, the apparatus further includes:
Requesting the shared storage node for obtaining the effective time of the target file; under the condition that the effective time is received, responding to the condition that the effective time is larger than the system time of the cache node, and starting to execute the query response processing; and executing the source return processing in the condition that the effective time is not acquired.
In some embodiments, in the case that the target file has been cached to the shared storage node, the apparatus further comprises: performing a source-back process in response to determining that the cache of the target file has expired; the query response processing includes: executing source returning processing under the condition that the target file is not acquired;
or, in the case that the target file is not cached in the shared storage node, the query response processing includes: and executing the source returning process in the case that the target file is not acquired or in the case that the target file is acquired and the cache of the target file is expired.
In some embodiments, the back-source processing includes: requesting the CDN source server to acquire the target file; responding to receiving a target file returned by the CDN source server, acquiring the effective time of the target file, and storing the target file and the effective time into the shared storage node; the effective time indicates the cache effective period of the target file; responding to the access request according to the received target file; and updating the information of the cache file which is used for recording and cached in the shared storage in the cache node according to the effective time.
In some embodiments, in the event that the cache of the target file has expired, prior to performing the back-source processing, the apparatus further comprises:
Accessing the target file in the shared storage node, and locking the target file; in response to determining that the cache of the accessed target file is not expired, unlocking the target file, acquiring the target file and responding to the access request; and in response to determining that the cache of the accessed target file has expired, performing an unlocking operation on the target file after the execution of the source-returning process is completed.
In some embodiments, in the event that the target file is not acquired, prior to performing the back-source processing, the apparatus further comprises:
sending a file creation request to the shared storage node; the file creation request is used for requesting to create the target file in the shared storage node;
after receiving an indication message indicating that creation is completed, accessing the target file, and locking the target file;
Responding to the read data in the target file, unlocking the target file, obtaining the target file and responding to the access request;
And responding to the fact that the data in the target file cannot be read, and performing unlocking operation on the target file after the source returning processing is completed.
The implementation process of the functions and roles of each unit in the above device is specifically shown in the implementation process of the corresponding steps in the above method, and will not be described herein again.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present application. Those of ordinary skill in the art will understand and implement the present application without undue burden.
The embodiment of the application also provides an electronic device, the structural schematic diagram of which is shown in fig. 11, the electronic device 1100 includes at least one processor 1101, a memory 1102 and a bus 1103, and at least one processor 1101 is electrically connected to the memory 1102; the memory 1102 is configured to store at least one computer executable instruction and the processor 1101 is configured to execute the at least one computer executable instruction to perform the steps of any one of the file lookup methods as provided by any one of the embodiments or any one of the alternative implementations of the present application.
Further, the processor 1101 may be an FPGA (field-programmable gate array) or other device having logic processing capability, such as an MCU (Microcontroller Unit, micro control unit), a CPU (Central Process Unit, central processing unit).
The embodiment of the application also provides another readable storage medium, which stores a computer program for implementing the steps of any one of the file searching methods provided by any one of the embodiments or any one of the optional embodiments of the application when the computer program is executed by a processor.
The readable storage medium provided by the embodiments of the present application includes, but is not limited to, any type of disk (including floppy disks, hard disks, optical disks, CD-roms, and magneto-optical disks), roms (read-only memories), rams (Random Access Memory, random access memories), eproms (Erasable Programmable Read-only memories), eeproms (ELECTRICALLY ERASABLE PROGRAMMABLE READ-only memories), flash memories, magnetic cards, or optical cards. That is, a readable storage medium includes any medium that stores or transmits information in a form readable by a device (e.g., a computer).
Thus, particular embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve desirable results. Furthermore, the processes depicted in the accompanying drawings are not necessarily required to be in the particular order shown, or sequential order, to achieve desirable results. In some implementations, multitasking and parallel processing may be advantageous.
While this specification contains many specific implementation details, these should not be construed as limitations on the scope of any invention or of what may be claimed, but rather as descriptions of features of specific embodiments of particular inventions. Certain features that are described in this specification in the context of separate embodiments can also be implemented in combination in a single embodiment. On the other hand, the various features described in the individual embodiments may also be implemented separately in the various embodiments or in any suitable subcombination. Furthermore, although features may be acting in certain combinations and even initially claimed as such, one or more features from a claimed combination can in some cases be excised from the combination, and the claimed combination may be directed to a subcombination or variation of a subcombination.
The foregoing description of the preferred embodiments of the application is not intended to be limiting, but rather to enable any modification, equivalent replacement, improvement or the like to be made within the spirit and principles of the application.

Claims (11)

1. The file searching method is characterized by being applied to cache nodes in CDN edge nodes of a content delivery network, wherein the edge nodes comprise at least two cache nodes and a shared storage node; each cache node shares access to the cache files stored in the shared storage node; the cache file is a file which is obtained and stored in the shared storage node by the cache node through executing back-source processing to request a CDN source server; the method comprises the following steps:
receiving an access request for requesting access to a target file;
under the condition that the present cache node caches the target file to the shared storage node, responding to the fact that the cache of the target file is not expired, and executing query response processing on the target file;
Under the condition that the target file is not cached to the shared storage node by the caching node, query response processing is executed for the target file;
Wherein the query response processing includes:
Requesting the shared storage node to acquire the target file; and under the condition that the target file is acquired, responding to the access request according to the target file in response to the fact that the cache of the target file is not expired.
2. The method of claim 1, wherein the client sends the access request to the local cache node, and wherein upon receiving the access request, the method further comprises:
generating a corresponding hash value according to the access request;
according to a mapping relation between a preset hash value and a cache node, forwarding the access request to the cache node corresponding to the hash value under the condition that the cache node corresponding to the hash value is not the cache node;
and receiving a response result of the access request returned by the cache node corresponding to the hash value, and sending the response result to a sender of the access request.
3. The method according to claim 1, wherein the cache node is provided with cache entry information; the cache table item information is used for recording the information of the cache file cached in the shared storage node by the cache node; after receiving the access request, the method further comprises:
Acquiring a file identifier of the target file according to the access request;
Determining that the target file is not cached to the shared storage node by the cache node if the target table item containing the file identifier does not exist in the cache table item information;
Determining that the cache node has cached the target file to the shared storage node in response to the target entry in the cache entry information; determining whether the cache of the target file is out of date according to the effective time included in the target table item and the system time of the cache node; the valid time indicates a cache valid period of the target file.
4. The method of claim 1, wherein the shared storage node synchronously stores a valid time of the cache file when storing the cache file, the valid time indicating a cache validity period of the cache file; in the case where the target file is not cached to the shared storage node, before performing a query response process for the target file, the method further includes:
Requesting the shared storage node for obtaining the effective time of the target file;
Under the condition that the effective time is received, responding to the condition that the effective time is larger than the system time of the cache node, and starting to execute the query response processing;
And executing the source return processing in the condition that the effective time is not acquired.
5. The method according to any one of claim 1 to 4, wherein,
In the case that the target file has been cached to the shared storage node, the method further comprises: performing a source-back process in response to determining that the cache of the target file has expired; the query response processing includes: executing source returning processing under the condition that the target file is not acquired;
or, in the case that the target file is not cached in the shared storage node, the query response processing includes: and executing the source returning process in the case that the target file is not acquired or in the case that the target file is acquired and the cache of the target file is expired.
6. The method of claim 5, wherein the back-source processing comprises:
Requesting the CDN source server to acquire the target file;
responding to receiving a target file returned by the CDN source server, acquiring the effective time of the target file, and storing the target file and the effective time into the shared storage node; the effective time indicates the cache effective period of the target file;
responding to the access request according to the received target file;
and updating the information of the cache file which is used for recording and cached in the shared storage in the cache node according to the effective time.
7. The method of claim 5, wherein in the event that the cache of the target file has expired, prior to performing the back-source processing, the method further comprises:
accessing the target file in the shared storage node, and locking the target file;
in response to determining that the cache of the accessed target file is not expired, unlocking the target file, acquiring the target file and responding to the access request;
and in response to determining that the cache of the accessed target file has expired, performing an unlocking operation on the target file after the execution of the source-returning process is completed.
8. The method of claim 5, wherein in the event that the target file is not obtained, prior to performing back-to-source processing, the method further comprises:
sending a file creation request to the shared storage node; the file creation request is used for requesting to create the target file in the shared storage node;
after receiving an indication message indicating that creation is completed, accessing the target file, and locking the target file;
Responding to the read data in the target file, unlocking the target file, obtaining the target file and responding to the access request;
And responding to the fact that the data in the target file cannot be read, and performing unlocking operation on the target file after the source returning processing is completed.
9. The file searching device is characterized by being applied to cache nodes in CDN edge nodes of a content delivery network, wherein the edge nodes comprise at least two cache nodes and a shared storage node; each cache node shares access to the cache files stored in the shared storage node; the cache file is a file which is obtained and stored in the shared storage node by the cache node through executing back-source processing to request a CDN source server; the device comprises:
An access request receiving module for receiving an access request for requesting access to a target file;
The first response processing module is used for responding to the fact that the cache of the target file is not expired under the condition that the local cache node caches the target file to the shared storage node, and executing query response processing on the target file;
The second response processing module is used for executing query response processing on the target file under the condition that the target file is not cached to the shared storage node by the caching node;
Wherein the query response processing includes:
Requesting the shared storage node to acquire the target file; and under the condition that the target file is acquired, responding to the access request according to the target file in response to the fact that the cache of the target file is not expired.
10. An electronic device, comprising: a memory, a processor;
the memory is used for storing a computer program;
The processor being operative to invoke the computer program to implement a file finding method as claimed in any of claims 1 to 8.
11. A readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements a file finding method as claimed in any one of claims 1-8.
CN202410079748.9A 2024-01-19 2024-01-19 File searching method, device, equipment and readable storage medium Active CN117615013B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410079748.9A CN117615013B (en) 2024-01-19 2024-01-19 File searching method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410079748.9A CN117615013B (en) 2024-01-19 2024-01-19 File searching method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN117615013A CN117615013A (en) 2024-02-27
CN117615013B true CN117615013B (en) 2024-04-19

Family

ID=89958216

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410079748.9A Active CN117615013B (en) 2024-01-19 2024-01-19 File searching method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN117615013B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102447712A (en) * 2012-01-20 2012-05-09 华为技术有限公司 Method and system for interconnecting nodes in content delivery network (CDN) as well as nodes
CN108780458A (en) * 2017-12-08 2018-11-09 深圳市大疆创新科技有限公司 A kind of page cache processing method, device and server
CN112995753A (en) * 2019-12-16 2021-06-18 中兴通讯股份有限公司 Media stream distribution method, CDN node server, CDN system and readable storage medium
CN116048874A (en) * 2022-11-08 2023-05-02 国网上海市电力公司 Data backup method and system based on cloud environment
CN116467275A (en) * 2023-04-23 2023-07-21 北京沃东天骏信息技术有限公司 Shared remote storage method, apparatus, system, electronic device and storage medium
CN116680233A (en) * 2023-05-11 2023-09-01 阿里巴巴(中国)有限公司 File access method, system, electronic equipment and machine-readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11301165B2 (en) * 2018-04-26 2022-04-12 International Business Machines Corporation Accelerating shared file checkpoint with local burst buffers

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102447712A (en) * 2012-01-20 2012-05-09 华为技术有限公司 Method and system for interconnecting nodes in content delivery network (CDN) as well as nodes
CN108780458A (en) * 2017-12-08 2018-11-09 深圳市大疆创新科技有限公司 A kind of page cache processing method, device and server
CN112995753A (en) * 2019-12-16 2021-06-18 中兴通讯股份有限公司 Media stream distribution method, CDN node server, CDN system and readable storage medium
CN116048874A (en) * 2022-11-08 2023-05-02 国网上海市电力公司 Data backup method and system based on cloud environment
CN116467275A (en) * 2023-04-23 2023-07-21 北京沃东天骏信息技术有限公司 Shared remote storage method, apparatus, system, electronic device and storage medium
CN116680233A (en) * 2023-05-11 2023-09-01 阿里巴巴(中国)有限公司 File access method, system, electronic equipment and machine-readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种可扩展分布式RAID存储集群系统;章宏灿;薛巍;舒继武;;计算机研究与发展;20080415(04);全文 *

Also Published As

Publication number Publication date
CN117615013A (en) 2024-02-27

Similar Documents

Publication Publication Date Title
US10958752B2 (en) Providing access to managed content
US10789217B2 (en) Hierarchical namespace with strong consistency and horizontal scalability
CN106790434B (en) Network data management method, network attached storage gateway and storage service system
US8914457B2 (en) Caching of nodes in cache cluster
CN106775446B (en) Distributed file system small file access method based on solid state disk acceleration
US11297031B2 (en) Hierarchical namespace service with distributed name resolution caching and synchronization
US20040030731A1 (en) System and method for accessing files in a network
US20110307533A1 (en) Data managing system, data managing method, and computer-readable, non-transitory medium storing a data managing program
CN111274310A (en) Distributed data caching method and system
JPH11120048A (en) Device and method for data caching of clinet-server decentralized system and medium where data caching program is recorded
CN104811493A (en) Network-aware virtual machine mirroring storage system and read-write request handling method
US20240028583A1 (en) Distributed data processing
CN108777718B (en) Method and device for accessing read-write-more-less system through client side by service system
CN111399760B (en) NAS cluster metadata processing method and device, NAS gateway and medium
US20190370374A1 (en) Bloom filter series
CN113010549A (en) Data processing method based on remote multi-active system, related equipment and storage medium
US20180189177A1 (en) Distributed data object management method and apparatus
US8543700B1 (en) Asynchronous content transfer
CN117615013B (en) File searching method, device, equipment and readable storage medium
JP2005063374A (en) Data management method, data management device, program for the same, and recording medium
CN112130747A (en) Distributed object storage system and data read-write method
US9922031B2 (en) System and method for efficient directory performance using non-persistent storage
US7058773B1 (en) System and method for managing data in a distributed system
CN113282563A (en) File gateway high availability implementation method based on object storage and electronic equipment
CN113849119A (en) Storage method, storage device, and computer-readable storage medium

Legal Events

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