Content delivery method, virtual server management method, cloud platform, and system
11431791 ยท 2022-08-30
Assignee
Inventors
Cpc classification
H04L67/568
ELECTRICITY
H04L67/288
ELECTRICITY
H04L67/1031
ELECTRICITY
H04L67/5682
ELECTRICITY
H04L67/1097
ELECTRICITY
International classification
G06F15/173
PHYSICS
H04L67/568
ELECTRICITY
H04L67/1097
ELECTRICITY
Abstract
A content delivery method and system, where the content delivery method includes receiving, by a first virtual server, a first request message from a content requester, where the first request message carries a first uniform resource locator (URL) of user-requested content, determining, by the first virtual server according to a cache list maintained by the first virtual server, that one of one or more storage servers managed by the first virtual server has cached the content corresponding to the first URL, and redirecting the first request message to a first storage server that is recorded in the cache list and that has cached the content corresponding to the first URL. A computation capability and a storage capability of a server cluster are separated, and content input/output (I/O) throughput performance is effectively improved.
Claims
1. A method performed by a first virtual server of a content delivery system, wherein the method comprises: managing a first storage server and a second storage server; receiving a first request message comprising a first uniform resource locator (URL) of user-requested content from a content requester; determining, according to a cache list maintained by the first virtual server, that neither the first storage server nor the second storage server caches the user-requested content; determining, according to a consistent hashing algorithm, that the second storage server is configured to cache the user-requested content; redirecting the first request message to the second storage server in response to determining that the second storage server is configured to cache the user-requested content, wherein the first request message instructs the second storage server to retrieve the user-requested content and directly send the user-requested content to the content requester without redirecting to the first virtual server, and wherein the second storage server is a physical server; computing, according to the first URL, a URL hash value of the first URL; obtaining partition hash values of all partitions in a distributed database; querying, based on the consistent hashing algorithm according to the URL hash value, for a partition corresponding to the first URL, wherein the partition is a division of storage servers in the content delivery system, which is divided into at least one partition; determining, according to a partition hash value of the partition and a correspondence stored in the distributed database between the partition hash value and a server hash value of a virtual server, that the first virtual server processes the first URL, wherein each partition in the content delivery system corresponds to one virtual server, determining that a partition storage capacity of the partition is full; determining that storage capacities of the partitions are all full; querying a cache queue for a record having a popularity that is lower than a first threshold; and instructing, according to the cache queue, a storage server corresponding to a partition in the record to delete content corresponding to a URL in the record.
2. The method of claim 1, further comprising: receiving a second request message comprising a second URL of second user-requested content from the content requester; determining, according to the cache list, that either the first storage server or the second storage server has cached the second user-requested content; and redirecting, in response to determining that the first storage server has cached the second user-requested content the second request message to the first storage server, wherein the second request message instructs the first storage server to send the second user-requested content to the content requester.
3. The method of claim 2, wherein before determining that either of the first storage server or the second storage server has cached the second user-requested content, the method further comprises determining, according to the second URL, that the first virtual server processes the second URL.
4. The method of claim 1, wherein before determining that neither the first storage server nor the second storage server caches the user-requested content, the method further comprises determining, according to the first URL, that the first virtual server processes the first URL.
5. The method of claim 1, further comprising: receiving a third request message carrying a third URL of third user-requested content from the content requester; determining, according to the third URL, that a second virtual server processes the third URL; and redirecting the third request message to the second virtual server.
6. The method of claim 1, wherein each storage server in the content delivery system comprises at least one partition, and wherein after redirecting the first request message to the second storage server, the method further comprises: updating popularity information corresponding to the first URL; determining, according to the popularity information, that the user-requested content needs to be cached; determining that a partition storage capacity of the partition is not full; and instructing the second storage server to cache the user-requested content into the partition.
7. The method of claim 1, further comprising: determining that a partition storage capacity of the partition is full; determining that an available storage capacity of at least one of a plurality of partitions managed by the first virtual server is not full; selecting a selected partition of the plurality of partitions that have the available storage capacity; instructing the second storage server to cache the user-requested content into the selected partition; and adding to a record of a cache queue, a URL hash value of the first URL, a partition hash value of the partition, and popularity information corresponding to the first URL.
8. The method of claim 7, wherein each partition of a plurality of partitions has a plurality of partition hash values, wherein one partition hash value of each partition corresponds to one virtual server, and wherein after redirecting the first request message to the second storage server, the method further comprises: receiving, from the second storage server to which the partition belongs, notification information indicating that the partition is full when the partition storage capacity is full; and sending a deletion notification carrying a URL of to-be-deleted content in a partition managed by the first virtual server and having a popularity that is lower than a second threshold to the second storage server, wherein the deletion notification instructs the second storage server to determine, according to popularity information indicating the popularity of the to-be-deleted content, whether to delete the to-be-deleted content.
9. A content delivery system, comprising: a first virtual server, wherein the first virtual server comprises: a memory configured to stored instructions; and a processor configured to execute the instructions, which cause the first virtual server to be configured to: manage a first storage server and a second storage server; receive a first request message comprising a first uniform resource locator (URL) of user-requested content from a content requester; determine, according to a cache list maintained by the first virtual server, that neither the first storage server nor the second storage server caches the user-requested content; determine, according to a consistent hashing algorithm, that the second storage server is configured to cache the user-requested content; redirect the first request message to the second storage server in response to the second storage server being configured to cache the user-requested content, wherein the first request message instructs the second storage server to retrieve the user-requested content and directly send the retrieved user-requested content to the content requester without a second virtual server, and wherein the second storage server is a physical server; compute, according to the first URL, a URL hash value of the first URL; obtain partition hash values of all partitions in a distributed database; query, based on the consistent hashing algorithm according to the URL hash value of the first URL, for a partition corresponding to the first URL, wherein each storage server in the content delivery system is divided into at least one partition; and determine, according to a partition hash value of the partition and a correspondence stored in the distributed database between the partition hash value and a server hash value of a virtual server, that the first virtual server processes the first URL, wherein each partition in the content delivery system corresponds to one virtual server, determine that a partition storage capacity of the partition is full; determine that storage capacities of the partitions are all full; query a cache queue for a record having a popularity that is lower than a first threshold; and instruct, according to the cache queue, a storage server corresponding to a partition in the record to delete content corresponding to a URL in the record.
10. The content delivery system of claim 9, wherein the instructions further cause the first virtual server to be configured to: receive a second request message carrying a second URL of second user-requested content from the content requester; determine, according to the cache list, that either the first storage server or the second storage server has cached the second user-requested content; and when the first storage server has cached the second user-requested content, redirect the second request message to the first storage server, wherein the second request message instructs the first storage server to send the second user-requested content to the content requester.
11. The content delivery system of claim 9, wherein before the first virtual server determines that neither the first storage server nor the second storage server caches the user-requested content, the instructions further cause the first virtual server to be configured to determine, according to the first URL, that the first virtual server processes the first URL.
12. The content delivery system of claim 9, wherein the instructions further cause the first virtual server to be configured to: receive a third request message carrying a third URL of third user-requested content from the content requester; determine, according to the third URL, that a second virtual server processes the third URL; and redirect the third request message to the second virtual server.
13. The content delivery system of claim 9, wherein each of the first storage server and the second storage server comprises at least one partition, and wherein after the first virtual server redirects the first request message to the second storage server, the instructions further cause the first virtual server to be configured to: determine that a partition storage capacity of the partition is not full; and instruct the second storage server to cache the user-requested content into the partition.
14. The content delivery system of claim 9, wherein the instructions further cause the first virtual server to be configured to: determine that a partition storage capacity of the partition is full; determine that an available storage capacity of at least one of a plurality of partitions managed by the first virtual server is not full; select a selected partition of the plurality of partitions that have the available storage capacity; instruct the second storage server to cache the user-requested content into the selected partition; and add, to a record of a cache queue, a URL hash value of the first URL, a partition hash value of the partition, and popularity information corresponding to the first URL.
15. The content delivery system of claim 14, wherein each partition of a plurality of partitions has a plurality of partition hash values, wherein one partition hash value of each partition corresponds to one virtual server, and wherein after the first virtual server redirects the first request message to the second storage server, the instructions further cause the first virtual server to be configured to: receive, from the second storage server to which the partition belongs, notification information indicating that the partition is full when the partition storage capacity is full; and send a deletion notification carrying a URL of to-be-deleted content in a partition managed by the first virtual server and having a popularity that is lower than a second threshold to the second storage server, wherein the deletion notification instructs the second storage server to determine, according to popularity information indicating the popularity of the to-be-deleted content, whether to delete the to-be-deleted content.
16. A computer program product comprising computer-executable instructions stored on a non-transitory computer-readable storage medium that, wherein the non-transitory medium storage comprise computer program instructions, when executed by a processor, reads the computer program instructions to perform, cause an apparatus comprising a first virtual server to: manage a first storage server and a second storage server; receive a first request message comprising a first uniform resource locator (URL) of user-requested content from a content requester; determine, according to a cache list maintained by the first virtual server, that neither the first storage server nor the second storage server caches the user-requested content; determine, according to a consistent hashing algorithm, that the second storage server is configured to cache the user-requested content; redirect the first request message to the second storage server in response the second storage server being configured to cache the user-requested content, wherein the first request message instructs the second storage server to retrieve the user-requested content and directly send the retrieved user-requested content to the content requester without redirecting to the first virtual server, and wherein the second storage server is a physical server; compute, according to the first URL, a URL hash value of the first URL; obtain partition hash values of all partitions in a distributed database; query, based on the consistent hashing algorithm according to the URL hash value of the first URL, for a partition corresponding to the first URL, wherein each storage server in a content delivery system is divided into at least one partition; and determine, according to a partition hash value of the partition and a correspondence stored in the distributed database between the partition hash value and a server hash value of a virtual server, that the first virtual server processes the first URL, wherein each partition in the content delivery system corresponds to one virtual server, determine that a partition storage capacity of the partition is full; determine that storage capacities of the partitions are all full; query a cache queue for a record having a popularity that is lower than a first threshold; and instruct, according to the cache queue, a storage server corresponding to a partition in the record to delete content corresponding to a URL in the record.
17. The computer program product of claim 16, wherein the instructions further cause the first virtual server to: receive a second request message carrying a second URL of second user-requested content from the content requester; determine, according to the cache list, that either the first storage server or the second storage server has cached the second user-requested content; and when the first storage server has cached the second user-requested content, redirect the second request message to the first storage server, wherein the second request message instructs the first storage server to send the second user-requested content to the content requester.
18. The computer program product of claim 17, wherein before the first virtual server determines that neither the first storage server nor the second storage server caches the user-requested content, the instructions further cause the first virtual server to determine, according to the first URL, that the first virtual server processes the first URL.
Description
BRIEF DESCRIPTION OF DRAWINGS
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(14)
(15)
(16)
(17)
(18)
(19)
(20)
(21)
(22)
(23)
DESCRIPTION OF EMBODIMENTS
(24) To make the purpose, technical solutions, and advantages of the embodiments of the present disclosure clearer, the following clearly describes the technical solutions of the embodiments of the present disclosure with reference to the accompanying drawings in the embodiments of the present disclosure.
(25)
(26) In this embodiment of the present disclosure, the intermediate node 102 is referred to as an upper-layer node of the edge node 103, and the central node 101 is referred to as an upper-layer node of the intermediate node 102. If the intermediate node 102 does not cache the content to be accessed using the access request either, the intermediate node 102 needs to first obtain the content from the upper-layer node of the intermediate node 102, and then send the obtained content to the edge node 103.
(27) To overcome a problem of relatively poor I/O performance of a CDN system that is based on cloud computing, in this embodiment of the present disclosure, composition of each CDN node is improved. The CDN node herein may be a central node, an intermediate node, or an edge node. Because an access request of a user is usually redirected first to an edge node, this embodiment of the present disclosure is described using only the edge node in the CDN system as an example. Composition of another CDN node and a content delivery method are similar thereto. For brevity, details are not described herein.
(28) In this embodiment of the present disclosure, the edge node in the CDN system is implemented using a virtual server created using a cloud computing technology and an independent storage server. A computation capability and a storage capability of the servers are separated, the computation capability is implemented using a virtualization technology of cloud computing, and the storage capability is implemented using the independent storage server. Each virtual server may access one or more storage servers. The storage server is a physical server, and performs content I/O without the virtual server, and I/O performance of the CDN system is greatly improved.
(29)
(30) An embodiment of the present disclosure provides a cloud platform. The cloud platform has a function of performing actual behaviors of a cloud platform in a content delivery method and a virtual server management method that are provided in embodiments of the present disclosure. The function may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the foregoing function.
(31) In a possible design, a structure of the cloud platform includes a processor and a transmitter, and the processor is configured to support the cloud platform to perform corresponding functions in the foregoing methods. The transmitter is configured to support the cloud platform to communicate with a storage server to send, to the storage server, information or an instruction in the foregoing methods. The cloud platform may further include a memory, and the memory is coupled to the processor, and stores a program instruction and data necessary to the cloud platform. The cloud platform may further include a receiver, and the receiver is configured to receive a request message sent by UE.
(32) An embodiment of the present disclosure provides a storage server. The storage server has a function of performing behaviors of a storage server in the foregoing method design. The function may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the foregoing function. The module may be software and/or hardware.
(33) In a possible design, a structure of the storage server includes a receiver and a processor, and the receiver is configured to support the storage server to receive instructions such as a request message redirected by the foregoing cloud platform. The processor controls the storage server to send, to a content requester according to the request message received by the receiver, content cached in a partition of the storage server, or first retrieve content corresponding to a URL carried in the request message, and then send the obtained content to the content requester. The storage server may further include a transmitter, and the transmitter is configured to send content to a content requester.
(34) Based on the network architecture shown in
(35) 1. A user requests file content from the load balancing and route server 202 according to a file URL using the UE 201.
(36) 2. The load balancing and route server 202 redirects the user to a virtual server (also referred to as VM 2031) A on a cloud computing platform according to a route scheduling algorithm. A specific route scheduling algorithm may be based on different selection polices, for example, based on a load status of a virtual server, or based on a responding time of a virtual server. In this embodiment of the present disclosure, the cloud computing platform may be briefly referred to as a cloud platform.
(37) 3. The UE 201 requests, from the virtual server A, the file content corresponding to the URL.
(38) 4. The virtual server A determines a virtual server B needing to process the URL. If the virtual server A and the virtual server B are not a same virtual server, the user request is redirected to the virtual server B, and the virtual server B processes the user request. If the virtual server A and the virtual server B are a same virtual server, the virtual server B directly processes the user request without redirection.
(39) The virtual server B determines whether the URL is in a cache queue maintained by the virtual server B. If the URL is in the cache queue of the virtual server B, the virtual server B redirects the user request to a storage server C that is recorded in the cache queue and that corresponds to the URL, and instructs the storage server C to deliver the file content corresponding to the URL to the UE 201. If the URL is not in the cache queue of the virtual server B, the virtual server B determines, according to a consistent hashing algorithm, a storage server D corresponding to the URL, redirects the user request to the storage server D corresponding to the URL, and instructs the storage server D to retrieve the file content corresponding to the URL and deliver the file content to the UE 201.
(40) The storage server C and the storage server D may be a same storage server, or may be different storage servers.
(41) 5. The storage server C or the storage server D deliveries the file content corresponding to the URL to the UE 201.
(42) This embodiment of the present disclosure provides a content delivery method. A virtual server receives a request message sent by UE, processes a URL, carried in the request message, of user-requested file content according to the URL, and redirects the request message to a storage server corresponding to the URL. The storage server sends cached content corresponding to the URL to the UE. A computation capability and a storage capability of a server cluster are separated, the computation capability is implemented using a virtualization technology of cloud computing, and the storage capability is implemented using an independent storage server such that the storage server may directly send content to ULE without a virtual server, and content I/O throughput performance is effectively improved.
(43)
(44) Step 301: A virtual server A receives a request message sent by UE. The request message carries a URL of user-requested content.
(45) In this embodiment of the present disclosure, after receiving the request message sent by the UE, a load balancing and route server redirects the request message to the virtual server A according to a preset policy.
(46) Step 302: The virtual server A determines, according to the URL, a virtual server B processing the URL.
(47) The CDN node includes multiple virtual servers. Each virtual server is responsible for processing some URLs. The virtual server A receiving the request message may be not a virtual server responsible for processing the URL. Therefore, after receiving the request message, the virtual server A further needs to determine, according to the URL carried in the request message, the virtual server B processing the URL.
(48) In this embodiment of the present disclosure, when a CDN system is constructed, a cloud platform establishes a distributed database, and stores a correspondence between a partition and a virtual server in the distributed database. That is, a partition in the correspondence is managed by a corresponding virtual server. A corresponding virtual server may be selected for each partition according to a random selection manner or a consistent hashing algorithm. The determined correspondence is stored in the distributed database for subsequent query. A hash value of a partition is used to identify the partition, and a hash value of a virtual server is used to identify the virtual server.
(49) To determine the virtual server processing the URL, a hash value of the URL may be first computed. Then the distributed database is queried for hash values of all partitions in the CDN node, and a hash value of a partition corresponding to the URL is determined according to the consistent hashing algorithm. Finally, the distributed database is queried according to the hash value of the partition for a hash value of a virtual server that corresponds to the hash value of the partition, thereby determining the virtual server processing the URL. The hash values of all the partitions include a hash value of each of all the partitions, and include each hash value of each partition.
(50) In this embodiment of the present disclosure, quantities of storage servers and virtual servers may be different. That is, a storage server and a virtual server are not necessarily in a one-to-one correspondence. To implement a one-to-multiple correspondence between a virtual server and a storage server, one storage server may be divided into at least one partition. The following two management manners may be used by a virtual server to manage a partition.
(51) In a first management manner, one storage server is divided into at least one partition, and each partition is managed by one virtual server. In this case, the correspondence stored in the distributed database between a partition and a virtual server may be shown in Table 1.
(52) TABLE-US-00001 TABLE 1 Virtual server A B C D Partition 00 10 20 30
(53) As can be learned from Table 1, when the hash value of the partition corresponding to the URL is 10, it may be known by querying the distributed database that the virtual server processing the URL is the virtual server B.
(54) In a second management manner, one storage server is divided into at least one partition, and each partition is managed by multiple virtual servers. The multiple mentioned in this embodiment of the present disclosure means at least two. In this case, the correspondence stored in the distributed database between a partition and a virtual server may be shown in Table 2.
(55) TABLE-US-00002 TABLE 2 Virtual server A B C D Partition 000 001 20 30
(56) As can be learned from Table 2, when the hash value of the partition corresponding to the URL is 000, it may be known by querying the distributed database that the virtual server processing the URL is the virtual server A.
(57) In this embodiment of the present disclosure, to implement a one-to-multiple correspondence between a partition and a virtual server, each partition may have multiple hash values, and one hash value of each partition corresponds to one virtual server. A manner for assigning multiple hash values to one partition may be adding a sequence number behind an identifier (ID) of the partition. For example, the partition 000 and the partition 001 in Table 2 correspond to a same partition 00. That is, the partition 00 is managed by two virtual servers, the virtual server A and the virtual server B.
(58) In the first management manner and the second management manner, a same method may be used to determine the virtual server B processing the URL. Further, the virtual server A computes the hash value of the URL according to the URL, queries the distributed database for a hash value of a partition, and determines, according to the consistent hashing algorithm, a hash value of a partition corresponding to the URL, queries the distributed database according to the hash value of the partition corresponding to the URL, for a hash value of a virtual server that corresponds to the hash value of the partition, and determines the found virtual server as the virtual server B processing the URL.
(59) If the virtual server B determined in step 302 and the virtual server A are not a same virtual server, step 303 is performed. If the virtual server B determined in step 302 and the virtual server A are a same virtual server, step 304 is performed.
(60) Step 303: When the virtual server A and the virtual server B are not a same virtual server, the virtual server A redirects the request message to the virtual server B.
(61) Step 304: The virtual server B determines whether a storage server managed by the virtual server B has cached the content corresponding to the URL.
(62) If a determining result in step 304 is that the virtual server B determines that the storage server managed by the virtual server B has cached the content corresponding to the URL, step 305 is performed. If a determining result in step 304 is that the virtual server B determines that the storage server managed by the virtual server B does not cache the content corresponding to the URL, step 307 is performed.
(63) Step 305: When the virtual server B determines that the storage server managed by the virtual server B has cached the content corresponding to the URL, the virtual server B redirects the request message to a storage server that is recorded in a cache queue and that corresponds to the URL (e.g. virtual server C), and sends a first notification message to the storage server corresponding to the URL.
(64) Step 306: The storage server corresponding to the URL sends the cached content corresponding to the URL to the UE according to the request message and the first notification message.
(65) The first notification message is used to indicate to the storage server that the storage server has cached the content corresponding to the URL. Optionally, the first notification message may be not sent to the storage server corresponding to the URL in step 305. Correspondingly, in step 306, the storage server corresponding to the URL determines, according to the request message, whether the storage server has cached the content corresponding to the URL, and when the storage server has cached the content corresponding to the URL, sends the cached content corresponding to the URL to the UE.
(66) Step 307: When the virtual server B determines that the storage server managed by the virtual server B does not cache the content corresponding to the URL, the virtual server B redirects the request message to a storage server that is determined according to a consistent hashing algorithm and that corresponds to the URL (e.g. virtual server D), and sends a second notification message to the storage server corresponding to the URL.
(67) Step 308: The storage server corresponding to the URL retrieves, according to the request message and the second notification message, the content corresponding to the URL, and sends the obtained content corresponding to the URL to the UE.
(68) The second notification message is used to indicate to the storage server that the storage server does not cache the content corresponding to the URL. Optionally, the second notification message may be not sent to the storage server corresponding to the URL in step 307. Correspondingly, in step 308, the storage server corresponding to the URL determines, according to the request message, whether the storage server has cached the content corresponding to the URL, and when the storage server does not cache the content corresponding to the URL, retrieves the content corresponding to the URL, and sends the obtained content corresponding to the URL to the UE.
(69) Retrieving the content corresponding to the URL may include obtaining, from an intermediate node, the content corresponding to the URL or obtaining, from a central node, the content corresponding to the URL.
(70) The content delivery method has different procedures when a virtual server manages a partition in the first management manner and the second management manner. Therefore, the following separately describes the content delivery method in the two management manners.
(71) The content delivery method may further include a content storage processing procedure. In the first management manner, after step 307, the method may further include the following steps.
(72) Step 3071: The virtual server B updates popularity information corresponding to the URL.
(73) Step 3072: Determine, according to the popularity information, whether the content corresponding to the URL needs to be cached.
(74) Step 3073: When the content corresponding to the URL needs to be cached, determine whether a storage capacity of a partition corresponding to the URL is full.
(75) The partition herein corresponding to the URL means a partition that is determined according to the consistent hashing algorithm and that corresponds to the URL.
(76) If a determining result in step 3073 is that the storage capacity of the partition corresponding to the URL is not full, step 3074 is performed. If a determining result in step 3073 is that the storage capacity of the partition corresponding to the URL is full, step 3075 is performed.
(77) Step 3074: When the storage capacity of the partition corresponding to the URL is not full, instruct a storage server to cache the content corresponding to the URL into the partition corresponding to the URL.
(78) In this embodiment of the present disclosure, a storage server D represents a storage server in which the partition corresponding to the URL is located.
(79) Step 3075: When the storage capacity of the partition corresponding to the URL is full, select a partition whose storage capacity is not full among multiple partitions managed by the virtual server B, instruct a storage server to cache the content corresponding to the URL into the selected partition, and add the URL, an ID of the partition caching content corresponding to the URL, and the popularity information corresponding to the URL to a record of the cache queue.
(80) In this embodiment of the present disclosure, a storage server C represents a storage server in which the partition that is selected by the virtual server B and whose storage capacity is not full is located.
(81) The storage server C and the storage server D may be a same storage server, or may be different storage servers.
(82) The content delivery method may further include a content deletion processing procedure. A storage server may report a storage capacity of a partition periodically or in an event-triggered manner to a virtual server managing the partition. In the first management manner, when the virtual server B determines storage capacities of the managed multiple partitions are all full, the virtual server B queries the cache queue for a record whose popularity is lower than a first threshold, and instructs, according to the found record, a storage server corresponding to a partition in the record to delete content corresponding to a URL in the record.
(83) An embodiment of the present disclosure further provides a virtual server management method. Referring to a flowchart of the virtual server management method shown in
(84) Step 401: A cloud platform determines, according to load of a CDN system, whether a virtual server needs to be added or removed.
(85) When a determining result is that a virtual server needs to be added, step 402 is performed. When a determining result is that a virtual server needs to be removed, step 406 is performed.
(86) Step 402: When a virtual server needs to be added, determine a quantity of partitions needing to be allocated to the newly added virtual server.
(87) Step 403: Select a partition whose quantity is the quantity from all partitions.
(88) A partition corresponding to the newly added virtual server may be selected according to a random selection manner or a consistent hashing algorithm.
(89) Step 404: Delete content in the selected partition.
(90) Step 405: Allocate the selected partition to the newly added virtual server, and update a correspondence stored in a distributed database between a partition and a virtual server.
(91) Step 406: When a virtual server needs to be removed, instruct a storage server to delete a file in a partition corresponding to the to-be-removed virtual server.
(92) Step 407: Allocate the partition corresponding to the to-be-removed virtual server to another virtual server, and update the correspondence stored in the distributed database between a partition and a virtual server.
(93) A content storage processing procedure included in the content delivery method in the foregoing second management manner is similar to that in the first management manner. Details are not described herein again.
(94) In the second management manner, the content delivery method may further include a content deletion processing procedure. When the second management manner is used, one partition is managed by multiple virtual servers. Therefore, content to be deleted in a partition needs to be determined according to a result of negotiation among multiple virtual servers, rather than determined by a single virtual server. Further, the method includes when a storage capacity of a partition corresponding to a URL is full, a storage server to which the partition belongs reports, to multiple virtual servers managing the partition, notification information indicating that the partition is full, to notify the virtual servers corresponding to the partition that first-percentage content whose popularity is relatively low needs to be evicted. Each of the multiple virtual servers sends a deletion notification to the storage server. The deletion notification carries a URL of second-percentage content that is in the partition managed by the virtual server and whose popularity is relatively low, and popularity information of the part of content. According to popularity information of content corresponding to a URL carried in each deletion notification, the storage server deletes content corresponding to a URL carried in a deletion notification in which popularity information indicates a lowest popularity.
(95) The popularity information may be further an average popularity, a maximum popularity, or a minimum popularity. In this embodiment of the present disclosure, the second percentage may be set less than the first percentage such that the virtual server may send multiple deletion notifications, and content whose popularity is relatively low is deleted relatively precisely.
(96) An embodiment of the present disclosure further provides a virtual server management method. Referring to a flowchart of the virtual server management method shown in
(97) Step 501: A cloud platform determines, according to load of a CDN system, whether a virtual server needs to be added or removed.
(98) When a determining result is that a virtual server needs to be added, step 502 is performed. When a determining result is that a virtual server needs to be removed, step 506 is performed.
(99) Step 502: When a virtual server needs to be added, compute a hash value of the newly added virtual server.
(100) Step 503: Allocate a corresponding partition to the newly added virtual server based on a consistent hashing algorithm.
(101) Step 504: Delete content that is in the allocated partition and that belongs to a cache queue of an original corresponding virtual server.
(102) Step 505: Update a correspondence stored in a distributed database between a partition and a virtual server.
(103) Different from the first management manner, in step 505, updating the correspondence is relatively simple. Only a correspondence between a hash value of a partition and a hash value of a virtual server needs to be added. Because the partition may be managed by multiple virtual servers, a correspondence between the partition and another virtual server does not need to be deleted.
(104) Step 506: When a virtual server needs to be removed, determine a partition corresponding to the to-be-removed virtual server.
(105) Step 507: Instruct a storage server to delete content that is in the partition corresponding to the to-be-removed virtual server and that belongs to a cache queue of the virtual server.
(106) Step 508: Update the correspondence stored in the distributed database between a partition and a virtual server.
(107) A hash value of a URL, a hash value of a partition, and a hash value of a server are mentioned in this embodiment of the present disclosure. Description is provided below using the hash value of the URL as an example. A content ID in a CDN system is a URL corresponding to content. Usually, to reduce occupied space, in the CDN system, an original character string of the URL is not used, and instead, a hash string of the URL is used to represent the URL. The hash string may also be referred to as a hash value.
(108) In this embodiment of the present disclosure, a URL distributed processing manner is used. Because billions of URLs are processed in the CDN, when a server cluster, such as a server cluster of an edge node, processes URLs, generally, a distributed processing method is used. Further, an entire URL set is divided into independent URL subsets according to a quantity of servers in the server cluster of the edge node, and each edge server processes only a URL subset corresponding to the edge server. One URL is processed on only one edge server. The processing herein means operations performed by the edge server, such as computing a popularity of a URL corresponding to content, determining whether to cache and caching the corresponding file content, and retrieving the file content corresponding to the URL.
(109) An edge server corresponding to a URL may be determined based on a consistent hashing technology. Further, a partition corresponding to the URL may be first determined according to the consistent hashing algorithm, and then the distributed database is queried for a virtual server corresponding to the partition, thereby determining the virtual server corresponding to the URL. Alternatively, if the correspondence stored in the distributed database between a hash value of a partition and a hash value of a virtual server satisfies the consistent hashing algorithm, the virtual server corresponding to the URL may be directly determined according to the consistent hashing algorithm. The following briefly describes the consistent hashing algorithm using the second case as an example.
(110) Usually, a quantity of servers is far less than a quantity of URLs. To implement load balance, multiple hash strings are generated for one server. That is, one server corresponds to multiple points on the loop. A method for generating multiple hash strings may be to add a sequence number behind an ID of a server.
(111) An embodiment of the present disclosure provides an architecture of a server cluster of an edge node. The server cluster of the edge node in a CDN is implemented using a cloud computing technology and an independent storage server. The storage server is implemented using an independent physical server.
(112) In this embodiment of the present disclosure, a correspondence between a virtual server and a storage server is relatively flexible, the virtual server and the storage server may be in a one-to-multiple correspondence or a one-to-multiple correspondence, and are not necessarily in the one-to-one correspondence. If the virtual server and the storage server are in a one-to-one correspondence, a quantity of virtual servers needs to be equal to a quantity of storage servers. As a result, when a virtual server needs to be flexibly added and removed, a storage server needs to be added or removed accordingly, affecting dynamic and flexible virtual server addition and removal. Therefore, in this embodiment of the present disclosure, a quantity of storage servers corresponding to one virtual server is not limited, and a quantity of virtual servers corresponding to one storage server is not limited. That is, one storage server may correspond to multiple virtual servers, and one virtual server may correspond to multiple storage servers.
(113) Referring to
(114) To implement the one-to-multiple correspondence between a storage server and a virtual server, a storage capability of the storage server may be partitioned. A partitioning rule may be partitioning based on similar partition sizes according to storage capabilities of different storage servers.
(115) In this embodiment of the present disclosure, when the foregoing first management manner is used, each storage partition can be accessed and managed by only one virtual server. A corresponding advantage is that the virtual server can implement interlinked storage on partitions managed by the virtual server, and disk utilization is improved. A corresponding disadvantage is that it is relatively complex to maintain a correspondence between storage of a storage server and a virtual server during virtual server addition and removal.
(116) For each storage partition, one virtual server may be randomly selected as a virtual server allocated to the storage partition. Alternatively, the virtual server allocated to the storage partition is determined according to a consistent hashing algorithm. A correspondence between a storage partition and a virtual server is stored in a distributed database of the CDN.
(117) The content delivery method provided in this embodiment of the present disclosure is described in detail below using several specific embodiments.
(118)
(119) Step 1101: A user requests a file from a route server.
(120) The user may send a request message to the route server using UE. The request message carries a URL of file content that the user wants to obtain.
(121) Step 1102: The route server requests, from a load balancing server, a virtual server that can accept the user request.
(122) In this embodiment of the present disclosure, the route server and the load balancing server may be integrated into one device, and collectively referred to as a load balancing and route server, or the route server and the load balancing server may be disposed separately.
(123) Step 1103: The route server redirects the user request to a virtual server A returned by the load balancing server.
(124) Step 1104: The virtual server A computes a hash string corresponding to a URL.
(125) Step 1105: The virtual server A queries a distributed database for a hash string of a partition.
(126) Step 1106: The virtual server A determines, based on consistent hashing according to the hash string of the URL and the hash string of the partition, a partition corresponding to the URL.
(127) A key technical solution in steps 1104 to 1106 is that a virtual server determines, according to a URL, a partition needing to process the URL such that a storage server processing the URL may be determined.
(128) The virtual server may first determine, according to the URL, a storage partition and a storage server that need to process the URL, and then determine a virtual server corresponding to the URL.
(129) A partition corresponding to a URL is determined based on a consistent hashing algorithm according to the URL. A specific determining method is to perform a hash on IDs of a URL and a storage partition based on a hash algorithm, for example, a murmur algorithm to obtain a hash string of the URL and a hash string of the server. All possible hash strings form a loop, and each point on the loop corresponds to a hash string. Therefore, the hash string of the URL and the hash string of the storage partition each correspond to a point on the loop. Clockwise starting from the point corresponding to the hash string of the URL, the first point corresponding to a hash string of a storage partition is found, and the storage partition is a storage partition used to store, during caching, content corresponding to the URL. A storage server in which the storage partition is located is a storage server processing the URL.
(130) Usually, a quantity of storage partitions is far less than a quantity of URLs. To implement load balance, multiple hash strings are generated for one storage partition, and one storage partition corresponds to multiple points on the loop. A method for generating multiple hash strings may be to add a sequence number behind an ID of a storage partition.
(131) Step 1107: The virtual server A queries the distributed database according to a hash string of the partition for a virtual server B corresponding to the partition.
(132) A key technical solution in step 1107 is that a virtual server determines, according to a URL, a virtual server needing to process the URL.
(133) A correspondence between a storage partition and a virtual server is stored in the distributed database of a CDN. When the distributed database is established, for each storage partition, a virtual server may be randomly selected (such as uniform sampling) as a virtual server allocated to the storage partition. After the storage partition and the storage server that correspond to the URL, the virtual server corresponding to the URL may be obtained according to a correspondence stored in the distributed database between a hash value of a storage partition and a hash value of a virtual server.
(134) Step 1108: If the virtual server A and the virtual server B are a same virtual server, go to step 1110, or otherwise, go to step 1109.
(135) Step 1109: Redirect the user request to the virtual server B.
(136) Step 1110: The virtual server B determines, according to the URL in the user request, whether the user-requested file exists in a cache queue.
(137) Step 1111: If the user-requested file is in the cache queue, redirect the user request to a storage server that is recorded in the cache queue and that corresponds to the URL, and instruct the storage server to deliver the file.
(138) Step 1112: If the user-requested file is not in the cache queue, redirect the user request to a storage server that is determined based on consistent hashing and that corresponds to the URL, and instruct the storage server to retrieve the user-requested file content.
(139) Step 1113: The storage server returns the user-requested content.
(140)
(141) Step 1201: A virtual server receives a URL of user-requested file content.
(142) Step 1202: The virtual server updates popularity information of the user-requested file corresponding to the URL.
(143) Step 1203: The virtual server determines, according to the popularity information, whether the file content corresponding to the URL needs to be cached. If yes, go to step 1204. Otherwise, the procedure ends.
(144) Step 1204: The virtual server determines whether a storage capacity of a partition corresponding to the URL is full. If yes, go to step 1205. Otherwise, go to step 1206.
(145) In this embodiment of the present disclosure, a storage server may notify the virtual server of a capacity occupation status of the partition.
(146) Step 1205: The virtual server selects, from managed partitions, any other partition that is not full to store the file content corresponding to the URL.
(147) Step 1206: The virtual server adds an ID of the storage partition to a record that is in a cache queue and that corresponds to the URL.
(148) Step 1207: The virtual server caches the user-request file content corresponding to the URL, and instructs a storage server corresponding to the partition to store the file content.
(149) A key technical solution corresponding to steps 1204 to 1207 is how to store file content in a cache queue on a storage server.
(150) In this embodiment of the present disclosure, one partition can be managed by only one virtual server, but one virtual server may manage multiple partitions. If a virtual server creates one cache queue for one managed partition, and separately manages cache queues using an existing CDN cache management technology, hard disk utilization is low, popularities of partitions are not even, and a hit rate is low.
(151) To avoid the disadvantages, a unified management policy is used in this embodiment of the present disclosure. The virtual server creates only one cache queue for managed multiple partitions. A file in the cache queue is stored in a partition corresponding to a URL of the file. If a storage capacity of a partition corresponding to a URL of a file is full, and capacities of other partitions managed by the virtual server are not full, the file is stored in any one of the other partitions whose capacities are not full, and the storage partition is marked in a record that is in the cache queue and that corresponds to the file. In this way, when a user requests the file content, the user request is redirected to a storage server corresponding to the partition marked in the cache record.
(152) That a storage capacity of a partition is full means that a total size of files stored in the partition is greater than C % the storage capacity, that is, a waterline is reached. A value of C is usually 80 to 85, and is not limited in the present disclosure.
(153) Step 1208: The virtual server determines whether capacities of all partitions managed by the virtual server are full. If yes, go to step 1209. Otherwise, the procedure ends.
(154) A storage server notifies the virtual server of a capacity occupation status of each partition.
(155) Step 1209: The virtual server queries the cache queue for a part of content whose popularity is the lowest.
(156) For example, 5% content whose popularity is the lowest is queried for.
(157) Step 1210: The virtual server instructs a storage server corresponding to a partition to delete the found content that corresponds to the partition and whose popularity is the lowest.
(158) A key technical solution corresponding to steps 1208 to 1210 is how to delete file content from a corresponding storage server when all partitions managed by a virtual server are fully occupied.
(159) A storage server monitors capacity occupation statuses of all partitions of the storage server, and notifies virtual servers corresponding to the partitions of the capacity occupation statuses periodically or in an event-triggered manner. For example, when a capacity of a partition is full, the storage server notifies a virtual server corresponding to the partition that the capacity of the partition is full. When storage capacities of all partitions managed by a virtual server are full, the virtual server queries a cache queue for a part of content whose popularity is the lowest, for example, 5% content whose popularity is the lowest, and instructs a storage server to delete the part of content.
(160) This embodiment of the present disclosure does not limit how a virtual server computes popularity information of a URL corresponding to a user request, and a specific cache queue algorithm. For example, an algorithm such as a common least recent usage (LRU) algorithm or a least frequent usage (LFU) algorithm may be used.
(161)
(162) Step 1301: A cloud platform determines, according to a load status, whether a virtual server needs to be added or removed.
(163) When a virtual server needs to be added, step 1302 is performed. When a virtual server needs to be removed, step 1306 is performed.
(164) Step 1302: When a virtual server needs to be added, the cloud platform computes a quantity of partitions needing to be re-allocated to the newly added virtual server.
(165) For example, an average value of quantities of partitions managed by virtual servers may be used as a.
(166) Step 1303: The cloud platform randomly selects a partition from all partitions.
(167) For example, a sampling method of uniform sampling may be used.
(168) Step 1304: The cloud platform deletes files in the selected a partitions.
(169) Step 1305: The cloud platform creates a virtual server, allocates the selected partitions to the newly added virtual server, and updates a correspondence stored in a distributed database between a partition and a virtual server.
(170) Updating a correspondence stored in a distributed database between a partition and a virtual server includes deleting an original correspondence between the selected partitions and a virtual server in the distributed database, and adding a correspondence between the selected partitions and the newly added virtual server.
(171) Step 1306: When a virtual server needs to be removed, the cloud platform instructs a storage server to delete a file in a partition corresponding to the to-be-removed virtual server.
(172) Step 1307: The cloud platform deletes the to-be-removed virtual server, randomly allocates the partition corresponding to the virtual server to another virtual server, and updates the correspondence stored in the distributed database between a partition and a virtual server.
(173) Updating the correspondence stored in the distributed database between a partition and a virtual server includes deleting a correspondence between the partition and the removed virtual server in the distributed database, and establishing a correspondence between the partition and the other virtual server.
(174) In this embodiment of the present disclosure, alternatively, one storage server may be divided into one or more partitions, and each storage partition may be accessed and managed by multiple virtual servers. A corresponding advantage is that it is easy to maintain a correspondence between storage of a storage server and a virtual server during virtual server addition and removal. A corresponding disadvantage is that a virtual server cannot implement interlinked storage on partitions managed by the virtual server, leading to relatively low disk utilization.
(175) For each storage partition, multiple virtual servers are randomly selected as virtual servers allocated to the storage partition. A correspondence between a storage partition and a virtual server is stored in the distributed database of a CDN. The present disclosure does not limit a quantity of selected virtual servers.
(176) In this embodiment of the present disclosure, each storage server may have one partition, that is, a storage space of the storage server may be not divided, and partitioning is not necessary. The following embodiment is described using an example in which a quantity of partitions is 1.
(177)
(178) Step 1401: A user requests a file from a route server.
(179) Step 1402: The route server requests, from a load balancing server, a virtual server that can accept the user request.
(180) Step 1403: The route server redirects the user request to a virtual server A returned by the load balancing server.
(181) Step 1404: The virtual server A computes a hash string corresponding to a URL.
(182) Step 1405: The virtual server A queries a distributed database for a hash string of a partition.
(183) Step 1406: The virtual server A determines, based on consistent hashing according to the hash string of the URL and the hash string of the partition, a partition corresponding to the URL.
(184) A key technical solution corresponding to steps 1401 to 1406 is that a virtual server determines, according to a URL, a partition needing to process the URL such that a storage server processing the URL is determined.
(185) The virtual server first determines, according to the URL, a storage partition needing to process the URL and a corresponding storage server, and then determines a virtual server corresponding to the URL.
(186) A method for determining, according to a URL, a partition needing to process the URL is the consistent hashing method described above.
(187) A specific determining method is to perform a hash on IDs of a URL and a storage partition based on a hash algorithm, for example, a murmur algorithm to obtain a hash string of the URL and a hash string of the server. All possible hash strings form a loop, and each point on the loop corresponds to a hash string. Therefore, the hash string of the URL and the hash string of the storage partition each correspond to a point on the loop. Clockwise starting from the point corresponding to the hash string of the URL, the first point corresponding to a hash string of a storage partition is found, and the storage partition is a storage partition used to store, during caching, content corresponding to the URL. A storage server in which the storage partition is located is a storage server processing the URL.
(188) Usually, a quantity of storage partitions is far less than a quantity of URLs. To implement load balance, multiple hash strings are generated for one storage partition, and one storage partition corresponds to multiple points on the loop. A method for generating multiple hash strings may be to add a sequence number behind an ID of a storage partition.
(189) Step 1407: The virtual server A queries the distributed database for a hash string of a virtual server.
(190) Step 1408: The virtual server A determines, based on consistent hashing according to the hash string of the partition and the hash string of the virtual server, a virtual server B corresponding to the URL.
(191) A precondition for step 1408 includes when establishing the distributed database, a cloud platform determines a correspondence between a hash string of a partition and a hash string of a virtual server according to consistent hashing, and stores the correspondence in the distributed database.
(192) In this embodiment of the present disclosure, for the determining the virtual server corresponding to the URL, step 1408 may be replaced with a manner of querying the distributed database.
(193) A key technical solution corresponding to steps 1407 and 1408 is that a virtual server determines, according to a URL, a virtual server needing to process the URL.
(194) In this embodiment of the present disclosure, after the storage partition and the storage server that correspond to the URL are obtained, a correspondence between a storage partition and a virtual server is obtained by still using a consistent hashing algorithm to obtain the virtual server corresponding to the URL.
(195)
(196) Referring to
(197) Usually, a quantity of storage partitions and a quantity of virtual servers are both small. To implement load balance, multiple hash strings are generated for one storage partition, and one storage partition corresponds to multiple points on the loop. A method for generating multiple hash strings may be to add a sequence number behind an ID of a storage partition. Multiple hash strings are generated for one virtual server, and one virtual server corresponds to multiple points on the loop. A method for generating multiple hash strings may be to add a sequence number behind an ID of a virtual server.
(198) The correspondence between a storage partition and a virtual server is stored in the distributed database of the CDN after being obtained. When one partition is managed by one virtual server, a one-to-one correspondence between the partition and the virtual server is stored in the database. Herein, a correspondence between each hash string of each partition and a virtual server is stored in the database, and each partition actually corresponds to multiple virtual servers.
(199) Step 1409: If the virtual server A and the virtual server B are a same virtual server, go to step 1411, or otherwise, go to step 1410.
(200) Step 1410: Redirect the user request to the virtual server B.
(201) Step 1411: The virtual server B determines, according to the URL in the user request, whether the user-requested file exists in a cache queue.
(202) Step 1412: If the user-requested file is in the cache queue, redirect the user request to a corresponding storage server, and instruct the storage server to deliver the file.
(203) Step 1413 If the user-requested file is not in the cache queue, redirect the user request to a corresponding storage server, and instruct the storage server to retrieve the user-requested file content.
(204) Step 1414: The storage server returns the user-requested content.
(205)
(206) Step 1601: When a virtual server receives user-requested file content of a URL, and determines that the user-requested file is not in a cache queue, the virtual server updates popularity information of the user-requested file corresponding to the URL.
(207) Step 1601 may be performed after step 1413.
(208) Step 1602: The virtual server determines, according to the popularity information, whether the file content corresponding to the URL needs to be cached. If yes, go to step 1603. Otherwise, the procedure ends.
(209) A key technical solution corresponding to step 1603 is how to store file content in a cache queue on a storage server.
(210) In this embodiment of the present disclosure, one partition may be managed by multiple virtual servers, and one virtual server may manage multiple partitions. To avoid a decrease in a hit rate caused by uneven popularities, the virtual server creates only one cache queue for managed multiple partitions. A file in the cache queue is stored in a partition corresponding to a URL of the file.
(211) Step 1603: The virtual server caches the user-requested file content corresponding to the URL into a selected partition.
(212) The selected partition is a partition that is determined according to a consistent hashing algorithm and that corresponds to the URL.
(213) A storage server reports, to all virtual servers managing a partition of the storage server, a storage capacity of the partition periodically or in an event-triggered manner.
(214) Step 1604: Virtual servers determine whether a capacity of a managed partition is full.
(215) If a determining result is yes, step 1605 is performed. Otherwise, the procedure ends.
(216) Step 1605: The virtual servers notify a storage server of content needing to be deleted.
(217) The virtual servers mean multiple virtual servers managing the partition.
(218) Step 1606: The storage server receives deletion notifications of the virtual servers, and deletes, from the partition, content that is in the notifications and whose average popularity is the lowest.
(219) According to different preset policies, content that is in the notifications and whose maximum popularity is the lowest may be deleted, or content that is in the notifications and whose minimum popularity is the lowest may be deleted.
(220) Step 1607: If a sufficient space in the partition is released, end the procedure, or otherwise, go to step 1605.
(221) A key technical solution corresponding to steps 1604 to 1607 is how to delete file content when a storage server is fully occupied.
(222) The storage server monitors capacity occupation statuses of all partitions of the storage server, and notifies virtual servers corresponding to the partitions of the capacity occupation statuses periodically or in an event-triggered manner. In this embodiment, because one partition is managed by multiple virtual servers, if a storage capacity of a partition is full, content that corresponds to the partition and whose popularity is the lowest in cache queues of the multiple virtual servers needs to be deleted.
(223) A specific method is as follows. The storage server notifies the virtual servers corresponding to the partition that a % content whose popularity is relatively low, for example, 5% content whose popularity is relatively low, needs to be evicted from the partition. The virtual servers send, to the storage server, b % content that is in the partition and whose popularity is the lowest in cache queues of the virtual servers. A size of b % content needs to be far less than a size of a % content. For example, b % is 1/10 of a %. In addition, the virtual servers send average popularities or maximum or minimum popularities of the virtual servers to the storage server. The storage server receives the content that is sent by the virtual servers and whose popularity is the lowest, deletes, from the content, content that is sent by a virtual server and whose average popularity or maximum or minimum popularity is the lowest, and continues to send a new eviction notification to the virtual server. The storage server receives new content needing to be evicted, compares an average popularity or a maximum or minimum popularity of the content with an average popularity or a maximum or minimum popularity of content that is not evicted in the previous round, and deletes, from the content, content that is sent by a virtual server and whose average popularity or maximum or minimum popularity is the lowest. The previous steps are repeated until eviction is completed, that is, a % content is evicted.
(224)
(225) Step 1701: A cloud platform determines, according to a load status, that a virtual server needs to be added.
(226) An execution device/module in a CDN needs to be capable of monitoring load statuses of all VMs, determines, according to service logic that is set in an actually, whether an expansion threshold is reached. Generally, a VM management module of the cloud platform performs monitoring and expansion.
(227) Step 1702: The cloud platform computes a hash string of the newly added virtual server.
(228) Step 1703: The cloud platform queries a distributed database for hash strings of a partition and a virtual server, and queries, based on consistent hashing, for b partitions corresponding to the newly added virtual server.
(229) Step 1704: The cloud platform deletes, from the b partitions returned after query, a file that is in a cache queue of an existing VM and that does not belong to the existing VM anymore.
(230) When a correspondence between a partition and a VM is re-determined in step 1704, a partition corresponding to the existing VM may be changed. In this case, the correspondence between a partition and a VM needs to be adjusted in the database. In addition, the cache queue of the existing VM needs to be adjusted, and a file that is not managed by each VM anymore is deleted. Then a storage server deletes, from partitions, files that are deleted by existing VMs from cache queues, that is, deletes, from re-allocated partitions, content belonging to cache queues of original corresponding virtual servers.
(231) Step 1705: Allocate the selected partitions to the newly added virtual server, and update a correspondence stored in the distributed database between a partition and a virtual server.
(232) Step 1706: The cloud platform determines, according to a load status, that a virtual server needs to be removed.
(233) Step 1707: The cloud platform instructs a storage server to delete, from a selected partition, content in a cache queue of the removed VM.
(234) Step 1708: Update the correspondence stored in the distributed database between a partition and a virtual server.
(235) This embodiment of the present disclosure provides a virtual server management method. A cloud platform and an independent storage server (for example, a streaming server) are used to implement a CDN, maintaining I/O performance while having advantages of a cloud computing platform of being dynamic, flexible, changing, virtual, shared, and efficient, and satisfying a content delivery requirement of media and other large files.
(236)
(237) In a possible design, the receiving unit 1801 is further configured to receive a second request message sent by the content requester, where the second request message carries a second URL of user-requested content, the judging unit 1802 is further configured to determine, according to the cache list maintained by the first virtual server, that none of the storage servers managed by the first virtual server caches the content corresponding to the second URL carried in the second request message, the virtual server further includes a determining unit 1804 configured to determine, according to a consistent hashing algorithm, a second storage server configured to cache the content corresponding to the second URL carried in the second request message received by the receiving unit 1801, and the redirection unit 1803 is further configured to redirect the second request message received by the receiving unit 1801 to the second storage server, where the second request message redirected to the second storage server is used to instruct the second storage server to retrieve the user-requested content and send the retrieved user-requested content to the content requester.
(238) In a possible design, the virtual server further includes a determining unit 1804 configured to, before the judging unit 1802 determines, according to the cache list maintained by the first virtual server, that one of the storage servers managed by the first virtual server has cached the content corresponding to the first URL, determine, according to the first URL, carried in the first request message received by the receiving unit 1801, of the user-requested content, that the first virtual server processes the first URL.
(239) In a possible design, the determining unit 1804 is further configured to, before the judging unit 1802 determines, according to the cache list maintained by the first virtual server, that none of the storage servers managed by the first virtual server caches the content corresponding to the second URL carried in the second request message, determine, according to the second URL, carried in the second request message received by the receiving unit 1801, of the user-requested content, that the first virtual server processes the second URL.
(240) In a possible design, the receiving unit 1801 is further configured to receive a third request message sent by the content requester, where the third request message carries a third URL of user-requested content, the determining unit 1804 is further configured to determine, according to the third URL, carried in the third request message received by the receiving unit 1801, of the user-requested content, that a second virtual server processes the third URL, and the redirection unit 1803 is further configured to redirect the third request message received by the receiving unit 1801 to the second virtual server.
(241) In a possible design, the determining unit 1804 includes a hash value computation subunit (not shown) configured to compute, according to a URL, carried in a request message received by the receiving unit 1801, of user-requested content, a hash value of the URL, a partition determining subunit configured to obtain hash values of all partitions in a distributed database, and query, based on the consistent hashing algorithm according to the hash value of the URL that is computed by the hash value computation subunit, for a partition corresponding to the URL, where each of the storage servers included in the content delivery system is divided into at least one partition, and a virtual server determining subunit configured to determine, according to a hash value of the partition determined by the partition determining subunit and corresponding to the URL and a correspondence stored in the distributed database between a hash value of a partition and a hash value of a virtual server, the virtual server processing the URL.
(242) In a possible design, each of the storage servers included in the content delivery system is divided into at least one partition, and the virtual server further includes an update unit 1805 configured to, after the redirection unit 1803 redirects the second request message received by the receiving unit 1801 to the second storage server, update popularity information corresponding to the second URL, the determining unit 1804 is further configured to determine, according to the popularity information updated by the update unit 1805, that the content corresponding to the second URL needs to be cached, and determine that a storage capacity of a partition corresponding to the second URL is not full, and the virtual server further includes a notification unit 1806 configured to instruct the second storage server to cache the content corresponding to the second URL into the partition corresponding to the second URL.
(243) In a possible design, each partition corresponds to one virtual server, the determining unit 1804 is further configured to determine that the storage capacity of the partition corresponding to the second URL is full, determine that a storage capacity of at least one of multiple partitions managed by the first virtual server is not full, and select a partition whose storage capacity is not full, the notification unit 1806 is further configured to instruct the second storage server to cache the content corresponding to the second URL into the selected partition, the virtual server further includes an addition unit 1807 configured to add a hash value of the second URL, a hash value of the partition caching the content corresponding to the second URL, and the popularity information corresponding to the second URL to a record of a cache queue, the determining unit 1804 is further configured to determine that the storage capacity of the partition corresponding to the second URL is full, determine that storage capacities of the multiple partitions managed by the first virtual server are all full, and query the cache queue for a record whose popularity is lower than a first threshold, and the notification unit 1806 is further configured to instruct, according to the record found by the determining unit 1804, a storage server corresponding to a partition in the record to delete content corresponding to a URL in the record.
(244) In a possible design, each partition has multiple hash values, and one hash value of each partition corresponds to one virtual server, the receiving unit 1801 is further configured to, after the redirection unit 1803 redirects the second request message to the second storage server, receive notification information that is reported when the storage capacity of the partition corresponding to the second URL is full and that indicates that the partition is full, where the notification information is reported by the second storage server to which the partition belongs to multiple virtual servers managing the partition, and the notification unit 1806 is further configured to send a deletion notification to the second storage server, where the deletion notification carries a URL of content that is in the partition managed by the first virtual server and whose popularity lower than a second threshold, and the deletion notification is used to instruct the second storage server to determine, according to popularity information of the content corresponding to the URL carried in the deletion notification, whether to delete the content corresponding to the URL carried in the deletion notification.
(245)
(246) In a possible design, the determining unit 1902 is further configured to determine, according to load of the content delivery system, that a virtual server needs to be newly added, and determine a quantity of partitions needing to be allocated to the newly added virtual server, the apparatus further includes a selection unit 1904 configured to select a partition whose quantity is the quantity determined by the determining unit 1902 from all partitions, a deletion unit 1905 configured to instruct a storage server to delete content in the partition selected by the selection unit 1904, and an update unit 1906 configured to allocate the partition selected by the selection unit 1904 to the newly added virtual server, and update a correspondence between a partition and a virtual server in the distributed database, the determining unit 1902 is further configured to determine, according to load of the content delivery system, that a virtual server needs to be removed, the deletion unit 1905 is further configured to instruct a storage server to delete content in a partition corresponding to the to-be-removed virtual server, the update unit 1906 is further configured to allocate the partition corresponding to the to-be-removed virtual server to another virtual server, and update the correspondence between a partition and a virtual server, and the deletion unit 1905 is further configured to delete the to-be-removed virtual server.
(247)
(248) In a possible design, the determining unit 2002 is further configured to determine, according to load of the content delivery system, that a virtual server needs to be newly added, the computation unit 2001 is further configured to compute a hash value of the newly added virtual server, the apparatus further includes an obtaining unit 2004 configured to obtain all hash values of all partitions, an allocation unit 2005 configured to allocate a hash value of a corresponding partition to the newly added virtual server based on the consistent hashing algorithm, a deletion unit 2006 configured to instruct a storage server to delete content in a cache queue of a virtual server originally corresponding to the allocated hash value of the partition, and an update unit 2007 configured to allocate the selected hash value of the partition to the newly added virtual server, and update a correspondence between a hash value of a partition and a virtual server in the distributed database, the determining unit 2002 is further configured to determine, according to load of the content delivery system, that a virtual server needs to be removed, and determine a hash value, corresponding to the to-be-removed virtual server, of a partition, the deletion unit 2006 is further configured to instruct a storage server to delete content that is in the partition corresponding to the to-be-removed virtual server and that belongs to a cache queue of the virtual server, the update unit 2007 is further configured to allocate the hash value, corresponding to the to-be-removed virtual server, of the partition to another virtual server, and update the correspondence between a hash value of a partition and a virtual server, and the deletion unit 2006 is further configured to delete the to-be-removed virtual server.
(249)
(250) The memory 2101 is configured to store a program instruction.
(251) The processor 2102 is configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operations of receiving, by the first virtual server, a first request message sent by a content requester, where the first request message carries a first URL of user-requested content, determining, by the first virtual server according to a cache list maintained by the first virtual server, that one of the storage servers managed by the first virtual server has cached the content corresponding to the first URL, and redirecting the first request message to a first storage server that is recorded in the cache list and that has cached the content corresponding to the first URL, where the first request message redirected to the first storage server is used to instruct the first storage server to send the cached content corresponding to the first URL to the content requester.
(252) In a possible design, the processor 2102 is further configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operations of receiving, by the first virtual server, a second request message sent by the content requester, where the second request message carries a second URL of user-requested content, determining, by the first virtual server according to the cache list maintained by the first virtual server, that none of the storage servers managed by the first virtual server caches the content corresponding to the second URL carried in the second request message, determining, by the first virtual server according to a consistent hashing algorithm, a second storage server configured to cache the content corresponding to the second URL carried in the second request message, and redirecting the second request message to the second storage server, where the second request message redirected to the second storage server is used to instruct the second storage server to retrieve the user-requested content and send the retrieved user-requested content to the content requester.
(253) In a possible design, the processor 2102 is further configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operation of determining, by the first virtual server according to the first URL, carried in the first request message, of the user-requested content, that the first virtual server processes the first URL before determining, by the first virtual server according to a cache list maintained by the first virtual server, that one of the storage servers managed by the first virtual server has cached the content corresponding to the first URL.
(254) In a possible design, the processor 2102 is further configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operation of determining, by the first virtual server according to the second URL, carried in the second request message, of the user-requested content, that the first virtual server processes the second URL before determining, by the first virtual server according to the cache list maintained by the first virtual server, that none of the storage servers managed by the first virtual server caches the content corresponding to the second URL carried in the second request message.
(255) In a possible design, the processor 2102 is further configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operations of receiving, by the first virtual server, a third request message sent by the content requester, where the third request message carries a third URL of user-requested content, determining, by the first virtual server according to the third URL, carried in the third request message, of the user-requested content, that a second virtual server processes the third URL, and redirecting the third request message to the second virtual server.
(256) In a possible design, an operation, performed by the processor 2102 or the first virtual server, of determining, by the first virtual server according to a URL, carried in a request message, of user-requested content, a virtual server processing the URL includes computing, by the first virtual server according to the URL, carried in the request message, of the user-requested content, a hash value of the URL, obtaining hash values of all partitions in a distributed database, and querying, based on the consistent hashing algorithm according to the hash value of the URL, for a partition corresponding to the URL, where each of the storage servers included in the content delivery system is divided into at least one partition, and determining, according to a hash value of the partition corresponding to the URL and a correspondence stored in the distributed database between a hash value of a partition and a hash value of a virtual server, the virtual server processing the URL.
(257) In a possible design, each of the storage servers included in the content delivery system is divided into at least one partition, and the processor 2102 is further configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operations of updating, by the first virtual server, popularity information corresponding to the second URL after redirecting the second request message to the second storage server, determining, according to the popularity information, that the content corresponding to the second URL needs to be cached, determining that a storage capacity of a partition corresponding to the second URL is not full, and instructing the second storage server to cache the content corresponding to the second URL into the partition corresponding to the second URL.
(258) In a possible design, each partition corresponds to one virtual server, and the processor 2102 is further configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operations of determining, by the first virtual server, that the storage capacity of the partition corresponding to the second URL is full, determining that a storage capacity of at least one of multiple partitions managed by the first virtual server is not full, and selecting a partition whose storage capacity is not full, instructing, by the first virtual server, the second storage server to cache the content corresponding to the second URL into the selected partition, and adding a hash value of the second URL, a hash value of the partition caching the content corresponding to the second URL, and the popularity information corresponding to the second URL to a record of a cache queue, or determining, by the first virtual server, that the storage capacity of the partition corresponding to the second URL is full, determining that storage capacities of the multiple partitions managed by the first virtual server are all full, and querying the cache queue for a record whose popularity is lower than a first threshold, and instructing, according to the found record, a storage server corresponding to a partition in the record to delete content corresponding to a URL in the record.
(259) In a possible design, each partition has multiple hash values, one hash value of each partition corresponds to one virtual server, and the processor 2102 is further configured to, according to the program instruction stored in the memory 2101, enable the processor 2102 or the first virtual server to perform the following operations of receiving, by the first virtual server, notification information that is reported when the storage capacity of the partition corresponding to the second URL is full and that indicates that the partition is full after redirecting the second request message to the second storage server, where the notification information is reported by the second storage server to which the partition belongs to multiple virtual servers managing the partition, and sending, by the first virtual server, a deletion notification to the second storage server, where the deletion notification carries a URL of content that is in the partition managed by the first virtual server and whose popularity lower than a second threshold, and the deletion notification is used to instruct the second storage server to determine, according to popularity information of the content corresponding to the URL carried in the deletion notification, whether to delete the content corresponding to the URL carried in the deletion notification.
(260)
(261) The memory 2201 is configured to store a program instruction.
(262) The processor 2202 is configured to, according to the program instruction stored in the memory 2201, enable the processor 2202 or the cloud platform to perform the following operations of computing, by a cloud platform, a hash value of each partition of the content delivery system and a hash value of each virtual server of the content delivery system, determining, according to a consistent hashing algorithm or a random selection manner, a virtual server corresponding to each partition, and establishing a distributed database, and storing a correspondence between a hash value of a partition and a hash value of a virtual server in the distributed database.
(263) In a possible design, the processor 2202 is further configured to, according to the program instruction stored in the memory 2201, enable the processor 2202 or the cloud platform to perform the following operations of determining, by the cloud platform according to load of the content delivery system, that a virtual server needs to be newly added, determining a quantity of partitions needing to be allocated to the newly added virtual server, selecting a partition whose quantity is the quantity from all partitions, instructing a storage server to delete content in the selected partition, and allocating the selected partition to the newly added virtual server, and updating a correspondence between a partition and a virtual server in the distributed database, or determining, by the cloud platform according to load of the content delivery system, that a virtual server needs to be removed, instructing, by the cloud platform, a storage server to delete content in a partition corresponding to the to-be-removed virtual server, allocating the partition corresponding to the to-be-removed virtual server to another virtual server, and updating the correspondence between a partition and a virtual server, and deleting the to-be-removed virtual server.
(264)
(265) The memory 2301 is configured to store a program instruction.
(266) The processor 2302 is configured to according to the program instruction stored in the memory 2301, enable the processor 2302 or the cloud platform to perform the following operations of computing, by a cloud platform, a hash value of each partition of the content delivery system and a hash value of each virtual server of the content delivery system, determining, according to a consistent hashing algorithm or a random selection manner, multiple virtual servers corresponding to each partition, and establishing a distributed database, and storing a correspondence between a hash value of a partition and a hash value of a virtual server in the distributed database.
(267) In a possible design, the processor 2302 is further configured to, according to the program instruction stored in the memory 2301, enable the processor 2302 or the cloud platform to perform the following operations of determining, by the cloud platform according to load of the content delivery system, that a virtual server needs to be newly added, computing, by the cloud platform, a hash value of the newly added virtual server, obtaining all hash values of all partitions, allocating a hash value of a corresponding partition to the newly added virtual server based on the consistent hashing algorithm, instructing a storage server to delete content in a cache queue of a virtual server originally corresponding to the allocated hash value of the partition, and allocating the selected hash value of the partition to the newly added virtual server, and updating a correspondence between a hash value of a partition and a virtual server in the distributed database, or determining, by the cloud platform according to load of the content delivery system, that a virtual server needs to be removed, determining, by the cloud platform, a hash value, corresponding to the to-be-removed virtual server, of a partition, instructing a storage server to delete content that is in the partition corresponding to the to-be-removed virtual server and that belongs to a cache queue of the virtual server, allocating the hash value, corresponding to the to-be-removed virtual server, of the partition to another virtual server, and updating the correspondence between a hash value of a partition and a virtual server, and deleting the to-be-removed virtual server.
(268) The method in the present disclosure in which a server cluster of an edge node in a CDN is implemented using a cloud computing technology and an independent storage server may also be applied to a server cluster of a central node in the CDN and a server cluster of an intermediate node between the central node and the edge node.
(269) A person skilled in the art may be further aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm steps may be implemented by electronic hardware, computer software, or a combination thereof. To clearly describe the interchangeability between the hardware and the software, the foregoing has generally described compositions and steps of each example according to functions. Whether the functions are performed by hardware or software depends on particular applications and design constraint conditions of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of the present disclosure.
(270) Persons of ordinary skill in the art may understand that all or a part of the steps in each of the foregoing method of the embodiments may be implemented by a program instructing a processor. The foregoing program may be stored in a computer readable storage medium. The storage medium may be a non-transitory medium, such as a random-access memory, a read-only memory, a flash memory, a hard disk, a solid-state drive, a magnetic tape, a floppy disk, an optical disc, or any combination thereof.
(271) The foregoing descriptions are merely example implementations of the present disclosure, but are not intended to limit the protection scope of the present disclosure. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in the present disclosure shall fall within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.