• 沒有找到結果。

Distributed Scheduling Approach (DSA)

第三章 基於賽局理論之分散式排程方法

3.2 Distributed Scheduling Approach (DSA)

此分散式排程方法雖要求所有聯邦雲皆需運行此演算法執行工作排程,但所 有聯邦雲皆以完全獨立模式決定排程策略,且不互相干涉,即擁有分散式精神。

此演算法主要用於如何在聯邦雲中分配和選擇工作,分為兩個情況:需要租資源 時該如何選擇租用何資源以及接受外包需求時要如何選擇接受何種外包。由以下 演算法可以明顯地展現出聯邦雲中的成員皆為自私。每個雲皆可依照資源及工作 情況成為剩餘資源剩餘方或是資源不足方,成為資源剩餘方之前必頇優先執行 Local 所有 Jobs,即 Local Jobs 優先權高於 Outsourcing Jobs。本研究方法為結合 以下數個演算法,當為資源不足方,執行租用資源之演算法(Algorithm II. Job Scheduling)尋找最低價格之資源,否則執行如何解決外包需求之演算法。

此演算法為一多目標方法,本研究將目標訂為最小化預估執行時間與成本,

此目標可由額外加權值之乘積而轉換為傾向預估執行時間或是成本之選擇。如圖 十四所示,圖中每個點為資源剩餘方,此方法將用於選擇何資源剩餘方發出外包 需求。本研究之多目標為對等預估執行時間與成本之乘積,所以圖中角度為 45o, 預 估 執 行 時 間 與 成 本 之 乘 積 越 低 者 代 表 為 較 佳 解 。 C 為 聯 邦 雲 之 雲 成 員 C={C1,C2,C3,C4,….CC}。

25

𝐦𝐢𝐧𝒊∈𝑵 𝑬𝒙𝒑𝒆𝒄𝒕𝒆𝒅 𝑻𝒖𝒓𝒏𝒂𝒓𝒐𝒖𝒏𝒅 𝑻𝒊𝒎𝒆 ∗ 𝑪𝒐𝒔𝒕

= 𝐦𝐢𝐧

𝒊∈𝑵 𝑬𝒙𝒑𝒆𝒄𝒕𝒆𝒅 𝑻𝒖𝒓𝒏𝒂𝒓𝒐𝒖𝒏𝒅 𝑻𝒊𝒎𝒆

∗ (𝑳𝒐𝒄𝒂𝒍 𝑪𝒐𝒔𝒕 ∗𝑵𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝑱𝒐𝒃 𝒊𝒔 𝑻𝒂𝒔𝒌𝒔 𝒓𝒖𝒏 𝒊𝒏 𝑳𝒐𝒄𝒂𝒍 𝑪𝒍𝒐𝒖𝒅 𝑵𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝑱𝒐𝒃 𝒊𝒔 𝑻𝒂𝒔𝒌𝒔

+ 𝑪𝒍𝒐𝒖𝒅 𝒄 𝑪𝒐𝒔𝒕 ∗𝑵𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝑱𝒐𝒃 𝒊𝒔 𝑶𝒖𝒕𝒔𝒐𝒖𝒓𝒄𝒊𝒏𝒈 𝑻𝒂𝒔𝒌𝒔 𝑵𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝑱𝒐𝒃 𝒊𝒔 𝑻𝒂𝒔𝒌𝒔 )

(1)

圖 十四 多目標最佳化

每個雲都會接到一堆運算需求,當本地資源足以滿足需求時,優先執行於 Local Cloud;而當 Local Cloud 資源不足時,即馬上尋找尚有剩餘資源之雲供應 商並且比較其價錢,向最低價格發出請求,等待要求被接受。若不被接受則向下 個供應商發出請求,直至外包資源租用成功。另外若是整個聯邦雲環境已經沒有 足夠資源處理此要求,則放棄此工作。

26

Algorithm II. Job Scheduling

Input:Jl( a set of jobs for cloudl.), Rj( job j resource requirement.), Vl( local cloud remaining resource.), Gj( outsourcing task group resource requirement.)

Output:Mapping Table for resource and jobs.(ex:{J1:V3}{J2:V1}{J3:V2})

{lack_resource=lack resource number(Rj , Vl);}

