Fair Scheduler Queue Basics

示例:具有正在Running的應(yīng)用程序的集群

假設(shè)我們有一個(gè)yarn集群,其總資源<內(nèi)存:800GB,vcores 200>,有兩個(gè)隊(duì)列:root.busy(權(quán)重=1.0)和root.sometimes_busy(權(quán)重3.0)。通常有四種的場(chǎng)景:

場(chǎng)景A:root.busy隊(duì)列applications序占滿隊(duì)列,root.sometimes_busy隊(duì)列中有少量正在運(yùn)行的applications(例如10%,即<memory:80GB,vcores:20>)。很快,大量applications在相對(duì)較短的時(shí)間窗口內(nèi)添加到root.sometimes_busy的隊(duì)列中。所有sometimes_busy隊(duì)列中的新應(yīng)用程序都將處于掛起狀態(tài),并在root.busy隊(duì)列中container結(jié)束時(shí)變?yōu)閍ctive狀態(tài)。如果root.busy隊(duì)列中的任務(wù)相當(dāng)短暫,則root.sometimes_busy隊(duì)列中的應(yīng)用程序?qū)⒉粫?huì)等待很長時(shí)間來分配容器。但是,如果root.busy隊(duì)列中的任務(wù)需要很長時(shí)間才能完成,則root.sometimes_busy隊(duì)列中的新應(yīng)用程序?qū)㈤L時(shí)間處于掛起狀態(tài)。在這兩種情況下,由于root.sometimes_busy隊(duì)列中的應(yīng)用程序處于活動(dòng)狀態(tài),root.busy隊(duì)列中許多正在運(yùn)行的應(yīng)用程序?qū)⑿枰L的時(shí)間才能完成。

場(chǎng)景B:root.busy隊(duì)列和root.sometimes_busy隊(duì)列都已滿或接近滿,都是活動(dòng)和/或掛起的applications。在這種情況下,集群將保持充分利用。每個(gè)隊(duì)列將使用其fair share,root.busy隊(duì)列中的所有應(yīng)用程序的總和使用集群資源的25%,root.sometimes_busy隊(duì)列中的所有應(yīng)用程序的總和使用剩余的75%。

那么,如何避免場(chǎng)景A呢?

一種解決方案是在root.busy隊(duì)列上設(shè)置maxResources。假設(shè)在root.busy隊(duì)列上將maxResources屬性設(shè)置為集群的25%。由于maxResources是一個(gè)硬限制,root.busy隊(duì)列中的應(yīng)用程序?qū)⑹冀K限制在總數(shù)的25%。因此,在可以使用100%集群的情況下,集群利用率實(shí)際上接近35%(root.sometimes_busy隊(duì)列為10%,root.busy隊(duì)列為25%)。

場(chǎng)景A將有顯著的改進(jìn),因?yàn)榧荷嫌锌臻e資源,這些資源只能用于root.sometimes_busy隊(duì)列中的應(yīng)用程序,但平均集群利用率可能較低

更多公平分享定義

  • Steady FairShare:隊(duì)列的理論公平共享值。該值是根據(jù)集群大小和集群中隊(duì)列的權(quán)重計(jì)算的。

  • Instantaneous FairShare:調(diào)度程序?yàn)榧褐械拿總€(gè)隊(duì)列計(jì)算的公平共享值。
    該值在兩個(gè)方面不同于Steady FairShare:
    – 未為空隊(duì)列分配任何資源。
    – 該值等于所有隊(duì)列達(dá)到或超過容量時(shí)的Steady FairShare。

  • Allocation:等于隊(duì)列中所有正在運(yùn)行的應(yīng)用程序使用的資源之和。

展望未來,我們將“Instantaneous FairShare ”簡(jiǎn)稱為“FairShare”

The Case for Preemption

根據(jù)這些新的定義,前面的場(chǎng)景可以表述如下:

情景A

root.sometimes_busy隊(duì)列的Allocations value為<memory:80GB,vcores:20>,F(xiàn)airShare value為<memory:600GB,vcores:150>。

root.busy隊(duì)列的Allocations value為<memory:720GB,vcores:180>,F(xiàn)airShare value為<memory:200GB,vcores:50>。

情景B

兩個(gè)隊(duì)列的Instantaneous FairShare等于其穩(wěn)定公平份額。

在場(chǎng)景A中,您可以看到兩個(gè)隊(duì)列的分配和Steady FairShare之間的不平衡。當(dāng)容器從root.busy隊(duì)列中釋放并分配給root.sometimes_busy的隊(duì)列時(shí),資源將緩慢返回。

通過啟用搶占,公平調(diào)度程序可以殺死繁忙隊(duì)列中的容器,并更快地將它們分配到root.sometimes_busy的隊(duì)列。

Configuring Fair Scheduler for Preemption

要啟用搶占,請(qǐng)?jiān)趛arn-site.xml中設(shè)置此屬性:

<property>yarn.scheduler.fair.preemption</property>
<value>true</value>

然后,在FairScheduler分配文件中,可以通過fairSharePreemptionThresholdfairSharePreemptionTimeout在隊(duì)列上配置搶占,如下例所示。fairSharePreemptionTimeout是隊(duì)列在嘗試搶占容器以從其他隊(duì)列獲取資源之前處于FairSharePreemptionReshold下的秒數(shù)

<allocations>
  <queue name="busy">
    <weight>1.0</weight>
  </queue>
  <queue name="sometimes_busy">
    <weight>3.0</weight>
    <fairSharePreemptionThreshold>0.50</fairSharePreemptionThreshold>
    <fairSharePreemptionTimeout>60</fairSharePreemptionTimeout>
  </queue>

 <queuePlacementPolicy>
    <rule name="specified" />
    <rule name=”reject” />
 </queuePlacementPolicy>
</allocations>

回想一下,root.sometimes_busy隊(duì)列的FairShare是<memory:600GB,vcores:150>。這兩個(gè)新屬性告訴FairScheduler,root.sometimes_busy的隊(duì)列將在開始搶占之前等待60秒。如果在這段時(shí)間內(nèi),F(xiàn)airScheduler沒有收到50%的FairShare資源,F(xiàn)airScheduler可以開始?xì)⑺?code>root.busy隊(duì)列中的容器,并將它們分配到root.sometimes_busy的隊(duì)列中。

需要注意的是:

fairSharePreemptionThreshold的值應(yīng)大于0.0(設(shè)置為0.0類似于關(guān)閉搶占),但不大于1.0(因?yàn)?.0將向需要資源的隊(duì)列返回所有的FairShare)。

此配置中的搶占將殺死root.busy隊(duì)列中的容器,并將它們分配到sometimes_busy隊(duì)列。
反向搶占不會(huì)發(fā)生,因?yàn)樵?code>root.busy隊(duì)列上沒有設(shè)置搶占屬性。

搶占不會(huì)殺死sometimes_busy隊(duì)列中應(yīng)用程序A的容器,并將它們分配給sometimes_busy隊(duì)列中的應(yīng)用程序B。

如果未為給定隊(duì)列或其parent隊(duì)列之一設(shè)置fairSharePreemptionTimeout,并且未設(shè)置defaultFairSharePreemptionTimeout,則即使啟用了搶占,此隊(duì)列也不會(huì)進(jìn)行搶占。

(注意:我們不會(huì)討論隊(duì)列上的minResourcesMinsharePremptionTimeout。目前建議使用FairShare搶占。)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容