Resource distribution method and device, electronic equipment and storage medium
Through the predicted popularity, slicing and hash mapping technology of the PCDN network, the problems of poor scalability and insufficient adaptability of unstable equipment during peak periods of video distribution methods are solved, and rapid resource distribution and dynamic adjustment are achieved.
Patent Information
- Application Number
- CN202311174260.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2043-09-12
AI Technical Summary
Existing video distribution methods have high costs and poor scalability when facing burst traffic during peak periods. They are also difficult to adapt to the data synchronization of unstable online devices. It is difficult to accurately predict the popularity of file blocks and easily create bottlenecks when selecting shared nodes.
Using the PCDN network, storage copies are generated by obtaining the predicted popularity of on-demand resources, slicing resources, mapping them to virtual nodes through hash calculation, and combining client attribute information for resource distribution to achieve load-balanced distribution.
It achieves rapid distribution and expansion of resources, is suitable for stable and unstable online devices, avoids excessive concentration of resources and waste of capacity, and dynamically adjusts resource distribution.
Smart Images

Figure CN118803291A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of content distribution network, and in particular to a resource distribution method, device, electronic equipment and storage medium. Background Art
[0002] With the development of technology, the clarity and fluency of video services are constantly improving, and with the advent of 5G, users' demand for high-quality videos will become more and more vigorous. At present, high-definition video has become the mainstream. With the improvement of resolution and clarity, although it improves the user's viewing experience, it also causes a sharp increase in traffic usage.
[0003] The popular video distribution methods in the industry are: Figure 1 As shown in the figure, resources such as video / audio / images are deployed on the Content Delivery Network (CDN). When users need to download resources, they directly initiate resource requests to the CDN to achieve downloading, live broadcasting and on-demand viewing. Users can also request resources from other users and share resources through Peer to Peer (P2P) technology. However, the current approach to providing large-scale resource sharing services is costly and has poor scalability. There are still certain defects in adaptability and fault tolerance to sudden traffic during peak periods.
[0004] In addition, there are patent documents that propose a method based on the heat of file blocks. First, the predicted heat corresponding to the file block is obtained; according to the predicted heat of the file block, several shared nodes are selected from multiple shared nodes as the deployment shared nodes corresponding to the file block; the file block is deployed on the deployment shared nodes; and the file block index information is generated by establishing a correspondence between several deployment shared nodes and the file block. Further, when the p2p obtains the resource tracker, the file tracker can obtain the file block from the deployment shared node corresponding to the file block according to the generated file block index information. The above scheme relies on unlimited shared nodes to provide services. These shared nodes have the characteristics of stable online, large storage space, and self-controllable file cache in the storage space. At the same time, the scheme also has the following problems: (1) It is more suitable for stable online devices (such as routers, optical modems, etc.), but there is data synchronization migration for unstable online devices (such as TV boxes, smart lamps, etc.); (2) The heat of the file block is based on the historical access record of the file block. For newly generated resources, there is no access record and it is difficult to generate heat; (3) The selection of shared nodes depends on the characteristics of the shared nodes, which is prone to bottlenecks when selecting massive data. Summary of the invention
[0005] The present invention provides a resource distribution method, device, electronic device and storage medium to solve the above problems existing in the prior art.
[0006] In a first aspect, the present invention provides a resource distribution method, which is applied to a PCDN network, wherein the PCDN network includes a plurality of PCDN nodes, and the method includes:
[0007] Get the predicted popularity of on-demand resources;
[0008] Obtaining the number of copies of the on-demand resource to be stored according to the predicted popularity;
[0009] According to the number of copies, generating a corresponding number of storage copies of the on-demand resource and marking a corresponding copy serial number for each storage copy;
[0010] Slicing the on-demand resource to obtain a plurality of resource slices and slice information corresponding to each of the resource slices, wherein each of the PCDN nodes stores one of the resource slices;
[0011] According to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the plurality of resource slices, a plurality of first virtual nodes mapped to the first hash ring are calculated by hashing, wherein the first virtual node stores a first index of the resource slice;
[0012] According to the attribute information of different clients, a plurality of second virtual nodes mapped to the second hash ring are calculated by hashing, and the second virtual nodes store the second index of the client;
[0013] Resource distribution to the client is determined based on a mapping relationship between the first index and the second index, and load balancing between the first virtual node and the second virtual node.
[0014] According to a resource distribution method provided by the present invention, the step of slicing the on-demand resource to obtain multiple resource slices and slice information corresponding to each resource slice includes:
[0015] If the on-demand resource is a single file resource, dividing and slicing the on-demand resource according to a preset first fixed slice size;
[0016] If the size of the resource slice finally cut is greater than or equal to the preset second fixed slice size, it is determined to be a single resource slice;
[0017] If the size of the resource slice cut last is smaller than the second fixed slice size, the resource slice cut last is merged with the previous resource slice into one resource slice, wherein the second fixed slice size is half of the first fixed slice size.
[0018] According to a resource distribution method provided by the present invention, the step of slicing the on-demand resource to obtain a plurality of resource slices and slice information corresponding to each of the resource slices further includes:
[0019] If the on-demand resource is a resource package file including at least one resource file, obtaining the file size of the resource file in the resource package file;
[0020] If the file size of the resource file is greater than or equal to the first fixed slice size, dividing and slicing the resource file according to the first fixed slice size;
[0021] If the file size of the resource file is smaller than the first fixed fragment size, grouping the plurality of resource files;
[0022] If the size of the last resource file is greater than or equal to the second fixed fragment size, the last resource file is grouped separately;
[0023] If the size of the last resource file is smaller than the second fixed fragment size, the last resource file and the previous resource file whose file size is smaller than the first fixed fragment size are merged into one group.
[0024] According to a resource distribution method provided by the present invention, the step of determining resource distribution to the client according to the mapping relationship between the first index and the second index and the load balancing of the first virtual node and the second virtual node includes:
[0025] The client synchronously stores the resource slice and the slice information to the distribution service;
[0026] The distribution service updates the first index and the second index of the resource slice that has completed synchronous storage;
[0027] Determine the first virtual node mapped by the client according to the mapping relationship between the first index and the second index;
[0028] Determine the resource slice that needs to be updated by the client according to the resource load of the first virtual node and the attributes of the client;
[0029] The distribution service sends a resource update request to the client, and the client completes a resource update operation according to the resource update request.
[0030] According to a resource distribution method provided by the present invention, after the client completes the resource update operation according to the resource update request, the method further includes:
[0031] After completing the resource update, the client synchronizes the resource update with the distribution service, and the distribution service updates the first index of the resource slice that has completed the synchronous update.
[0032] According to a resource distribution method provided by the present invention, when the resource update request is a request for adding a new resource, correspondingly, the step of determining the resource distribution to the client according to the mapping relationship between the first index and the second index, and the load balancing between the first virtual node and the second virtual node, further includes:
[0033] Determine a client list corresponding to the first virtual node according to a mapping relationship between the first index and the second index;
[0034] Determining the client suitable for storing the newly added resource slice from the client list according to the attributes of the client;
[0035] The distribution service sends a resource update request to the client;
[0036] The client sends a resource sharing request to the resource scheduling service according to the resource update request, and obtains a client sharing list of the resource slice;
[0037] The client completes the resource storage operation according to the client sharing list.
[0038] According to a resource distribution method provided by the present invention, the client sends a resource sharing request to a resource scheduling service according to the resource update request, and the step of obtaining a client sharing list of the resource slice includes:
[0039] The resource scheduling service receives the resource sharing request, queries a plurality of resource slices corresponding to the on-demand resource, and stores a client set of the on-demand resource;
[0040] For each resource slice, determining a client participating in the PCDN network from the client set to form a client sharing list and return it to the client;
[0041] The client makes a resource sharing request for the resource slices in the PCDN network according to the playback position of the client sharing list, so as to complete the resource sharing of the on-demand resource in the PCDN network.
[0042] In a second aspect, the present invention further provides a resource distribution device, which is applied to a PCDN network, wherein the PCDN network includes a plurality of PCDN nodes, and the device includes:
[0043] A predicted popularity acquisition module is used to obtain the predicted popularity of on-demand resources;
[0044] A copy quantity acquisition module, used to obtain the number of copies of the on-demand resource to be stored according to the predicted popularity;
[0045] A storage copy marking module, used to generate a corresponding number of storage copies of the on-demand resource according to the number of copies and mark each storage copy with a corresponding copy serial number;
[0046] A video-on-demand resource slicing module, configured to slice the video-on-demand resource to obtain a plurality of resource slices and slicing information corresponding to each of the resource slices, wherein each of the PCDN nodes stores one of the resource slices;
[0047] A first hash calculation module, configured to map to a plurality of first virtual nodes on a first hash ring through hash calculation according to the attribute information of the on-demand resource, the storage copy, and slice information corresponding to the plurality of resource slices, wherein the first virtual node stores a first index of the resource slice;
[0048] A second hash calculation module, used to map to a plurality of second virtual nodes on a second hash ring through hash calculation according to attribute information of different clients, wherein the second virtual nodes store a second index of the client;
[0049] A resource distribution module is used to determine resource distribution to the client according to a mapping relationship between the first index and the second index, and load balancing between the first virtual node and the second virtual node.
[0050] In a third aspect, the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the resource distribution method as described above is implemented.
[0051] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements any of the resource distribution methods described above.
[0052] The present invention provides a resource distribution method, device, electronic device and storage medium, firstly obtain the predicted heat of the on-demand resource, generate the number of copies of the on-demand resource storage according to the predicted heat of the on-demand resource; then slice the on-demand resource to generate resource slices and corresponding slice information; according to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the multiple resource slices, map to multiple first virtual nodes on the first hash ring through hash calculation, the first virtual node stores the first index of the resource slice; according to the attribute information of different clients, map to multiple second virtual nodes on the second hash ring through hash calculation, the second virtual node stores the second index of the client; according to the mapping relationship between the first index and the second index, and the load balancing of the first virtual node and the second virtual node, determine to distribute resources to the client. The present invention is applicable to stable online and unstable online devices, and the rapid distribution and expansion of resources can be completed through the above steps; at the same time, according to the resource capacity and the client storage capacity, it is convenient for resource expansion and dynamic adjustment. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1 It is a schematic diagram of the video content distribution process of the content distribution network in the prior art;
[0055] Figure 2 This is one of the flow charts of a resource distribution method provided by an embodiment of the present invention;
[0056] Figure 3 is a schematic diagram of a network structure in which a resource distribution method provided by an embodiment of the present invention is applied to a PCDN network;
[0057] Figure 4 It is a mapping view of a hash index calculated by using resource slices in a resource distribution method provided in an embodiment of the present invention;
[0058] Figure 5 This is a second flow chart of a resource distribution method provided by an embodiment of the present invention;
[0059] Figure 6 This is a third flow chart of a resource distribution method provided by an embodiment of the present invention;
[0060] Figure 7 This is a fourth flow chart of a resource distribution method provided by an embodiment of the present invention;
[0061] Figure 8 It is a structural diagram of a resource distribution device provided by an embodiment of the present invention;
[0062] Fig. 9 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0064] When the client storage space is limited and the high-definition video file is relatively large, in order to avoid several resources occupying all the storage space, the storage space needs to be comprehensively utilized so that the storage use of network nodes is relatively balanced; when the access popularity of resources is not equal, it is necessary to try to avoid excessive concentration of hot resources; when the resource capacity and the client storage capacity are not equal, it is necessary to avoid capacity waste and lack of space for storage. Therefore, the present invention proposes a resource distribution method, device, electronic device and storage medium based on the popularity of on-demand resources and the slicing of on-demand resources.
[0065] Figure 2 This is one of the flow charts of the resource distribution method provided by the embodiment of the present invention. Figure 2 As shown, an embodiment of the present invention provides a resource distribution method, which is applied to a PCDN network (peer-to-peer content distribution network). The PCDN network includes multiple PCDN nodes. The method may specifically include the following steps:
[0066] Step S1: Obtain the predicted popularity of the on-demand resource;
[0067] Step S2: obtaining the number of copies to be stored for the on-demand resource according to the predicted popularity;
[0068] Step S3: generating a corresponding number of storage copies of the on-demand resource according to the number of copies and marking a corresponding copy serial number for each storage copy;
[0069] Step S4: Slice the on-demand resource to obtain multiple resource slices and slice information corresponding to each resource slice, wherein each PCDN node stores one resource slice;
[0070] Step S5: mapping multiple first virtual nodes on the first hash ring through hash calculation according to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the multiple resource slices, wherein the first virtual node stores the first index of the resource slice;
[0071] Step S6: mapping the attribute information of different clients to a plurality of second virtual nodes on the second hash ring through hash calculation, wherein the second virtual nodes store the second index of the client;
[0072] Step S7: Determine resource distribution to the client according to the mapping relationship between the first index and the second index, and the load balancing of the first virtual node and the second virtual node.
[0073] In this embodiment, the on-demand solution and main modules applied to the PCDN network are as follows: Figure 3 As shown, the device attributes include: node type, region, storage, network, memory, CPU, etc.;
[0074] The heat management function is responsible for obtaining the predicted heat of the on-demand resource, which includes the heat generated based on the historical access records of big data and the heat level set for the new data injected by the user;
[0075] The copy management function is: according to the predicted popularity of the on-demand resource, it is converted into the number of copies to be stored in the region. The higher the resource popularity, the more copies it will store. New data is converted into the number of copies according to the popularity level set by the user.
[0076] Resource distribution management functions include: responsible for the slicing and distribution of VOD resources in the region, mapping and maintenance of resource information and client storage. Each PCDN network node is used to store resource slices of VOD resources.
[0077] The resource scheduling management function is to sense the online / offline status of PCDN network nodes, receive on-demand resource sharing requests from nodes, return the complete resource slices and slice information corresponding to the on-demand resources, and the client sharing list information corresponding to the resource slices.
[0078] In this embodiment, step S4 specifically includes:
[0079] If the on-demand resource is a single file resource, the on-demand resource is divided and sliced according to a preset first fixed slice size;
[0080] If the size of the resource slice finally cut is greater than or equal to the preset second fixed slice size, it is determined as a single resource slice;
[0081] If the size of the last cut resource slice is smaller than the second fixed slice size, the last cut resource slice and the previous resource slice are merged into one resource slice, wherein the second fixed slice size is half of the first fixed slice size.
[0082] Specifically, resources mainly include two types, single file resources (such as mp4 or files, etc.) and resource package files. Resource package files contain multiple media resources of different sizes (such as m3u8, etc.).
[0083] If the on-demand resource is a single file resource, the single file resource is divided and sliced according to the preset first fixed slice size L, and its slice information is recorded as [off: whether to offset, length: data length] type. If the last resource slice is greater than or equal to the preset second fixed slice size N (for example, N = L / 2), it is a separate resource slice. When the last resource slice is less than the second fixed size N, it is merged with the previous resource slice into one resource slice.
[0084] In this embodiment, step S4 further specifically includes:
[0085] If the on-demand resource is a resource package file including at least one resource file, obtaining the file size of the resource file in the resource package file;
[0086] If the file size of the resource file is greater than or equal to the first fixed slice size, the resource file is segmented and sliced according to the first fixed slice size;
[0087] If the file size of the resource file is smaller than the first fixed fragment size, the multiple resource files are grouped for processing;
[0088] If the size of the last resource file is greater than or equal to the second fixed fragment size, the last resource file is grouped separately;
[0089] If the size of the last resource file is smaller than the second fixed fragment size, the last resource file and the previous resource file whose file size is smaller than the first fixed fragment size are merged into one group.
[0090] Specifically, if the on-demand resource is a resource package file, after parsing the resource package file (such as m3u8), analyze the size of each resource file in the resource package. Suppose the size of the resource file is M. If M > L, slice the resource shard for the resource file with reference to the above-mentioned slicing method; if M < L, group and number it with other resource files smaller than L in the resource package file. For the last remaining resource file smaller than L, if its file size is greater than or equal to N (such as N = L / 2), it is grouped separately. If the size of this resource file is less than N, it is merged with the previous resource file smaller than L into one group. The slicing information for grouping is: the sequential group of data blocks in the resource package.
[0091] In this embodiment, steps S5 and S6 specifically include:
[0092] According to the attribute information of the on-demand resource, the storage replicas, and the slicing information corresponding to multiple resource slices, map them to multiple first virtual nodes on the first hash ring through hash calculation, as shown in the following formula:
[0093] First virtual node = Hash(on-demand resource file, storage replica, slicing information);
[0094] As Figure 4 shown, for the ring structure based on the hash algorithm - the hash ring, virtual nodes are evenly distributed on the hash ring. When no resource slice is mapped to a virtual node, the virtual node is empty. Once the hash ring is constructed, the position of each virtual node on the hash ring is fixed. Map the resource slices (xxx.1, xxx.2, yyy.1, etc.) that need to establish slice indexes to the first virtual nodes on the first hash ring. The first virtual nodes store the first indexes of the resource slices. One storage replica of an on-demand resource corresponds to generating one hash ring.
[0095] Similarly, according to the attribute information of different clients, map them to multiple second virtual nodes on the second hash ring through hash calculation, as shown in the following formula:
[0096] Resource virtual node = Hash(client ID);
[0097] Map the clients that need to establish client indexes to the second virtual nodes on the second hash ring through the attribute information of the clients (such as client ID). The second virtual nodes store the second indexes of the clients.
[0098] By using the above mechanism to establish indexes for resource slices and clients with virtual nodes, the distribution scale can be effectively reduced; the data within the virtual nodes can perform data distribution and index management for clients through load balancing, and the number of resources distributed from the virtual nodes to clients can be dynamically adjusted according to the total amount of resource content and storage space.
[0099] In this embodiment, step S7 specifically includes:
[0100] Step S701: The client synchronously stores resource slices and slice information to the distribution service;
[0101] Step S702: The distribution service updates the first index and the second index of the resource slice that has completed synchronous storage;
[0102] Step S703: Determine the first virtual node mapped by the client according to the mapping relationship between the first index and the second index;
[0103] Step S704: Determine the resource slice that the client needs to update according to the resource load of the first virtual node and the attributes of the client;
[0104] Step S705: the distribution service sends a resource update request to the client, and the client completes the resource update operation according to the resource update request.
[0105] Step S706: After completing the resource update, the client synchronizes the resource update with the distribution service, and the distribution service updates the first index of the resource slice that has completed the synchronous update.
[0106] Specifically, the resource distribution process: Figure 5 As shown, when the client goes online, the client synchronizes and stores resource slices and slice information to the distribution service. The distribution service updates the first index (index of resource slices) and the second index (client index), and finds the first virtual node mapped by the client based on the mapping relationship between the first index and the second index; finds the resource slices that need to be updated based on the load of the resource slices in the first virtual node and the properties of the client; and sends a resource update request to the client. After the client completes the resource update, it synchronizes the resource update to the distribution service, and the distribution service updates the index information of the resource slices that have completed the synchronization update.
[0107] In this embodiment, step S7 further specifically includes:
[0108] Step S711: determining a client list corresponding to the first virtual node according to a mapping relationship between the first index and the second index;
[0109] Step S712: Determine a client suitable for storing the newly added resource slice from the client list according to the attributes of the client;
[0110] Step S713: the distribution service sends a resource update request to the client;
[0111] Step S714: the client sends a resource sharing request to the resource scheduling service according to the resource update request, and obtains a client sharing list of the resource slice;
[0112] Step S715: The client completes the resource storage operation according to the client sharing list.
[0113] Specifically, the resource update process: Figure 6 As shown, when there is a resource update (including new resources and deleted resources), if a new resource is added, the distribution service analyzes the popularity information of the on-demand resource (including historical records and popularity levels, etc.) and generates the number of copies of the on-demand resource to be stored; obtains the content and length of the on-demand resource, and slices the content and length to generate resource slices and corresponding slice information; the first virtual node mapped by the resource slice is found through hash calculation, and the client list corresponding to the index stored in the first virtual node is found according to the mapping relationship between the first index and the second index, and the client suitable for storing the newly added resource slice is found according to the client attributes, and a resource update request is sent to the client; the client requests the client sharing list of the resource slice from the resource scheduling service, and the client completes the resource storage operation according to the client sharing list.
[0114] If the resource update is to delete the resource, directly find the index corresponding to the resource slice to determine the client information, and send a resource update request to the client; the client requests the client sharing list of the resource slice from the resource scheduling service, and the client completes the resource deletion operation according to the client sharing list.
[0115] Further, step S714 specifically includes:
[0116] Step S7141: The resource scheduling service receives the resource sharing request, queries multiple resource slices corresponding to the on-demand resource, and the client set storing the on-demand resource;
[0117] Step S7142: for each resource slice, determine the clients participating in the PCDN network from the client set to form a client sharing list and return it to the client;
[0118] Step S7143: The client makes a resource sharing request for the resource slices in the PCDN network according to the playback position in the client sharing list, so as to complete the resource sharing of the on-demand resources in the PCDN network.
[0119] Specifically, the resource scheduling process: Figure 7As shown, after receiving the resource sharing request sent by the client, the resource scheduling service queries multiple resource slices corresponding to the on-demand resource and the client set storing the on-demand resource, and finds a client list suitable for participating in the PCDN network from the client set for each resource slice; sends the resource slice and the corresponding client list to the client, and the client makes a resource sharing request for the resource slice in the PCDN network according to the playback position of the client sharing list, so as to complete the resource sharing of the on-demand resource in the PCDN network.
[0120] In summary, the resource distribution method provided in this embodiment has the following technical advantages:
[0121] 1. Based on resource pre-distribution, resource synchronization and resource acquisition, it is easy to complete the rapid distribution and sharing of resources and the efficient processing of shared data. It is suitable for stable online and unstable online devices.
[0122] 2. By establishing a complete resource index, the index contains slice information, and the resource slices and client indexes are calculated through hashing, which facilitates the expansion of massive resources and clients.
[0123] The resource distribution device provided by the embodiment of the present invention is described below. The resource distribution device described below and the resource distribution method described above can be referred to each other.
[0124] Figure 8 Schematic diagram of a resource distribution device provided by an embodiment of the present invention. Figure 8 As shown, a resource distribution device provided by an embodiment of the present invention is applied to a PCDN network, where the PCDN network includes multiple PCDN nodes. The device includes:
[0125] The predicted popularity acquisition module 201 is used to acquire the predicted popularity of the on-demand resource;
[0126] The copy number acquisition module 202 is used to obtain the number of copies to be stored for the on-demand resource according to the predicted popularity;
[0127] The storage copy marking module 203 is used to generate a corresponding number of storage copies of the on-demand resource according to the number of copies and mark each storage copy with a corresponding copy serial number;
[0128] The on-demand resource slicing module 204 is used to slice the on-demand resource to obtain multiple resource slices and slice information corresponding to each resource slice, wherein each PCDN node stores one resource slice;
[0129] A first hash calculation module 205 is used to map multiple first virtual nodes on the first hash ring through hash calculation according to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the multiple resource slices, wherein the first virtual node stores the first index of the resource slice;
[0130] A second hash calculation module 206, configured to map to a plurality of second virtual nodes on a second hash ring through hash calculation according to attribute information of different clients, wherein the second virtual nodes store second indexes of the clients;
[0131] The resource distribution module 207 is used to determine resource distribution to the client according to the mapping relationship between the first index and the second index and the load balancing of the first virtual node and the second virtual node.
[0132] In this embodiment, the on-demand resource slicing module 204 is specifically used for:
[0133] If the on-demand resource is a single file resource, the on-demand resource is divided and sliced according to a preset first fixed slice size;
[0134] If the size of the resource slice finally cut is greater than or equal to the preset second fixed slice size, it is determined as a single resource slice;
[0135] If the size of the last cut resource slice is smaller than the second fixed slice size, the last cut resource slice and the previous resource slice are merged into one resource slice, wherein the second fixed slice size is half of the first fixed slice size.
[0136] The on-demand resource slicing module 204 is also specifically used for:
[0137] If the on-demand resource is a resource package file including at least one resource file, obtaining the file size of the resource file in the resource package file;
[0138] If the file size of the resource file is greater than or equal to the first fixed slice size, the resource file is segmented and sliced according to the first fixed slice size;
[0139] If the file size of the resource file is smaller than the first fixed fragment size, the multiple resource files are grouped for processing;
[0140] If the size of the last resource file is greater than or equal to the second fixed fragment size, the last resource file is grouped separately;
[0141] If the size of the last resource file is smaller than the second fixed fragment size, the last resource file and the previous resource file whose file size is smaller than the first fixed fragment size are merged into one group.
[0142] In this embodiment, the resource distribution module 207 is specifically used for:
[0143] The client synchronizes and stores resource slices and slice information to the distribution service;
[0144] The distribution service updates the first index and the second index of the resource slice that has completed synchronous storage;
[0145] Determine a first virtual node mapped by the client according to a mapping relationship between the first index and the second index;
[0146] Determine the resource slice that the client needs to update according to the resource load of the first virtual node and the attributes of the client;
[0147] The distribution service sends a resource update request to the client, and the client completes the resource update operation according to the resource update request.
[0148] After the client completes the resource update, it synchronizes the resource update with the distribution service, and the distribution service updates the first index of the resource slice that has completed the synchronization update.
[0149] The resource distribution module 207 is also specifically used for:
[0150] Determine a client list corresponding to the first virtual node according to a mapping relationship between the first index and the second index;
[0151] Determine a client suitable for storing the newly added resource slice from the client list according to the client's attributes;
[0152] The distribution service sends a resource update request to the client;
[0153] The client sends a resource sharing request to the resource scheduling service based on the resource update request, and obtains the client sharing list of the resource slice, which includes:
[0154] The resource scheduling service receives resource sharing requests, queries multiple resource slices corresponding to the on-demand resources, and the client set storing the on-demand resources;
[0155] For each resource slice, determine the clients participating in the PCDN network from the client set to form a client sharing list and return it to the client;
[0156] The client makes a resource sharing request for the resource slice in the PCDN network according to the playback position in the client sharing list, so as to complete the resource sharing of the on-demand resource in the PCDN network;
[0157] The client completes the resource storage operation according to the client sharing list.
[0158] Fig. 9 An example of a physical structure diagram of an electronic device is shown in FIG. Fig. 9 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call a computer program in the memory 330 to execute the resource distribution method provided in the above embodiment, which is applied to a PCDN network, wherein the PCDN network includes multiple PCDN nodes, and the method includes:
[0159] Get the predicted popularity of on-demand resources;
[0160] The number of copies of the on-demand resource to be stored is obtained based on the predicted popularity;
[0161] According to the number of copies, generate a corresponding number of storage copies of the on-demand resource and mark each storage copy with a corresponding copy serial number;
[0162] Slice the on-demand resource to obtain multiple resource slices and slice information corresponding to each resource slice, wherein each PCDN node stores one resource slice;
[0163] According to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the plurality of resource slices, a plurality of first virtual nodes mapped to the first hash ring are calculated by hashing, and the first virtual node stores a first index of the resource slice;
[0164] According to the attribute information of different clients, a plurality of second virtual nodes are mapped to the second hash ring through hash calculation, and the second virtual nodes store the second index of the client;
[0165] The resource distribution to the client is determined according to the mapping relationship between the first index and the second index, and the load balancing of the first virtual node and the second virtual node.
[0166] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0167] On the other hand, an embodiment of the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the resource distribution method provided in the above embodiment, applied to a PCDN network, the PCDN network includes multiple PCDN nodes, the method includes:
[0168] Get the predicted popularity of on-demand resources;
[0169] The number of copies of the on-demand resource to be stored is obtained based on the predicted popularity;
[0170] According to the number of copies, generate a corresponding number of storage copies of the on-demand resource and mark each storage copy with a corresponding copy serial number;
[0171] Slice the on-demand resource to obtain multiple resource slices and slice information corresponding to each resource slice, wherein each PCDN node stores one resource slice;
[0172] According to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the plurality of resource slices, a plurality of first virtual nodes mapped to the first hash ring are calculated by hashing, and the first virtual node stores a first index of the resource slice;
[0173] According to the attribute information of different clients, a plurality of second virtual nodes are mapped to the second hash ring through hash calculation, and the second virtual nodes store the second index of the client;
[0174] The resource distribution to the client is determined according to the mapping relationship between the first index and the second index, and the load balancing of the first virtual node and the second virtual node.
[0175] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for distributing resources provided in the above embodiment is implemented, and the method is applied to a PCDN network, wherein the PCDN network includes a plurality of PCDN nodes. The method includes:
[0176] Get the predicted popularity of on-demand resources;
[0177] The number of copies of the on-demand resource to be stored is obtained based on the predicted popularity;
[0178] According to the number of copies, generate a corresponding number of storage copies of the on-demand resource and mark each storage copy with a corresponding copy serial number;
[0179] Slice the on-demand resource to obtain multiple resource slices and slice information corresponding to each resource slice, wherein each PCDN node stores one resource slice;
[0180] According to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the plurality of resource slices, a plurality of first virtual nodes mapped to the first hash ring are calculated by hashing, and the first virtual node stores a first index of the resource slice;
[0181] According to the attribute information of different clients, a plurality of second virtual nodes are mapped to the second hash ring through hash calculation, and the second virtual nodes store the second index of the client;
[0182] The resource distribution to the client is determined according to the mapping relationship between the first index and the second index, and the load balancing of the first virtual node and the second virtual node.
[0183] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0184] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0185] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A resource distribution method, characterized in that: Applied to a PCDN network, the PCDN network includes a plurality of PCDN nodes, and the method includes: Get the predicted popularity of on-demand resources; Obtaining the number of copies of the on-demand resource to be stored according to the predicted popularity; According to the number of copies, generating a corresponding number of storage copies of the on-demand resource and marking a corresponding copy serial number for each storage copy; Slicing the on-demand resource to obtain a plurality of resource slices and slice information corresponding to each of the resource slices, wherein each of the PCDN nodes stores one of the resource slices; According to the attribute information of the on-demand resource, the storage copy and the slice information corresponding to the plurality of resource slices, a plurality of first virtual nodes mapped to the first hash ring are calculated by hashing, wherein the first virtual node stores a first index of the resource slice; According to the attribute information of different clients, a plurality of second virtual nodes mapped to the second hash ring are calculated by hashing, and the second virtual nodes store the second index of the client; Resource distribution to the client is determined based on a mapping relationship between the first index and the second index, and load balancing between the first virtual node and the second virtual node.
2. The resource distribution method according to claim 1, characterized in that: The step of slicing the on-demand resource to obtain a plurality of resource slices and slice information corresponding to each of the resource slices includes: If the on-demand resource is a single file resource, dividing and slicing the on-demand resource according to a preset first fixed slice size; If the size of the resource slice finally cut is greater than or equal to the preset second fixed slice size, it is determined to be a single resource slice; If the size of the resource slice cut last is smaller than the second fixed slice size, the resource slice cut last is merged with the previous resource slice into one resource slice, wherein the second fixed slice size is half of the first fixed slice size.
3. The resource distribution method according to claim 2, characterized in that: The step of slicing the on-demand resource to obtain a plurality of resource slices and slice information corresponding to each of the resource slices also includes: If the on-demand resource is a resource package file including at least one resource file, obtaining the file size of the resource file in the resource package file; If the file size of the resource file is greater than or equal to the first fixed slice size, dividing and slicing the resource file according to the first fixed slice size; If the file size of the resource file is smaller than the first fixed fragment size, grouping the plurality of resource files; If the size of the last resource file is greater than or equal to the second fixed fragment size, the last resource file is grouped separately; If the size of the last resource file is smaller than the second fixed fragment size, the last resource file and the previous resource file whose file size is smaller than the first fixed fragment size are merged into one group.
4. The resource distribution method according to claim 1, characterized in that: The step of determining resource distribution to the client according to the mapping relationship between the first index and the second index and the load balancing of the first virtual node and the second virtual node includes: The client synchronously stores the resource slice and the slice information to the distribution service; The distribution service updates the first index and the second index of the resource slice that has completed synchronous storage; Determine the first virtual node mapped by the client according to the mapping relationship between the first index and the second index; Determine the resource slice that needs to be updated by the client according to the resource load of the first virtual node and the attributes of the client; The distribution service sends a resource update request to the client, and the client completes a resource update operation according to the resource update request.
5. The resource distribution method according to claim 1, characterized in that: After the client completes the resource update operation according to the resource update request, the method further includes: After completing the resource update, the client synchronizes the resource update with the distribution service, and the distribution service updates the first index of the resource slice that has completed the synchronous update.
6. The resource distribution method according to claim 1, characterized in that: When the resource update request is a request for adding a new resource, correspondingly, the step of determining the resource distribution to the client according to the mapping relationship between the first index and the second index and the load balancing of the first virtual node and the second virtual node further includes: Determine a client list corresponding to the first virtual node according to a mapping relationship between the first index and the second index; Determining the client suitable for storing the newly added resource slice from the client list according to the attributes of the client; The distribution service sends a resource update request to the client; The client sends a resource sharing request to the resource scheduling service according to the resource update request, and obtains a client sharing list of the resource slice; The client completes the resource storage operation according to the client sharing list.
7. The resource distribution method according to claim 1, characterized in that: The step of the client sending a resource sharing request to the resource scheduling service according to the resource update request to obtain a client sharing list of the resource slice includes: The resource scheduling service receives the resource sharing request, queries a plurality of resource slices corresponding to the on-demand resource, and stores a client set of the on-demand resource; For each resource slice, determining a client participating in the PCDN network from the client set to form a client sharing list and return it to the client; The client makes a resource sharing request for the resource slices in the PCDN network according to the playback position of the client sharing list, so as to complete the resource sharing of the on-demand resource in the PCDN network.
8. A resource distribution device, characterized in that: Applied to a PCDN network, the PCDN network includes a plurality of PCDN nodes, and the device includes: A predicted popularity acquisition module is used to obtain the predicted popularity of on-demand resources; A copy quantity acquisition module, used to obtain the number of copies of the on-demand resource to be stored according to the predicted popularity; A storage copy marking module, used to generate a corresponding number of storage copies of the on-demand resource according to the number of copies and mark each storage copy with a corresponding copy serial number; A video-on-demand resource slicing module, configured to slice the video-on-demand resource to obtain a plurality of resource slices and slicing information corresponding to each of the resource slices, wherein each of the PCDN nodes stores one of the resource slices; A first hash calculation module, configured to map to a plurality of first virtual nodes on a first hash ring through hash calculation according to the attribute information of the on-demand resource, the storage copy, and slice information corresponding to the plurality of resource slices, wherein the first virtual node stores a first index of the resource slice; A second hash calculation module, used to map to a plurality of second virtual nodes on a second hash ring through hash calculation according to attribute information of different clients, wherein the second virtual nodes store a second index of the client; A resource distribution module is used to determine resource distribution to the client according to a mapping relationship between the first index and the second index, and load balancing between the first virtual node and the second virtual node.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the resource distribution method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the resource distribution method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Content metadata storing, inquiring method and managing system in content delivery network (CDN)
CN101741731A
File deployment method and device and scheduling method and device
CN110035306A
Content distribution method, device and system and storage medium
CN113296924A
Method and apparatus for routing data to a load balanced server using MPLS packet labels
US6856991B1
Resource acquisition method and apparatus, and node device in CDN network
WO2021135835A1