While (lack_resource){

C_temp=look for other cloud providers with enough resources;

outsourcingC=MinEq.1(C_temp);

If (outsourcingC->price > Outsourcing_boundn) {give up Jj;update Vl; update lack_resource;}

Else if (outsourcingC->price <= Outsourcing_boundn) without competition {

allocate Gj to Vl and Vc;

update Vl; update lack_resource;

}

Else {update lack_resource;}

}

27

公式(6)為計價方式,當沒有資源競爭產生時,資源價格採用 cost-driven Pricing[27],否則需透過額外加上競爭程度與帄均邊際成本之積調整價格。

28

Algorithm III. Pricing

Input:Vc(Cloud C’s remaining resource.), ratec(The Cost-driven Pricing rate for Cloud C.), CompetitionLevelc(The Cloud C’s Competition degree.), Ri(an outsourcing request.)

Output:Mapping Table for remaining resources and outsourcing jobs.

(ex:{V1:R3}{V2:R1}{V3:R2}) {

Update CompetitionLevelc;

Pricec= Cost-driven Pricing(Vc,ratec) While CompetitionLevelc >1

{

Pricec= Pricec + Marginal cost(Vc,Ri) Update CompetitionLevelc;

}

29

30

Algorithm IV. modified 0/1 knapspack

Input:resources(cloud remaining resources.), outsourcing requests(a set of outsourcing requests.)

Output:strategy(An outsourcing strategy for cloud provider.(ex:{item1,item3,item4,item5},{item2,item3})) {

Min cost=maximal value Knapspack(item)

{

New a fork for item.

Select a non-repetitive item to strategy from outsourcing requests If total strategy outsourcing requests <= resources

Calculate marginal cost by eq.13.

If Min cost > marginal cost then

Select strategy and update Min cost.

Knapspack(next item);

Else fork end }

Knapspack(first item) Return strategy.

}

表 二 Game scenario

Cloud Providers\

Cloud Environment

T

p

秒後有 Job X T

p

秒後不會有 Job X

31

上述方法修改了傳統 0/1 背包演算法選擇策略,每個外包需求為物件、外包 資源需求為價格、剩餘資源為背包容量,目標為利用公式(13)找出最低值。傳統 的 0/1 背包演算法由於時間複雜度太高而無法用於即時系統;因此本研究針對此 缺點修改了演算法,當選定某個物件之後,若超出了背包空間,則之後的物件選 擇與計算則皆不進行。所以能將時間複雜度壓縮至一定區間,此區間決定於剩餘 資源多寡,當剩餘資源越少所需要的計算也隨之減少,因大部分之物件選擇都被 認定為不必要的計算。

圖 十五 0/1 knapspack Algorithm 運算範圍圖

圖十五為一般的 0/1 背包演算法所需的運算範圍。假設剩餘資源為 8,Job1 需要 9 個資源、Job2 需要 7 個資源、Job3 需要 5 個資源,橘色部分表示必頇執 行運算。當外包需求漸漸增加,運算需求則呈現指數成長,時間複雜度為 O(2N),

對於即時系統,當外包需求增加至一定數量,必定造成嚴重瓶頸,因此需修改此 缺點。

32

圖 十六 modified 0/1 knapspack Algorithm 運算範圍圖

透過 modified 0/1 knapspack Algorithm 修剪掉大量不必要的運算,所謂的不 必要的運算代表就算持續選擇其他外包需求也無法對結果產生影響。如圖 十六 所示,大部分的運算將被刪去,此修剪機制將能為此演算法加速許多,實際執行 時間與比較將於下一章節詳細說明。

Algorithm V 用於外包需求決策,當目前剩餘資源足以滿足所有外包資源時,

即接受所有外包需求;否則將利用 modified 0/1 knapspack 計算出最低邊際成本 之策略組合。此組合不一定唯一,若不唯一則優先處理擁有較高資源需求工作之 組合,否則隨機選擇策略,策略決定後回覆要求且更新資源狀態。

33

Algorithm V. Re-rented game theory

Input:Resources(remaining resource.), outsourcing requests(a set of outsourcing requests.)

Output:An outsourcing strategy for cloud provider. (ex:{item2,item3}) {

If resources enough to satisfy all outsourcing requests Then accept all requests.

Else

Obtain acceptable strategy by modified 0/1 knapspack algorithm If Strategies with minimal marginal cost not only one.

If the maximum resource request job in strategies are same.

then accept randomly.

Else Accept strategy with maximum resource request job.

Else accept strategy with minimal acceptable strategy marginal cost.

Update resource status and response requests.

}

34

相關文件