Disclosure of Invention
The invention aims to provide a resource pre-distribution method and a device, which solve the problems that bandwidth resources are wasted due to excessive issued copies or insufficient supply and demand are caused by inaccurate calculation of the demand of different files in the prior art; and the problem that the file hit opportunity is missed because the pre-distribution cannot be carried out before the actual need.
The technical scheme of the invention is realized as follows:
in one aspect, the present invention provides a method for pre-distributing resources, including:
respectively calculating the predicted bandwidth amounts of a plurality of target files;
calculating the number of tasks planned to be issued of each target file according to the code rate and the predicted bandwidth amount of each target file;
correcting the planned task issuing number according to the number of the target files held by all the available service equipment at present to acquire the actual task issuing number of each target file;
and distributing to available service equipment according to the actually issued task number.
In the method for pre-distributing resources according to the present invention, the calculating the predicted bandwidth amounts of the plurality of target files respectively includes:
acquiring a first time point according to the current moment, and acquiring a second time point after a first period interval of the first time point;
acquiring a third time point before a second period interval of the second time point, and acquiring the total bandwidth amount of the third time point;
acquiring a fourth time point before a first cycle interval of the first time point, determining a time period from the fourth time point to the first time point as a measured time period, and acquiring an access frequency ranking table of a plurality of target files in the measured time period; the access frequency ranking table comprises a plurality of access frequencies of the target files;
dividing the number of accesses of each of the target files by the total number of accesses of the plurality of target files to obtain a weight coefficient of each of the target files;
multiplying the weight coefficient of each of the target files by the total amount of bandwidth at the third point in time to obtain a predicted amount of bandwidth at the second point in time for each of the target files. In the method for pre-distributing resources of the present invention, the calculating the number of tasks to be scheduled to be issued for each target file according to the code rate and the predicted bandwidth amount of each target file includes:
acquiring the code rate of each target file from the access times ranking table; the access times ranking table also comprises the code rate of each target file;
and dividing the predicted bandwidth amount of each target file by the corresponding code rate to obtain the planned issuing task number of each target file.
In the method for pre-distributing resources of the present invention, the correcting the number of task copies scheduled to be issued according to the number of copies of each target file already held by all currently available service devices to obtain the actual number of task copies issued for each target file includes:
acquiring the number of copies of each target file which are already held by all currently available service equipment;
and subtracting the corresponding number of copies from the planned issued task number of each target file to obtain the actual issued task number of copies.
In the method for pre-distributing resources according to the present invention, the distributing to available service devices according to the number of actually issued tasks includes:
sequencing a plurality of target files according to the access times of the target files;
and selecting available service equipment according to the sorting result to distribute the target files respectively.
In another aspect, there is provided a resource pre-distribution apparatus having stored therein a plurality of instructions adapted to be loaded and executed by a processor, comprising:
respectively calculating the predicted bandwidth amounts of a plurality of target files;
calculating the number of tasks planned to be issued of each target file according to the code rate and the predicted bandwidth amount of each target file;
correcting the planned task issuing number according to the number of the target files held by all the available service equipment at present to acquire the actual task issuing number of each target file;
and distributing to available service equipment according to the actually issued task number.
In the resource pre-allocation apparatus according to the present invention, the calculating the predicted bandwidth amounts of the plurality of target files, respectively, includes:
acquiring a first time point according to the current moment, and acquiring a second time point after a first period interval of the first time point;
acquiring a third time point before a second period interval of the second time point, and acquiring the total bandwidth amount of the third time point;
acquiring a fourth time point before a first cycle interval of the first time point, determining a time period from the fourth time point to the first time point as a measured time period, and acquiring an access frequency ranking table of a plurality of target files in the measured time period; the access frequency ranking table comprises a plurality of access frequencies of the target files;
dividing the number of accesses of each of the target files by the total number of accesses of the plurality of target files to obtain a weight coefficient of each of the target files;
multiplying the weight coefficient of each of the target files by the total amount of bandwidth at the third point in time to obtain a predicted amount of bandwidth at the second point in time for each of the target files. In the resource pre-distribution device of the present invention, the calculating the number of tasks scheduled to be issued for each target file according to the code rate and the predicted bandwidth amount of each target file includes:
acquiring the code rate of each target file from the access times ranking table; the access times ranking table also comprises the code rate of each target file;
and dividing the predicted bandwidth amount of each target file by the corresponding code rate to obtain the planned issuing task number of each target file.
In the resource pre-distribution apparatus of the present invention, the correcting the number of task copies scheduled to be issued according to the number of copies of each target file already held by all currently available service devices to obtain the actual number of task copies issued for each target file includes:
acquiring the number of copies of each target file which are already held by all currently available service equipment;
and subtracting the corresponding number of copies from the planned issued task number of each target file to obtain the actual issued task number of copies.
In the resource pre-distribution apparatus of the present invention, the distributing to the available service devices according to the number of actually issued tasks includes:
sequencing a plurality of target files according to the access times of the target files;
and selecting available service equipment according to the sorting result to distribute the target files respectively.
Therefore, the method has the advantages that the demand of different files is accurately calculated, the node capacity is fully considered, and resources are reasonably utilized; the file is pre-distributed before the real need, so that the hit rate of the file is improved.
Detailed Description
In order to more clearly understand the technical features, objects, and effects of the present invention, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It is to be understood that the following description is only a specific illustration of the embodiments of the present invention and should not be taken as limiting the scope of the invention.
Referring to fig. 1, fig. 1 is a flowchart of a resource pre-distribution method according to an embodiment of the present invention, where the resource pre-distribution method includes steps S1-S4:
s1, respectively calculating the predicted bandwidth amounts of the target files; step S1 includes steps S11-S15:
s11, acquiring a first time point according to the current moment, and acquiring a second time point after a first period interval of the first time point; referring to fig. 2, fig. 2 is a schematic diagram of time point distribution provided by an embodiment of the present invention, for example: the pre-distribution system calculates the demand of the target file at the next interval time point through a preset algorithm A, wherein the interval during the first week is a preset threshold value, such as 30 minutes. The current time is 12:10, the first time point is 12:00 of the current date, the first week interval is 30 minutes, and the second time point is 12:30 of the current date.
S12, acquiring a third time point before the second period interval of the second time point, and acquiring the total bandwidth amount of the third time point; for example: the required amount of the next interval time point of the target file is calculated by the preset algorithm a of step S11 (hereinafter, this time point is referred to as time point C). And then, acquiring the total bandwidth amount of the same time point C of yesterday through big data statistics. I.e. the second week interval is one day. Referring to fig. 2, time point C (12:30) of the current date is the second time point, yesterday the same time point C (12:30) is the third time point, and the second week interval is 1 day.
S13, acquiring a fourth time point before the first cycle interval of the first time point, determining a time period from the fourth time point to the first time point as a measured time period, and acquiring an access frequency ranking table of a plurality of target files in the measured time period; the access frequency ranking table comprises a plurality of access frequencies of the target files; for example: acquiring an access time ranking table of a target file in an interval time period (hereinafter referred to as time period D) at a time point C, wherein the access time ranking table of the target file comprises { file identification, access times and file code rate }; referring to FIG. 2, the fourth time point is 11:30 of the current date; from 11:30 to 12:00 of the current date is time period D, i.e., the measured time period.
S14, dividing the access times of each target file by the total access times of the plurality of target files to obtain a weight coefficient of each target file; for example: and dividing the access times of each target file in the target file access times sorting table of the time period D by the sum of the access times of all files to be used as a weight coefficient.
And S15, multiplying the weight coefficient of each target file by the total bandwidth amount at the third time point to obtain the predicted bandwidth amount of each target file at the second time point. For example: the total bandwidth amount of the same time point C (third time point) of yesterday is multiplied by the weight coefficient of each target file, and the predicted bandwidth amount of each target file at the time point C (second time point) is calculated. The method comprises the steps of calculating the accurate number of the target to be issued according to a preset algorithm B, and issuing the accurate number to available service equipment, wherein the service equipment provides an uploading bandwidth service for the networking hardware equipment implanted with preset software.
S2, calculating the number of tasks planned to be issued of each target file according to the code rate and the predicted bandwidth of each target file; step S2 includes steps S21-S22:
s21, obtaining the code rate of each target file from the access times sorting table; the access times ranking table also comprises the code rate of each target file; for example: and obtaining the code rate of each target file and the predicted bandwidth amount of the time point C from the target file access frequency sorting table of the time period D.
And S22, dividing the predicted bandwidth amount of each target file by the corresponding code rate to obtain the planned issuing task number of each target file. For example: and dividing the predicted bandwidth amount of each target file by the code rate of the target file to obtain the number of tasks (hereinafter referred to as task number E) required by each target file to be issued in a plan manner.
S3, correcting the planned task issuing number according to the number of the target files held by all the available service equipment at present to obtain the actual task issuing number of each target file; step S3 includes steps S31-S32:
and S31, acquiring the number of copies of each target file which are already held by all the currently available service equipment.
And S32, subtracting the corresponding number of copies from the number of the planned issued tasks of each target file to obtain the number of the actually issued tasks. For example: subtracting the number of the tasks E of each target file from the number of the tasks F of each target file, which is recorded by the scheduling server currently and is already held by all available service equipment, and calculating the result to be the number of the issued tasks F of each target file.
And S4, distributing the number of the actually issued task copies to available service equipment. Step S4 includes steps S41-S42:
s41, sorting the target files according to the access times of the target files; for example: and the scheduling server sorts the target files in the file access times sorting table according to the access times.
And S42, selecting available service equipment according to the sorting result to distribute the target files respectively. For example: and selecting available service equipment for distributing the files according to the target file copy number F from high to low one by one.
In another aspect, a resource pre-distribution apparatus is provided having stored therein a plurality of instructions adapted to be loaded and executed by a processor. Therefore, the resource pre-distribution device realizes the resource pre-distribution method.
In summary, although the present invention has been described with reference to the preferred embodiments, the above-described preferred embodiments are not intended to limit the present invention, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention, therefore, the scope of the present invention shall be determined by the appended claims.