CN117194439B - Method for creating resource storage system, electronic equipment and storage medium - Google Patents

Method for creating resource storage system, electronic equipment and storage medium Download PDF

Info

Publication number
CN117194439B
CN117194439B CN202311476244.2A CN202311476244A CN117194439B CN 117194439 B CN117194439 B CN 117194439B CN 202311476244 A CN202311476244 A CN 202311476244A CN 117194439 B CN117194439 B CN 117194439B
Authority
CN
China
Prior art keywords
index
resource
exclusive
directory
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
CN202311476244.2A
Other languages
Chinese (zh)
Other versions
CN117194439A (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 CN202311476244.2A priority Critical patent/CN117194439B/en
Publication of CN117194439A publication Critical patent/CN117194439A/en
Application granted granted Critical
Publication of CN117194439B publication Critical patent/CN117194439B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a method for creating a resource storage system, electronic equipment and a storage medium, which are applied to the storage equipment, wherein the storage equipment is provided with a plurality of storage media; the method comprises the following steps: acquiring a domain name, and creating a cache directory and an index node associated with the cache directory according to the domain name; wherein, the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the index nodes; creating exclusive catalogues corresponding to the domain names respectively aiming at all storage media, and mapping the index nodes to the created exclusive catalogues respectively so that resources matched with any index node under the domain names are stored in the exclusive catalogues corresponding to the index node; the number of index nodes corresponding to each exclusive directory is positively correlated with the capacity of the storage medium to which the exclusive directory belongs.

Description

Method for creating resource storage system, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method for creating a resource storage system, an electronic device, and a storage medium.
Background
The content delivery network system (Content Delivery Network, CDN) is a network architecture that provides efficient content delivery by deploying servers at multiple geographic locations, and is capable of redirecting a user's request to a service node closest to the user in real time according to network traffic and comprehensive information such as connection, load conditions of each node, distance to the user, and response time, so that the user can obtain required resources nearby, solve the network congestion condition, and improve the response speed of the user to access a website.
In the related art, in order to save broadband and improve the access speed of clients, a CDN manufacturer may cache more data in an edge node as much as possible, so as to avoid acquiring resource data to an upper node or a source station. However, the cache function of the currently widely used nmginx is relatively single, and only one directory can be configured for a certain domain name to be used as a cache, and when a plurality of hard disks are provided on one physical server, the plurality of hard disks need to be virtualized into one hard disk by a RAID method, and then the virtual hard disk is mounted as one directory to be used.
In this way, if the storage capacities of the plurality of hard disks are different, the usage rate between the respective hard disks cannot be balanced, and load balancing of the plurality of hard disks cannot be ensured; meanwhile, because a plurality of domain names share one cache space, under the condition that a lock is needed to be held for searching the red-black tree to access the resource, a plurality of access requests cannot be processed at the same time.
Disclosure of Invention
In view of the foregoing, the present application provides a method for creating a resource storage system, an electronic device, and a storage medium, so as to solve the deficiencies in the related art.
According to an embodiment of a first aspect of the present application, there is provided a method for creating a resource storage system, applied to a storage device, where the storage device is equipped with a plurality of storage media; the method comprises the following steps:
acquiring a domain name, and creating a cache directory and an index node associated with the cache directory according to the domain name; wherein, the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the index nodes;
creating exclusive catalogues corresponding to the domain names respectively aiming at all storage media, and mapping the index nodes to the created exclusive catalogues respectively so that resources matched with any index node under the domain names are stored in the exclusive catalogues corresponding to the index node; the number of index nodes corresponding to each exclusive directory is positively correlated with the capacity of the storage medium to which the exclusive directory belongs.
According to an embodiment of a second aspect of the present application, there is provided a resource access method applied to a storage device, the storage device being equipped with a plurality of storage media; the method comprises the following steps:
Acquiring a domain name and a corresponding resource path of a target resource, and determining a cache directory corresponding to the domain name and an index value in an index set corresponding to the target resource; the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the associated index nodes in the cache directory;
according to the index value, determining an index node of the target resource in the cache directory, and further determining an exclusive directory of the target resource in each storage medium; the index nodes are respectively mapped to the exclusive catalogs corresponding to the domain names in all storage media, so that resources matched with any index node under the domain names are stored in the exclusive catalogs corresponding to the index nodes, and the number of the index nodes corresponding to each exclusive catalogs is positively correlated with the capacity of the storage media to which the exclusive catalogs belong;
and accessing the target resource in the exclusive directory.
According to an embodiment of a third aspect of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method according to the first aspect when executing the computer program.
According to an embodiment of a fourth aspect 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 steps of the method according to the first aspect.
In the technical scheme provided by the application, the resource cache directory of the domain name and the index nodes associated with the cache directory can be created according to the domain name, and the resources under the domain name are uniformly mapped to each index value in the predefined index set. Because the index value and the index nodes in the cache directory are in one-to-one correspondence, the resources under the domain name can be uniformly distributed in each index node of the cache directory. Then, because a plurality of storage media are assembled in the storage device applying the method, the exclusive catalogs corresponding to the domain names can be respectively created for the storage media, and the index nodes are respectively mapped to the created exclusive catalogs, so that the resources matched with any index node under the domain names can be accurately stored in the exclusive catalogs corresponding to the index nodes. The number of index nodes corresponding to each exclusive directory is positively correlated with the capacity of the storage medium to which the exclusive directory belongs, so that the number of resources stored in each storage medium can be matched with the capacity of the storage medium. By applying the technical scheme, on the basis that a plurality of storage media in the storage device can be combined to provide integral cache service, the utilization rate of each storage medium is kept relatively balanced, and load balancing among the plurality of storage media is realized; meanwhile, as each domain name corresponds to an independent cache space, a plurality of access requests can be allowed to search resources at the same time, and the access efficiency of the resources during access is improved; and when the cache acceleration is not needed for the domain name, the storage space can be quickly released by directly deleting the cache directory corresponding to the domain name.
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 embodiments of the application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following description will briefly introduce the drawings that are required to be used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present application, and other drawings may also be obtained according to these drawings for a person having ordinary skill in the art.
FIG. 1 is a flow chart illustrating a method of creating a resource storage system according to an exemplary embodiment of the present application;
FIG. 2 is a catalog schematic diagram of a resource storage system shown in accordance with an exemplary embodiment of the present application;
FIG. 3 is a flow chart of a method of resource access shown in an exemplary embodiment of the present application;
FIG. 4 is a schematic diagram of a creation device of a resource storage system, as illustrated in an exemplary embodiment of the present application;
FIG. 5 is a schematic diagram of a creation device of a resource storage system, as illustrated in an exemplary embodiment of the present application;
FIG. 6 is a schematic diagram of a creation device of a resource storage system, as illustrated in an exemplary embodiment of the present application;
FIG. 7 is a schematic diagram of a resource access device according to an exemplary embodiment of the present application;
FIG. 8 is a schematic diagram of a resource access device according to an exemplary embodiment of the present application;
fig. 9 is a schematic structural view of an electronic device according to an exemplary embodiment of the present 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 embodiments are not representative of all implementations consistent with one or more embodiments of the present application. Rather, they are merely examples of apparatus and methods that are consistent with aspects of one or more embodiments of the present application, as detailed in the accompanying claims.
It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described herein. In some other embodiments, the method may include more or fewer steps than described herein. Furthermore, individual steps described in this application may be described as being broken down into multiple steps in other embodiments; while various steps described in this application may be combined into a single step in other embodiments.
A content delivery network system (Content Delivery Network, CDN) is a network architecture that provides efficient content delivery by deploying servers in multiple geographic locations, the principle of which is to cache the resources of a website (e.g., pictures, videos, CSS files, etc.) onto the server node closest to the user. When a user requests to access a website, the CDN system can redirect the user's request to the service node closest to the user according to the network flow, the connection of each node, the load condition, the distance from the user, the response time and other comprehensive information, and transmit the resource from the closest server node to the user without acquiring the resource from a source server, so that the bottleneck and links which possibly affect the data transmission speed and stability on the Internet are avoided as much as possible, the resource is transmitted faster and more stably, the condition of network congestion is solved, and the response speed of the user for accessing the website is improved.
In the related art, CDN vendors typically use nginnx to provide caching services. Nginx is a high-performance HTTP and reverse proxy Web server, but has a single caching function, and can only configure a directory for a domain name to serve as a cache. However, nmginx is not distributed software, and when some websites need to cache a large amount of resources, creating only one directory in a single hard disk may cause a situation that the capacity cannot be met. In this case, it is necessary to prepare a plurality of hard disks on a physical server as a hard disk by using a RAID method, mount the virtual hard disk as a directory for use, and create a cache directory for each domain name under the directory.
However, in the case of adopting the above manner, if the storage capacities of the plurality of hard disks are different, the usage rate between the respective hard disks cannot be equalized, and load balancing of the plurality of hard disks cannot be ensured; meanwhile, since a plurality of domain names share a cache space, and when accessing resources, a lock is needed to search the red-black tree, the above manner cannot process a plurality of access requests at the same time. In addition, in the above manner, online capacity expansion or capacity contraction cannot be performed on the hard disk on the physical server, and once the RAID controller is damaged, all stored resource data are lost; in addition, since the cache resource is required to be named by using a string composed of hash values when the system is storing, if all domain names share a cache directory, it is impossible to distinguish which domain name the cache resource belongs to, so that the cache cannot be deleted immediately, and the automatic deletion of the nmginx can be waited after the expiration of the cache.
In addition, in the related art, a plurality of storage media are usually deployed on the same cache server, for example, a solid state disk and a mechanical hard disk are deployed on the cache server at the same time. However, the present nmginx does not support hierarchical caching according to the access heat of the cache resources, so that the characteristics of various storage media cannot be effectively utilized for storage, the hardware cost cannot be reduced, and the storage performance and the cache capacity are affected.
In order to solve the above-mentioned problems, the present application proposes a method for creating a resource storage system, an electronic device, and a storage medium, which can create a resource cache directory of a domain name and index nodes associated with the cache directory according to the domain name, and uniformly map resources under the domain name to index values in a predefined index set. Because the index value and the index nodes in the cache directory are in one-to-one correspondence, the resources under the domain name can be uniformly distributed in each index node of the cache directory. Then, because a plurality of storage media are assembled in the storage device applying the method, the exclusive catalogs corresponding to the domain names can be respectively created for the storage media, and the index nodes are respectively mapped to the created exclusive catalogs, so that the resources matched with any index node under the domain names can be accurately stored in the exclusive catalogs corresponding to the index nodes. The number of index nodes corresponding to each exclusive directory is positively correlated with the capacity of the storage medium to which the exclusive directory belongs, so that the number of resources stored in each storage medium can be matched with the capacity of the storage medium. By applying the technical scheme, on the basis that a plurality of storage media in the storage device can be combined to provide integral cache service, the utilization rate of each storage medium is kept relatively balanced, and load balancing among the plurality of storage media is realized; meanwhile, as each domain name corresponds to an independent cache space, a plurality of access requests can be allowed to search resources at the same time, and the access efficiency of the resources during access is improved.
In an exemplary embodiment, the method for creating the resource storage system of the present application may be applied to a storage device. The storage device may be a physical server comprising an independent host, or may be a virtual server carried by a host cluster, for processing resource access requests and storing resources in a source server. Specifically, when the storage device receives a resource access request, if no corresponding resource exists in the storage device, the resource is requested to the source server, and the resource is stored in the current storage device after being acquired, so that the resource is directly returned when the resource access request for the resource is received next time.
In an exemplary embodiment, the resource access request may be a resource access request forwarded by another storage device, or may be directly from the electronic device. Here, the electronic device may include any type of mobile phone, tablet device, notebook computer, palm computer (PDAs, personal Digital Assistants), wearable device (e.g., smart glasses, smart watch, etc.), outdoor sharing device (e.g., smart mirror device, smart billboard, etc.), etc., which is not limited in this specification. In operation, the electronic device may interact with the storage device via a network, which may include in particular various types of wired or wireless networks, such as a public switched telephone network (Public Switched Telephone Network, PSTN) and the internet.
FIG. 1 is a flowchart of a method of creating a resource storage system according to an exemplary embodiment of the present application, including:
s101, acquiring a domain name, and creating a cache directory and an index node associated with the cache directory according to the domain name; wherein the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the index nodes.
S102, respectively creating exclusive catalogs corresponding to the domain names for all storage media, and respectively mapping the index nodes to the created exclusive catalogs so that resources matched with any index node under the domain names are stored in the exclusive catalogs corresponding to the index node; the number of index nodes corresponding to each exclusive directory is positively correlated with the capacity of the storage medium to which the exclusive directory belongs.
In an exemplary embodiment, the storage device may first obtain a domain name that requires the CDN to provide a resource caching service, and create a corresponding cache directory and a plurality of inodes associated with the cache directory for the domain name. Specifically, a unique identifier may be allocated to each domain name that needs to provide a resource caching service, and a corresponding cache directory is established using the identifier, for example, an ID, a unique string, and the like may be allocated to each domain name as the identifier. It can be understood that there are multiple resources to be stored under each domain name, so that the resources under each domain name can be uniformly mapped to each index value in the predefined index set, and then in the case that there is a one-to-one correspondence between the index value and the index node in the cache directory, the resources under each domain name can be uniformly mapped to multiple index nodes in the cache directory.
In an exemplary embodiment, since a plurality of storage media are mounted on the storage device, it is possible to create exclusive directories corresponding to the domain name in each storage medium, and map inodes in the cache directory to the created exclusive directories, respectively. Under the condition that the resources under each domain name are uniformly mapped to the index nodes in the cache directory, the resources matched with any index node under any domain name can be stored into the exclusive directory corresponding to the index node in the cache directory corresponding to the domain name, namely, the exclusive directory actually storing the resources in the storage medium can be found through the index node. Specifically, a corresponding subdirectory can be established under each exclusive directory according to the index node, and the resources matched with any index node are stored to the subdirectory under the corresponding exclusive directory, so that the storage resources are better divided and stored.
It should be noted that, in each storage medium, the number of index nodes corresponding to each dedicated directory is positively correlated with the capacity of the storage medium to which the dedicated directory belongs, that is, the greater the capacity of a storage medium, the greater the number of index nodes corresponding to the dedicated directory of the storage medium. For example, where storage device a is populated with two storage media of 10TB and 6TB, and there are 16 inodes for the cache directory of the domain name "example.
By applying the technical scheme, on the basis that a plurality of storage media in the storage device can be combined to provide integral cache service, the utilization rate of each storage medium is kept relatively balanced, and load balancing among the plurality of storage media is realized; meanwhile, each domain name corresponds to an independent cache space, and under the condition that a lock is needed to be held for searching the red black trees to access the resources, a plurality of different red black trees are accessed, so that a plurality of access requests can be allowed to search the resources at the same time, and the access efficiency of the resources during access is improved.
In an exemplary embodiment, the last bit value of the preset length of the target hash value may be used as an index value in a predefined index set, so that the resource is uniformly mapped to each index value in the index set, where the target hash value is a hash value obtained by performing consistent hash calculation on a resource path of the resource under the domain name. It will be appreciated that each resource to be stored has a corresponding resource access path in the source server, for example, when a request is made for "example, com/a.mp4", the "example, com" is a domain name, and the "a.mp4" is the resource access path. And performing consistent hash calculation on the resource access path to obtain a target hash value corresponding to the resource, such as 17ef0e43f96f9 a. It will also be appreciated that in performing consistent hash calculations on any resource path, the possible values of each bit in the hash value, such as the above-mentioned "17ef0e43f96f9a" being the target hash value represented using hexadecimal, may be known in advance, where each bit may be any one of the values "0~f", for a total of 16 possible values. At this time, if the last bit of the target hash value is used as the basis for dividing the resource, i.e. the last bit of the target hash value is taken, the index value has 16 possibilities (1×16=16), and simultaneously 16 index nodes corresponding to the index value need to be built in the cache directory; if the last two bits of the target hash value are taken as the basis for partitioning resources, i.e. the last two bits of the target hash value are taken, the index value has 256 possibilities (16×16=256), and 256 index nodes corresponding to the index value also need to be built in the cache directory at the same time, and so on.
By applying the technical scheme, the resources can be quite uniformly mapped to each index value in the predefined index set, and meanwhile, as the index values are in one-to-one correspondence with the index nodes and the resources matched with any index node can be stored in the exclusive catalogues of different storage media corresponding to the index node, the utilization rate of each storage medium is better ensured to be kept relatively balanced.
In an exemplary embodiment, inodes associated with cache directories may be directed to dedicated directories in respective storage media through soft connections. The soft connection can establish a different new link for a certain resource at other positions except the storage position of the resource, and the resource can be directly accessed by accessing the established new link without changing the position of the resource. By the method, the index nodes of the cache directory can be accurately mapped to the exclusive directory in each storage medium, the resource can be directly and effectively obtained under the condition that the index nodes corresponding to the resource are known, and the guarantee is provided for the subsequent access of the storage resource.
In an exemplary embodiment, the storage medium may also be expanded or contracted. The storage medium is expanded or contracted as the capacity of the storage medium is changed, for example, one or more storage media are added or subtracted in the storage device, or any one of the storage media is replaced with a larger or smaller storage medium, etc. In this case, the capacity of each storage medium in the storage device may be redetermined, and based on the capacity of each storage medium, the index node corresponding to the exclusive directory in each storage medium may be reassigned, and the mapping relationship between the exclusive directory and the index node may be further updated. In the previous example, the storage device a is originally equipped with two storage media of 10TB and 6TB, and one storage medium of 8TB is added, so that in the case that the cache directory for the domain name "example. Com" has 16 index nodes in total, the index nodes corresponding to the exclusive directories in the three storage media are reassigned: the exclusive directory in the storage medium of 10TB may correspond to 7 of the index nodes, the exclusive directory in the storage medium of 8TB may correspond to 5 of the index nodes, and the exclusive directory in the storage medium of 6TB may correspond to 4 of the index nodes.
In an exemplary embodiment, there may be a case where a resource caching service is not required for a domain name, and all resources cached under the domain name need to be purged. Specifically, when a resource clearing instruction for any domain name is received, a cache directory corresponding to the domain name may be determined first. And then, deleting the cache directory, each index node associated with the cache directory and the exclusive directory corresponding to the index nodes. Because the index nodes in the cache directory are respectively mapped to the exclusive directories in each storage medium, the actual storage position of the resources under the domain name can be accurately found under the condition that the cache directory is determined, and all the stored resources under the domain name can be cleared by deleting the cache directory and the corresponding exclusive directory. By applying the technical scheme, on the basis that a plurality of storage media in the storage device are combined to provide the whole cache service, all resources under any domain name can be rapidly and accurately deleted, the space occupied by the cache file of the domain name can be immediately cleared, and the automatic deletion after the expiration of the cache is not required.
In an exemplary embodiment, the storage device may be equipped with multiple types of storage media, with different types of storage media having different read-write capabilities. For example, the storage device may be simultaneously equipped with a solid state disk, a mechanical hard disk, or other high-speed storage medium; taking a solid state disk and a mechanical hard disk as examples, the mechanical hard disk has large storage capacity, but has poor random read-write performance (a large number of random reads and writes exist in CDN cache); the solid state disk has high random read-write performance, but the capacity is lower than that of a mechanical hard disk, and the cost is higher. In this case, the virtual storage space can be generated for the storage medium with relatively lower read-write performance by using the Bcache tool, the resource with relatively higher request times in the preset period is stored by using the storage medium with relatively higher read-write performance, and the resource with relatively lower request times in the preset period is stored by using the storage medium with relatively lower read-write performance, so that the resource with frequent request can be returned to the requesting party more quickly, and the access efficiency of the hot resource is improved. Here, the preset period may be a period of time set by a technician according to a requirement, which is not limited in the present application.
Specifically, the Bcache technology can enable a solid state disk to generate a new virtual Bcache disk for each mechanical hard disk, and the capacity of the Bcache disk is equal to that of the mechanical hard disk, so that resources can be cached. For example, a high performance solid state disk, such as an NVMe SSD, may be configured on a cache server for multiple mechanical disks. Assuming that four mechanical hard disks are respectively HD_ A, HD _ B, HD _ C, HD _D and one NVMe solid state hard disk NVMe_0n1 on a server, binding HD_A with NVMe_0n1 by using make-Bcache in a Bche tool set to generate a new bcche disk bcche_0, and generating bcche_1, bcche_2 and bcche_3 for other three disks by the same method. Therefore, the four Bcache disks can be used as common storage disks to be used as CDN cache disks.
Specifically, when data is written into the bcache disk, the data is firstly cached in the solid state disk, and then written into the mechanical hard disk when a certain amount of data is reached, so that a plurality of random writing is changed into partial sequential writing, and the writing performance of the mechanical hard disk is improved. When the resource is read from the bcache disk, whether the resource exists or not is firstly searched in the solid-state cache disk, if so, the resource is directly returned, if not, the resource is read from the mechanical hard disk, then the resource is simultaneously cached in the solid-state cache disk, and the resource can be directly read from the solid-state cache disk when being read again next time.
Meanwhile, the Bcache technology stores the access sequence of cache resources in the memory by using an LRU algorithm in the bcche virtual disk, eliminates the resources with the minimum request times in a preset period every time when the cache space is nearly full, and eliminates the resources, so that the bcche technology can carry out hierarchical caching according to the heat, and the hottest data is cached in the high-performance cache disk, thereby ensuring the access speed.
In the technical scheme provided by the application, the solid state disk can be used for accelerating the mechanical hard disk through the Bcache technology, the Bcache technology is used for providing a cache accelerating function for the mechanical hard disk, and the setting of hierarchical cache according to the heat is completed. The hardware cost can be reduced, and the cache capacity can be improved without affecting the performance. Meanwhile, because the Bcache technology is an open source technical scheme in Linux, the implementation is very simple, and additional maintenance is not needed, so that technicians do not need to additionally develop related components, and other massive and complex software such as Apache Traffic Server is not needed, and the labor cost and the economic cost are reduced.
The method of creating a resource storage system will be illustrated in conjunction with a directory schematic of the resource storage system shown in fig. 2.
As shown in fig. 2, assuming that a domain name requiring a resource caching service is "example. Com", an unused ID of 100 may be assigned to the domain name, and a cache directory of the domain name, such as "/dev/shm/100", is created on a storage device using the ID. The directory includes a plurality of index nodes, and the number of index nodes needs to be matched with the possible value of the last bit of the preset length of the target hash value of the resource path, so when the target hash value is represented by hexadecimal system and the last 1 bit of the target hash value is taken as the resource division basis, 16 corresponding index nodes are needed under the cache directory "/dev/shm/100", which are respectively 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and a, b, c, d, e, f.
Thereafter, if there are four storage media A, B, C, D in the storage device, then a proprietary directory for the domain name will be created in the four storage media, respectively "/disk_a/100", "/disk_b/100", "/disk_c/100", "/disk_d/100", respectively. Wherein, since the capacity of the storage medium a is 3TB, the capacity of the storage medium B is 3TB, the capacity of the storage medium C is 5TB, and the capacity of the storage medium D is 5TB, the number of index nodes corresponding to each exclusive directory is allocated correspondingly according to the capacity of the storage medium, and corresponding subdirectories are built in the exclusive directory. The exclusive directory "/disk_a/100" in the storage medium A corresponds to the index nodes 0-2, the exclusive directory "/disk_b/100" in the storage medium B corresponds to the index nodes 3-5, the exclusive directory "/disk_c/100" in the storage medium C corresponds to the index node 6~a, and the exclusive directory "/disk_D/100" in the storage medium D corresponds to the index nodes B-f. At this time, corresponding soft connections can be created in each index node of the cache directory, so that each index node points to a subdirectory in the corresponding exclusive directory, for example, soft connection of/dev/shm/100/0 to/disk_a/100/0. At this time, the association relationship among the domain name, the cache directory and the exclusive directory is established, and a resource storage system capable of realizing load balancing among a plurality of storage media is obtained.
Correspondingly, the application also provides a resource access method which is applied to the storage equipment, wherein a plurality of storage media are assembled on the storage equipment; the method is as shown in fig. 3, and comprises the following steps:
s301, obtaining a domain name and a corresponding resource path to which a target resource belongs, and determining a cache directory corresponding to the domain name and an index value in an index set corresponding to the target resource; wherein the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with associated index nodes in the cache directory.
S302, determining index nodes of the target resources in the cache catalogs according to the index values, and further determining exclusive catalogs of the target resources in each storage medium; the index nodes are respectively mapped to the exclusive catalogs corresponding to the domain names in the storage media, so that resources matched with any index node under the domain names are stored in the exclusive catalogs corresponding to the index nodes, and the number of the index nodes corresponding to each exclusive catalogs is positively correlated with the capacity of the storage media to which the exclusive catalogs belong.
S303, accessing the target resource in the exclusive directory.
In an exemplary embodiment, for the first requested resource, the storage system needs to first obtain the resource from the source server and store the resource in the storage device, and when the subsequent requester issues an access request to the resource again, the resource in the storage device can be directly returned. Specifically, the resource to be accessed can be used as a target resource, a domain name and a corresponding resource path to which the target resource belongs are obtained, and a cache directory corresponding to the domain name and an index value in an index set corresponding to the target resource are determined. If the index value in the previous step is matched with the possibility of the last bit value of the preset length of the target hash value, the resource path can be calculated through a consistent hash algorithm, and the target hash value of the resource path is obtained. After the index value of the target resource is obtained, the index node of the target resource in the cache directory can be further determined, and the exclusive directory of the target resource in each storage medium is further determined. And finally, accessing the exclusive catalogue to obtain the target resource.
Continuing with the previous example, if a request is made for "example. Com/A.mp4," example. Com "is the domain name and" A.mp4 "is the resource access path. Since the ID assigned to the domain name "example. Com" is 100, the cache directory corresponding to the domain name can be found to be "/dev/shm/100". Meanwhile, consistency hash calculation can be performed on the resource path, so that a target hash value corresponding to the resource is 17ef0e43f96f9 a. Since the target hash value is represented by hexadecimal system and the last 1 bit of the target hash value is taken as the resource division basis when the resource storage system is created, the last 1 bit in the 17ef0e43f96f9a is "a", namely the index value of the target resource corresponds to the index node a in the cache directory. After that, since the index node a is mapped to the exclusive directory "/disk_a/100" of the storage medium a, the target resource is actually stored in the subdirectory "/disk_a/100/a" under the exclusive directory, and the target resource can be found by accessing the location. If the method of pointing the index node to the exclusive directory through the soft connection is adopted in the process of creating the storage system, the index node a in the cache directory "/dev/shm/100" can be directly accessed, and then the target resource can be directly found.
By applying the technical scheme, under the condition that a plurality of storage media in the storage device are combined to provide the whole cache service, resources can be quickly and accurately accessed, and the resources stored in the storage system are effectively utilized.
In an exemplary embodiment, the cache capacity of a single cache server (i.e., storage device) is limited, and for domain names with large access traffic and particularly large storage sizes, one cache server cannot handle such large access volumes, thus requiring the deployment of many cache servers. In this case, if each cache server directly caches resources according to the received request, the resources cached on each cache server may be repeatedly caused, which further causes waste of storage resources. Therefore, when a resource access request is received, a hash calculation may be performed on a resource path of the target resource, and a target storage device for processing the resource access request may be determined based on the obtained hash value and a predefined correspondence between the hash value and the storage device. If the determined target storage equipment is the current equipment, continuously acquiring the related information of the target resource on the equipment for processing; and if the determined target storage device is other devices, forwarding the request. For example, if the requester makes a request for "example. Com/a. Mp4", the request is first received by the storage device 3. The storage device 3 will perform a hash calculation on "a.mp4" to obtain a hash value of 9, and the request will be forwarded to the storage device 9. If the requestor makes a request for "example. Com/b.mp4", the request is first received by the storage device 3, and a hash calculation is performed on "b.mp4" to obtain a hash value of 3, at which point the storage device 3 will continue to process the request. By applying the technical scheme, the resources can be uniformly stored in all storage devices in the cluster, and the load balance in the whole cluster is realized.
Based on the method for creating the resource storage system provided by the application, the application also provides a device for creating the resource storage system, which is applied to a storage device, wherein a plurality of storage media are assembled on the storage device, see fig. 4, and the device comprises:
a cache directory creation unit 401, configured to obtain a domain name, and create a cache directory and an inode associated with the cache directory according to the domain name; wherein, the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the index nodes;
the exclusive directory creation unit 402 is configured to create exclusive directories corresponding to the domain names for respective storage media, and map the index nodes to the created exclusive directories, so that resources under the domain names, which are matched with any index node, are stored in the exclusive directory corresponding to the index node; the number of index nodes corresponding to each exclusive directory is positively correlated with the capacity of the storage medium to which the exclusive directory belongs.
Optionally, the index value in the index set is the last value of the preset length of the target hash value, and the target hash value is the hash value obtained after the consistent hash calculation is performed on the resource path of the resource under the domain name.
Optionally, the index nodes are mapped to dedicated directories in the respective storage media by:
and pointing the index node to the exclusive catalogue in each storage medium through soft connection.
Optionally, referring to fig. 5, further includes:
a capacity determining unit 403 for re-determining the capacity of each storage medium in the case where expansion or contraction of the storage medium occurs;
an allocation unit 404, configured to reallocate, based on the capacity of each storage medium, an inode corresponding to an exclusive directory in each storage medium, and update a mapping relationship between the exclusive directory and the inode;
and the migration unit 405 is configured to determine a change-dedicated directory in which a change occurs, and migrate the resource stored in the change-dedicated directory to the updated dedicated directory.
Optionally, referring to fig. 6, further includes:
a domain name determining unit 406, configured to determine a cache directory corresponding to the domain name when a resource clearing instruction for the domain name is received;
the deleting unit 407 is configured to delete the cache directory, each index node associated with the cache directory, and an exclusive directory corresponding to the index node.
Optionally, the storage device is provided with a plurality of types of storage media, and the read-write performance of the different types of storage media is different; wherein a storage medium with relatively higher read-write performance is used for storing resources with relatively more request times, and a storage medium with relatively lower read-write performance is used for storing resources with relatively less request times.
Based on the resource access method provided by the application, the application also provides a resource access device, which is applied to a storage device, wherein a plurality of storage media are assembled on the storage device, and referring to fig. 7, the resource access device comprises:
an obtaining unit 501, configured to obtain a domain name to which a target resource belongs and a corresponding resource path, and determine a cache directory corresponding to the domain name and an index value in an index set corresponding to the target resource; the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the associated index nodes in the cache directory;
a determining unit 502, configured to determine, according to the index value, an index node of the target resource in the cache directory, and further determine an exclusive directory of the target resource in each storage medium; the index nodes are respectively mapped to the exclusive catalogs corresponding to the domain names in all storage media, so that resources matched with any index node under the domain names are stored in the exclusive catalogs corresponding to the index nodes, and the number of the index nodes corresponding to each exclusive catalogs is positively correlated with the capacity of the storage media to which the exclusive catalogs belong;
And the accessing unit 503 is configured to access the target resource in the dedicated directory.
Optionally, referring to fig. 8, further includes:
a hash calculation unit 504, configured to perform hash calculation on a resource path of the target resource to obtain a hash value when a resource access request is received;
a storage device determining unit 505, configured to determine a target storage device for processing the resource access request based on the hash value and a predefined correspondence between the hash value and a storage device;
the acquiring unit 501 is specifically configured to: under the condition that the target storage equipment is a current node, acquiring a domain name and a corresponding resource path of a target resource in the resource access request;
and a forwarding unit 506, configured to forward the resource access request to the target storage device if the target storage device is a node other than the current node.
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 invention without undue burden.
Accordingly, the application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method for creating the resource storage system according to any of the embodiments above when executing the computer program.
Referring to fig. 9, at the hardware level, the electronic device includes a processor 902, an internal bus 904, a network interface 906, memory 908, and non-volatile storage 910, although other hardware required for other services is also possible. The processor 902 reads the corresponding computer program from the non-volatile memory 910 into the memory 908 and then runs to form the means of creation of the resource storage system at a logical level. Of course, other implementations, such as logic devices or combinations of hardware and software, are not excluded from the present application, that is, the execution subject of the following processing flows is not limited to each logic unit, but may be hardware or logic devices.
Accordingly, the present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method of creating a resource storage system as described in any of the embodiments above.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, read only compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by the computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The foregoing describes specific embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The terminology used in one or more embodiments of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of one or more embodiments of the application. As used in this application in one or more embodiments 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 in one or more embodiments of the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of one or more embodiments of the present application. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The foregoing description of the preferred embodiment(s) is (are) merely intended to illustrate the embodiment(s) of the present application and is not intended to limit the embodiment(s) of the present application, since any modification, equivalent replacement, improvement or the like which comes within the spirit and principles of the embodiment(s) of the present application is included within the scope of the present application.

Claims (9)

1. A method of creating a resource storage system, characterized by being applied to a storage device, the storage device being equipped with a plurality of storage media; the method comprises the following steps:
acquiring a domain name, and creating a cache directory and an index node associated with the cache directory according to the domain name; wherein, the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the index nodes;
creating exclusive catalogues corresponding to the domain names respectively aiming at all storage media, and mapping the index nodes to the created exclusive catalogues respectively so that resources matched with any index node under the domain names are stored in the exclusive catalogues corresponding to the index node; the number of index nodes corresponding to each exclusive directory is positively correlated with the capacity of a storage medium to which the exclusive directory belongs;
The storage device is provided with a plurality of types of storage media, and the read-write performance of the storage media of different types is different; the virtual storage space is generated for the storage medium with relatively lower read-write performance by using the storage medium with relatively higher read-write performance through Bcache, so that the storage medium with relatively higher read-write performance stores more resources with relatively higher request times in a preset period, and the storage medium with relatively lower read-write performance stores fewer resources with relatively lower request times in the preset period.
2. The method of claim 1, wherein an index value in the index set is a last value of a preset length of a target hash value, and the target hash value is a hash value obtained after performing consistent hash calculation on a resource path of a resource under the domain name.
3. The method of claim 1, wherein the inodes are mapped to dedicated directories in respective storage media by:
and pointing the index node to the exclusive catalogue in each storage medium through soft connection.
4. The method as recited in claim 1, further comprising:
the capacity of each storage medium is redetermined under the condition that the storage medium expands or contracts;
Based on the capacity of each storage medium, reallocating the index node corresponding to the exclusive directory in each storage medium, and updating the mapping relation between the exclusive directory and the index node;
and determining a change exclusive directory in which the change occurs, and migrating the resources stored in the change exclusive directory to the updated exclusive directory.
5. The method as recited in claim 1, further comprising:
under the condition that a resource clearing instruction aiming at the domain name is received, determining a cache directory corresponding to the domain name;
and deleting the cache directory, each index node associated with the cache directory and the exclusive directory corresponding to the index node.
6. A resource access method, characterized by being applied to a storage device, the storage device being equipped with a plurality of storage media; the method comprises the following steps:
acquiring a domain name and a corresponding resource path of a target resource, and determining a cache directory corresponding to the domain name and an index value in an index set corresponding to the target resource; the resources under the domain name can be uniformly mapped to each index value in a predefined index set, and the index values are in one-to-one correspondence with the associated index nodes in the cache directory;
According to the index value, determining an index node of the target resource in the cache directory, and further determining an exclusive directory of the target resource in each storage medium; the index nodes are respectively mapped to the exclusive catalogs corresponding to the domain names in all storage media, so that resources matched with any index node under the domain names are stored in the exclusive catalogs corresponding to the index nodes, and the number of the index nodes corresponding to each exclusive catalogs is positively correlated with the capacity of the storage media to which the exclusive catalogs belong;
accessing the target resource in the exclusive directory;
the storage device is provided with a plurality of types of storage media, and the read-write performance of the storage media of different types is different; the virtual storage space is generated for the storage medium with relatively lower read-write performance by using the storage medium with relatively higher read-write performance through Bcache, so that the storage medium with relatively higher read-write performance stores more resources with relatively higher request times in a preset period, and the storage medium with relatively lower read-write performance stores fewer resources with relatively lower request times in the preset period.
7. The method as recited in claim 6, further comprising:
Under the condition that a resource access request is received, carrying out hash calculation on a resource path of the target resource to obtain a hash value;
determining a target storage device for processing the resource access request based on the corresponding relation between the hash value and the predefined hash value and the storage device;
and under the condition that the target storage device is the current node, acquiring the domain name and the corresponding resource path to which the target resource belongs comprises the following steps: acquiring a domain name to which a target resource in the resource access request belongs and a corresponding resource path;
and forwarding the resource access request to the target storage device in the case that the target storage device is other nodes except the current node.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any one of claims 1 to 7 when executing the computer program.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
CN202311476244.2A 2023-11-07 2023-11-07 Method for creating resource storage system, electronic equipment and storage medium Active CN117194439B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311476244.2A CN117194439B (en) 2023-11-07 2023-11-07 Method for creating resource storage system, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311476244.2A CN117194439B (en) 2023-11-07 2023-11-07 Method for creating resource storage system, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117194439A CN117194439A (en) 2023-12-08
CN117194439B true CN117194439B (en) 2024-03-22

Family

ID=89002042

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311476244.2A Active CN117194439B (en) 2023-11-07 2023-11-07 Method for creating resource storage system, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117194439B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102164186A (en) * 2011-05-31 2011-08-24 互动在线(北京)科技有限公司 Method and system for realizing cloud search service
CN107087031A (en) * 2017-05-10 2017-08-22 浙江宇视科技有限公司 A kind of storage resource load-balancing method and device
CN112650721A (en) * 2020-12-29 2021-04-13 杭州趣链科技有限公司 File storage method, device, system and equipment
CN113608851A (en) * 2021-08-03 2021-11-05 北京金山云网络技术有限公司 Task allocation method and device, electronic equipment and storage medium
CN114595167A (en) * 2022-02-15 2022-06-07 阿里巴巴(中国)有限公司 Distributed cache system, method and device
CN115795187A (en) * 2022-06-29 2023-03-14 杭州海康威视数字技术股份有限公司 Resource access method, device and equipment
CN115826845A (en) * 2021-09-18 2023-03-21 北京金山云网络技术有限公司 Storage resource allocation method and device, storage medium and electronic device
CN116339623A (en) * 2023-02-23 2023-06-27 北京奇艺世纪科技有限公司 Data storage method and device based on consistent hash algorithm

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8818970B2 (en) * 2011-04-08 2014-08-26 Symantec Corporation Partitioning a directory while accessing the directory

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102164186A (en) * 2011-05-31 2011-08-24 互动在线(北京)科技有限公司 Method and system for realizing cloud search service
CN107087031A (en) * 2017-05-10 2017-08-22 浙江宇视科技有限公司 A kind of storage resource load-balancing method and device
CN112650721A (en) * 2020-12-29 2021-04-13 杭州趣链科技有限公司 File storage method, device, system and equipment
CN113608851A (en) * 2021-08-03 2021-11-05 北京金山云网络技术有限公司 Task allocation method and device, electronic equipment and storage medium
CN115826845A (en) * 2021-09-18 2023-03-21 北京金山云网络技术有限公司 Storage resource allocation method and device, storage medium and electronic device
CN114595167A (en) * 2022-02-15 2022-06-07 阿里巴巴(中国)有限公司 Distributed cache system, method and device
CN115795187A (en) * 2022-06-29 2023-03-14 杭州海康威视数字技术股份有限公司 Resource access method, device and equipment
CN116339623A (en) * 2023-02-23 2023-06-27 北京奇艺世纪科技有限公司 Data storage method and device based on consistent hash algorithm

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于B+树的数据索引存储;耿庆田;狄婧;常亮;赵宏伟;;吉林大学学报(理学版)(第06期);全文 *

Also Published As

Publication number Publication date
CN117194439A (en) 2023-12-08

Similar Documents

Publication Publication Date Title
US11068395B2 (en) Cached volumes at storage gateways
US9952753B2 (en) Predictive caching and fetch priority
US10887416B2 (en) Efficient high availability and storage efficiency in a multi-site object storage environment
US9268651B1 (en) Efficient recovery of storage gateway cached volumes
US9274956B1 (en) Intelligent cache eviction at storage gateways
CN103067433B (en) A kind of data migration method of distributed memory system, equipment and system
US9330108B2 (en) Multi-site heat map management
US9559889B1 (en) Cache population optimization for storage gateways
US11245774B2 (en) Cache storage for streaming data
CN114860163B (en) Storage system, memory management method and management node
US10482062B1 (en) Independent evictions from datastore accelerator fleet nodes
JP6388339B2 (en) Distributed caching and cache analysis
US20070150492A1 (en) Method and system for allocating file in clustered file system
CN103747073A (en) Distributed caching method and system
JP2009295127A (en) Access method, access device and distributed data management system
US10986065B1 (en) Cell-based distributed service architecture with dynamic cell assignment
US20170168956A1 (en) Block cache staging in content delivery network caching system
US10387043B2 (en) Writing target file including determination of whether to apply duplication elimination
JP6221717B2 (en) Storage device, storage system, and data management program
CN117194439B (en) Method for creating resource storage system, electronic equipment and storage medium
WO2012164735A1 (en) Information processing device, data management method, and data management program
KR100785774B1 (en) Obeject based file system and method for inputting and outputting
WO2021110176A1 (en) Edge system and method for processing data operation request
US11971902B1 (en) Data retrieval latency management system
Lim et al. Imposing Cache: Busy-Aware Cooperative Data Caching in Edge-Cloud Environments

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
CP03 Change of name, title or address

Address after: 310053 room 611-612, Zhuoxin building, No. 3820, South Ring Road, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Hangzhou Youyun Technology Co.,Ltd.

Country or region after: China

Address before: 310053 room 611-612, Zhuoxin building, No. 3820, South Ring Road, Binjiang District, Hangzhou City, Zhejiang Province

Patentee before: Hangzhou Youyun Technology Co.,Ltd.

Country or region before: China

CP03 Change of name, title or address