4.1. Scheduling Heterogeneous Tasks with Data Migration
For a data center consists of multiple uniform servers with a default data (blocks) placement, which ensures that there are 3 data replicas for each data. The problem is to assign the heterogeneous tasks on the servers such that the task execution time is minimized. It could be formulated as:
where
is the workload, which indicates the task execution time as mentioned above. The number of servers in the data center is
N, and the number of data (blocks) is
K.
The first constraint means that the hosted data (blocks) for each server should not exceed its storage capacity, represented by M. The second constraint means that the task response time, indicated by , should be greater than the task start time, , where means the set of online tasks while represents the set of periodic tasks, and we have , .
Since there are
N servers working at the same time, each server has a workload
. If we find that server
has the maximum workload and we minimize the maximum load of
, the whole job execution time of system will be reduced. To achieve this goal, each time we assign a task to the server, we select the server with the least workload in the system, and execute the task in the mode with the least execution time. Obviously, it could be better to achieve data locality for the tasks to reduce the task execution time. Hence, the problem is to pick one task from the queue to occupy the available computing resources. If there is no proper task, which means none of the tasks could be executed locally, we need to make a decision between waiting and remote access to achieve better benefit. Therefore, we propose the heterogeneous task scheduling as shown in Algorithm 1.
Algorithm 1: Heterogeneous task scheduling. |
- Require:
: the set of online tasks which have arrived the system; : the set of periodic tasks which have arrived the system; : the server with minimum workload; : the server; t: the final completion time; - 1:
; - 2:
for to N do - 3:
if
then - 4:
if
then - 5:
assign(); - 6:
else if
then - 7:
if
then - 8:
ifand
then - 9:
assign(); - 10:
else - 11:
assign(); - 12:
else if
then - 13:
ScheduleTaskwithDataMigration(); - 14:
else if
then - 15:
assign(); - 16:
else if
then - 17:
if
then - 18:
; - 19:
if
then - 20:
assign(); - 21:
else - 22:
assign(); - 23:
else if
then - 24:
ScheduleTaskwithDataMigration(); - 25:
; - 26:
update(); - 27:
return t;
|
In Algorithm 1, is an idle server with available resource slots and we need to assign a task to it. Because the heterogeneous tasks consist of periodic tasks and online tasks, we first check whether there is an online task in the queue. If the queue of online tasks is not empty, we will select one task and judge if it can be executed locally. We assign the task to if it can access its input data from . Otherwise, we find the server with minimum workload.if has the required data of task in the data center, we make a comparison between two kinds of time: (1) the waiting time until is idle, and the execution time locally, represented by by ; (2) the time of executing task on server in remote mode, the time is represented by . We compare them and find the less one and indicate it with . Here, with the result of , we have two choices as follows:
. It means we can schedule task to be executed on server so that the remote task can be a local task and reduce the execution time. However, this a an online task scheduling problem. As mentioned before, an online task has a constraint that it has to be executed before its deadline of response time. It means the waiting time until the server to be idle cannot exceed the response time of . Therefore, before we schedule , we should guarantee that the waiting time is less than . This manner of scheduling refers to delay scheduling.
. If the time of executing task in remote mode is minimum, we can assign task to server and execute it in remote mode immediately.
If task cannot be executed locally on server and there is no local data blocks of task on server , we could consider whether to introduce data migration to execute . The strategy of scheduling tasks with data migration will be interpreted in next subsection.
If the queue of online tasks is empty, we will schedule the periodic tasks. We first check if there is a local periodic task and assign it to the idle server . If all periodic tasks cannot be executed locally on , we need to find the task (say ) with the least execution time, indicated as . Then, we still need to check the execution mode for . If , the task will be assigned to server with locality mode by data migration. Or, the task will be assigned to server with remote execution mode, as shown in the algorithm. Since periodic tasks have much longer response time than online tasks, we do not need consider the waiting time and response time.
4.2. Data Migration
In
Section 3 of this paper, we have discussed that data migration will bring extra time consumption. Because data transferring costs network, it must influence the execution of remote tasks. Therefore, we must consider the impacts on remote tasks before migrating data blocks. We explain the process of scheduling a task with data migration in Algorithm 2 as follows.
Algorithm 2: ScheduleTaskwithDataMigration(J). |
- Require:
: the server; J:the selected task; :the server with minimum workload in cluster without . - 1:
if There is a remote task on and
then - 2:
; - 3:
else if There is a remote task on and
then - 4:
; - 5:
else if There is a local task on and
then - 6:
; - 7:
else if There is a local task on and
then - 8:
; - 9:
if
then - 10:
assign(); - 11:
else - 12:
migration(); - 13:
assign();
|
In Algorithm 2, task J can be executed on in remote mode or executed on after data migration. Both of the two execution modes need data transmission, which brings transmission cost. We need to compare two time costs: and . The first means the task on server still needs to take to execute. is the time of transferring required data block by selected task J to server . We consider data migration while the is executing a previous task. If is larger than , which means the data migration will not finish when is idle. Hence, task J needs to wait for the end of data transferring before it can be executed. Otherwise, data migration will finish before being idle, and task J can be executed when completes its previous task. Based on this time comparison and decision on if there is a remote task on server , we can list four scenarios as follows:
There is a remote task on
and
: In this condition, the time of migrating data is over the rest execution time of previous task on
, task
J needs to wait the end of data migration before it can be executed. Because the previous task on
is remote task,
and
will double. The work load of
will increase
, so that the new workload of
is:
Because the previous task on
will finish before data migration, the time of migrating data will not be twice when
is idle. The rest time for task
J to wait and be executed when
is idle is:
Therefore, the task execution time with data migration could be:
The time of executing task J on in remote mode is , we compare these two kinds of time and select the mode with less time.
There is a remote task on
: In this condition, data migration has finished before
is idle. The task
J could be executed directly on
.
and
will also double when executing a remote task and migrating data at the same time on
. If data migration is finished,
will still take some time to execute its remote task, and the time is:
The new workload of server
is:
Therefore, the whole time for task
J to wait and be executed on
is:
We also compare the time above with and select the less one.
There is a local task on : Because local tasks do not need network, data migration will not affect local tasks. Similarly, we compare and , and calculate the whole time for task J to be executed on , the time is . We choose the less one between and and execute J in corresponding mode.
There is a local task on : Similar to the situation above, we calculate the whole time for task J to be executed on , the time is . We compare it with and choose the less one.
From the case analysis, we find that we will execute J on in remote mode with few cases. Otherwise, we migrate the required data of J to from other server to server and execute it in locality mode. Here, we will introduce more about data migration. The algorithm on how to migrate a data block is described in Algorithm 3.
For the migration procedure, we first judge if the destination server has enough storage capacity (
), we can migrate the data block to it and the number of data replica (
) increases by one. If target server has no space to store the data block, we will find the data block
with least degree, which means there is few task needs the data block. If the replica number of
is more than one, we can replace it with the migrated data block. This is because we have to guarantee that each data block in the data center must has at least one replica. If the replica is the only one, we give up the operation of data migration.
Algorithm 3: migration(). |
- Require:
J: the selected task; : the destination server; : the number of replicas of each data; : the number of tasks which require data as input;: the target server for data migration. - 1:
if
then - 2:
assign to ; - 3:
; - 4:
else - 5:
for to M do - 6:
; - 7:
if
then - 8:
replace with ;
|