capacity_scheduler.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta content="Apache Forrest" name="Generator">
  6. <meta name="Forrest-version" content="0.8">
  7. <meta name="Forrest-skin-name" content="pelt">
  8. <title>Capacity Scheduler</title>
  9. <link type="text/css" href="skin/basic.css" rel="stylesheet">
  10. <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
  11. <link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
  12. <link type="text/css" href="skin/profile.css" rel="stylesheet">
  13. <script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
  14. <link rel="shortcut icon" href="images/favicon.ico">
  15. </head>
  16. <body onload="init()">
  17. <script type="text/javascript">ndeSetTextSize();</script>
  18. <div id="top">
  19. <!--+
  20. |breadtrail
  21. +-->
  22. <div class="breadtrail">
  23. <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://hadoop.apache.org/">Hadoop</a> &gt; <a href="http://hadoop.apache.org/core/">Core</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  24. </div>
  25. <!--+
  26. |header
  27. +-->
  28. <div class="header">
  29. <!--+
  30. |start group logo
  31. +-->
  32. <div class="grouplogo">
  33. <a href="http://hadoop.apache.org/"><img class="logoImage" alt="Hadoop" src="images/hadoop-logo.jpg" title="Apache Hadoop"></a>
  34. </div>
  35. <!--+
  36. |end group logo
  37. +-->
  38. <!--+
  39. |start Project Logo
  40. +-->
  41. <div class="projectlogo">
  42. <a href="http://hadoop.apache.org/core/"><img class="logoImage" alt="Hadoop" src="images/core-logo.gif" title="Scalable Computing Platform"></a>
  43. </div>
  44. <!--+
  45. |end Project Logo
  46. +-->
  47. <!--+
  48. |start Search
  49. +-->
  50. <div class="searchbox">
  51. <form action="http://www.google.com/search" method="get" class="roundtopsmall">
  52. <input value="hadoop.apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google">&nbsp;
  53. <input name="Search" value="Search" type="submit">
  54. </form>
  55. </div>
  56. <!--+
  57. |end search
  58. +-->
  59. <!--+
  60. |start Tabs
  61. +-->
  62. <ul id="tabs">
  63. <li>
  64. <a class="unselected" href="http://hadoop.apache.org/core/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="http://wiki.apache.org/hadoop">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">Hadoop 0.19 Documentation</a>
  71. </li>
  72. </ul>
  73. <!--+
  74. |end Tabs
  75. +-->
  76. </div>
  77. </div>
  78. <div id="main">
  79. <div id="publishedStrip">
  80. <!--+
  81. |start Subtabs
  82. +-->
  83. <div id="level2tabs"></div>
  84. <!--+
  85. |end Endtabs
  86. +-->
  87. <script type="text/javascript"><!--
  88. document.write("Last Published: " + document.lastModified);
  89. // --></script>
  90. </div>
  91. <!--+
  92. |breadtrail
  93. +-->
  94. <div class="breadtrail">
  95. &nbsp;
  96. </div>
  97. <!--+
  98. |start Menu, mainarea
  99. +-->
  100. <!--+
  101. |start Menu
  102. +-->
  103. <div id="menu">
  104. <div onclick="SwitchMenu('menu_selected_1.1', 'skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Documentation</div>
  105. <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
  106. <div class="menuitem">
  107. <a href="index.html">Overview</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="quickstart.html">Quickstart</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="cluster_setup.html">Cluster Setup</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="hdfs_design.html">HDFS Architecture</a>
  117. </div>
  118. <div class="menuitem">
  119. <a href="hdfs_user_guide.html">HDFS User Guide</a>
  120. </div>
  121. <div class="menuitem">
  122. <a href="hdfs_permissions_guide.html">HDFS Permissions Guide</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="hdfs_quota_admin_guide.html">HDFS Quotas Administrator Guide</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="commands_manual.html">Commands Manual</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="hdfs_shell.html">FS Shell Guide</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="SLG_user_guide.html">Synthetic Load Generator User Guide</a>
  135. </div>
  136. <div class="menuitem">
  137. <a href="distcp.html">DistCp Guide</a>
  138. </div>
  139. <div class="menuitem">
  140. <a href="mapred_tutorial.html">Map-Reduce Tutorial</a>
  141. </div>
  142. <div class="menuitem">
  143. <a href="native_libraries.html">Native Hadoop Libraries</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="streaming.html">Streaming</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="hadoop_archives.html">Hadoop Archives</a>
  150. </div>
  151. <div class="menuitem">
  152. <a href="hod.html">Hadoop On Demand</a>
  153. </div>
  154. <div class="menupage">
  155. <div class="menupagetitle">Capacity Scheduler</div>
  156. </div>
  157. <div class="menuitem">
  158. <a href="api/index.html">API Docs</a>
  159. </div>
  160. <div class="menuitem">
  161. <a href="jdiff/changes.html">API Changes</a>
  162. </div>
  163. <div class="menuitem">
  164. <a href="http://wiki.apache.org/hadoop/">Wiki</a>
  165. </div>
  166. <div class="menuitem">
  167. <a href="http://wiki.apache.org/hadoop/FAQ">FAQ</a>
  168. </div>
  169. <div class="menuitem">
  170. <a href="http://hadoop.apache.org/core/mailing_lists.html">Mailing Lists</a>
  171. </div>
  172. <div class="menuitem">
  173. <a href="releasenotes.html">Release Notes</a>
  174. </div>
  175. <div class="menuitem">
  176. <a href="changes.html">All Changes</a>
  177. </div>
  178. </div>
  179. <div id="credit"></div>
  180. <div id="roundbottom">
  181. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  182. <!--+
  183. |alternative credits
  184. +-->
  185. <div id="credit2"></div>
  186. </div>
  187. <!--+
  188. |end Menu
  189. +-->
  190. <!--+
  191. |start content
  192. +-->
  193. <div id="content">
  194. <div title="Portable Document Format" class="pdflink">
  195. <a class="dida" href="capacity_scheduler.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  196. PDF</a>
  197. </div>
  198. <h1>Capacity Scheduler</h1>
  199. <div id="minitoc-area">
  200. <ul class="minitoc">
  201. <li>
  202. <a href="#Purpose">Purpose</a>
  203. </li>
  204. <li>
  205. <a href="#Features">Features</a>
  206. </li>
  207. <li>
  208. <a href="#Picking+a+task+to+run">Picking a task to run</a>
  209. </li>
  210. <li>
  211. <a href="#Reclaiming+capacity">Reclaiming capacity</a>
  212. </li>
  213. <li>
  214. <a href="#Installation">Installation</a>
  215. </li>
  216. <li>
  217. <a href="#Configuration">Configuration</a>
  218. <ul class="minitoc">
  219. <li>
  220. <a href="#Using+the+capacity+scheduler">Using the capacity scheduler</a>
  221. </li>
  222. <li>
  223. <a href="#Setting+up+queues">Setting up queues</a>
  224. </li>
  225. <li>
  226. <a href="#Configuring+properties+for+queues">Configuring properties for queues</a>
  227. </li>
  228. <li>
  229. <a href="#Reviewing+the+configuration+of+the+capacity+scheduler">Reviewing the configuration of the capacity scheduler</a>
  230. </li>
  231. </ul>
  232. </li>
  233. </ul>
  234. </div>
  235. <a name="N1000D"></a><a name="Purpose"></a>
  236. <h2 class="h3">Purpose</h2>
  237. <div class="section">
  238. <p>This document describes the Capacity Scheduler, a pluggable Map/Reduce scheduler for Hadoop which provides a way to share large clusters.</p>
  239. </div>
  240. <a name="N10017"></a><a name="Features"></a>
  241. <h2 class="h3">Features</h2>
  242. <div class="section">
  243. <p>The Capacity Scheduler supports the following features:</p>
  244. <ul>
  245. <li>
  246. Support for multiple queues, where a job is submitted to a queue.
  247. </li>
  248. <li>
  249. Queues are guaranteed a fraction of the capacity of the grid (their
  250. 'guaranteed capacity') in the sense that a certain capacity of
  251. resources will be at their disposal. All jobs submitted to the a
  252. queue will have access to the capacity guaranteed to the queue.
  253. </li>
  254. <li>
  255. Free resources can be allocated to any queue beyond its guaranteed
  256. capacity. These excess allocated resources can be reclaimed and made
  257. available to another queue in order to meet its capacity guarantee.
  258. </li>
  259. <li>
  260. The scheduler guarantees that excess resources taken from a queue
  261. will be restored to it within N minutes of its need for them.
  262. </li>
  263. <li>
  264. Queues optionally support job priorities (disabled by default).
  265. </li>
  266. <li>
  267. Within a queue, jobs with higher priority will have access to the
  268. queue's resources before jobs with lower priority. However, once a
  269. job is running, it will not be preempted for a higher priority job.
  270. </li>
  271. <li>
  272. In order to prevent one or more users from monopolizing its
  273. resources, each queue enforces a limit on the percentage of
  274. resources allocated to a user at any given time, if there is
  275. competition for them.
  276. </li>
  277. <li>
  278. Support for memory-intensive jobs, wherein a job can optionally
  279. specify higher memory-requirements than the default, and the tasks
  280. of the job will only be run on TaskTrackers that have enough memory
  281. to spare.
  282. </li>
  283. </ul>
  284. </div>
  285. <a name="N1003C"></a><a name="Picking+a+task+to+run"></a>
  286. <h2 class="h3">Picking a task to run</h2>
  287. <div class="section">
  288. <p>Note that many of these steps can be, and will be, enhanced over time
  289. to provide better algorithms.</p>
  290. <p>Whenever a TaskTracker is free, the Capacity Scheduler first picks a
  291. queue that needs to reclaim any resources the earliest (this is a queue
  292. whose resources were temporarily being used by some other queue and now
  293. needs access to those resources). If no such queue is found, it then picks
  294. a queue which has most free space (whose ratio of # of running slots to
  295. guaranteed capacity is the lowest).</p>
  296. <p>Once a queue is selected, the scheduler picks a job in the queue. Jobs
  297. are sorted based on when they're submitted and their priorities (if the
  298. queue supports priorities). Jobs are considered in order, and a job is
  299. selected if its user is within the user-quota for the queue, i.e., the
  300. user is not already using queue resources above his/her limit. The
  301. scheduler also makes sure that there is enough free memory in the
  302. TaskTracker to tun the job's task, in case the job has special memory
  303. requirements.</p>
  304. <p>Once a job is selected, the scheduler picks a task to run. This logic
  305. to pick a task remains unchanged from earlier versions.</p>
  306. </div>
  307. <a name="N1004F"></a><a name="Reclaiming+capacity"></a>
  308. <h2 class="h3">Reclaiming capacity</h2>
  309. <div class="section">
  310. <p>Periodically, the scheduler determines:</p>
  311. <ul>
  312. <li>
  313. if a queue needs to reclaim capacity. This happens when a queue has
  314. at least one task pending and part of its guaranteed capacity is
  315. being used by some other queue. If this happens, the scheduler notes
  316. the amount of resources it needs to reclaim for this queue within a
  317. specified period of time (the reclaim time).
  318. </li>
  319. <li>
  320. if a queue has not received all the resources it needed to reclaim,
  321. and its reclaim time is about to expire. In this case, the scheduler
  322. needs to kill tasks from queues running over capacity. This it does
  323. by killing the tasks that started the latest.
  324. </li>
  325. </ul>
  326. </div>
  327. <a name="N10062"></a><a name="Installation"></a>
  328. <h2 class="h3">Installation</h2>
  329. <div class="section">
  330. <p>The capacity scheduler is available as a JAR file in the Hadoop
  331. tarball under the <em>contrib/capacity-scheduler</em> directory. The name of
  332. the JAR file would be on the lines of hadoop-*-capacity-scheduler.jar.</p>
  333. <p>You can also build the scheduler from source by executing
  334. <em>ant package</em>, in which case it would be available under
  335. <em>build/contrib/capacity-scheduler</em>.</p>
  336. <p>To run the capacity scheduler in your Hadoop installation, you need
  337. to put it on the <em>CLASSPATH</em>. The easiest way is to copy the
  338. <span class="codefrag">hadoop-*-capacity-scheduler.jar</span> from
  339. to <span class="codefrag">HADOOP_HOME/lib</span>. Alternatively, you can modify
  340. <em>HADOOP_CLASSPATH</em> to include this jar, in
  341. <span class="codefrag">conf/hadoop-env.sh</span>.</p>
  342. </div>
  343. <a name="N1008A"></a><a name="Configuration"></a>
  344. <h2 class="h3">Configuration</h2>
  345. <div class="section">
  346. <a name="N10090"></a><a name="Using+the+capacity+scheduler"></a>
  347. <h3 class="h4">Using the capacity scheduler</h3>
  348. <p>
  349. To make the Hadoop framework use the capacity scheduler, set up
  350. the following property in the site configuration:</p>
  351. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  352. <tr>
  353. <td colspan="1" rowspan="1">Property</td>
  354. <td colspan="1" rowspan="1">Value</td>
  355. </tr>
  356. <tr>
  357. <td colspan="1" rowspan="1">mapred.jobtracker.taskScheduler</td>
  358. <td colspan="1" rowspan="1">org.apache.hadoop.mapred.CapacityTaskScheduler</td>
  359. </tr>
  360. </table>
  361. <a name="N100B7"></a><a name="Setting+up+queues"></a>
  362. <h3 class="h4">Setting up queues</h3>
  363. <p>
  364. You can define multiple queues to which users can submit jobs with
  365. the capacity scheduler. To define multiple queues, you should edit
  366. the site configuration for Hadoop and modify the
  367. <em>mapred.queue.names</em> property.
  368. </p>
  369. <p>
  370. You can also configure ACLs for controlling which users or groups
  371. have access to the queues.
  372. </p>
  373. <p>
  374. For more details, refer to
  375. <a href="cluster_setup.html#Configuring+the+Hadoop+Daemons">Cluster
  376. Setup</a> documentation.
  377. </p>
  378. <a name="N100CE"></a><a name="Configuring+properties+for+queues"></a>
  379. <h3 class="h4">Configuring properties for queues</h3>
  380. <p>The capacity scheduler can be configured with several properties
  381. for each queue that control the behavior of the scheduler. This
  382. configuration is in the <em>conf/capacity-scheduler.xml</em>. By
  383. default, the configuration is set up for one queue, named
  384. <em>default</em>.</p>
  385. <p>To specify a property for a queue that is defined in the site
  386. configuration, you should use the property name as
  387. <em>mapred.capacity-scheduler.queue.&lt;queue-name&gt;.&lt;property-name&gt;</em>.
  388. </p>
  389. <p>For example, to define the property <em>guaranteed-capacity</em>
  390. for queue named <em>research</em>, you should specify the property
  391. name as
  392. <em>mapred.capacity-scheduler.queue.research.guaranteed-capacity</em>.
  393. </p>
  394. <p>The properties defined for queues and their descriptions are
  395. listed in the table below:</p>
  396. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  397. <tr>
  398. <th colspan="1" rowspan="1">Name</th><th colspan="1" rowspan="1">Description</th>
  399. </tr>
  400. <tr>
  401. <td colspan="1" rowspan="1">mapred.capacity-scheduler.queue.&lt;queue-name&gt;.guaranteed-capacity</td>
  402. <td colspan="1" rowspan="1">Percentage of the number of slots in the cluster that are
  403. guaranteed to be available for jobs in this queue.
  404. The sum of guaranteed capacities for all queues should be less
  405. than or equal 100.</td>
  406. </tr>
  407. <tr>
  408. <td colspan="1" rowspan="1">mapred.capacity-scheduler.queue.&lt;queue-name&gt;.reclaim-time-limit</td>
  409. <td colspan="1" rowspan="1">The amount of time, in seconds, before which resources
  410. distributed to other queues will be reclaimed.</td>
  411. </tr>
  412. <tr>
  413. <td colspan="1" rowspan="1">mapred.capacity-scheduler.queue.&lt;queue-name&gt;.supports-priority</td>
  414. <td colspan="1" rowspan="1">If true, priorities of jobs will be taken into account in scheduling
  415. decisions.</td>
  416. </tr>
  417. <tr>
  418. <td colspan="1" rowspan="1">mapred.capacity-scheduler.queue.&lt;queue-name&gt;.minimum-user-limit-percent</td>
  419. <td colspan="1" rowspan="1">Each queue enforces a limit on the percentage of resources
  420. allocated to a user at any given time, if there is competition
  421. for them. This user limit can vary between a minimum and maximum
  422. value. The former depends on the number of users who have submitted
  423. jobs, and the latter is set to this property value. For example,
  424. suppose the value of this property is 25. If two users have
  425. submitted jobs to a queue, no single user can use more than 50%
  426. of the queue resources. If a third user submits a job, no single
  427. user can use more than 33% of the queue resources. With 4 or more
  428. users, no user can use more than 25% of the queue's resources. A
  429. value of 100 implies no user limits are imposed.</td>
  430. </tr>
  431. </table>
  432. <a name="N10130"></a><a name="Reviewing+the+configuration+of+the+capacity+scheduler"></a>
  433. <h3 class="h4">Reviewing the configuration of the capacity scheduler</h3>
  434. <p>
  435. Once the installation and configuration is completed, you can review
  436. it after starting the Map/Reduce cluster from the admin UI.
  437. </p>
  438. <ul>
  439. <li>Start the Map/Reduce cluster as usual.</li>
  440. <li>Open the JobTracker web UI.</li>
  441. <li>The queues you have configured should be listed under the <em>Scheduling
  442. Information</em> section of the page.</li>
  443. <li>The properties for the queues should be visible in the <em>Scheduling
  444. Information</em> column against each queue.</li>
  445. </ul>
  446. </div>
  447. </div>
  448. <!--+
  449. |end content
  450. +-->
  451. <div class="clearboth">&nbsp;</div>
  452. </div>
  453. <div id="footer">
  454. <!--+
  455. |start bottomstrip
  456. +-->
  457. <div class="lastmodified">
  458. <script type="text/javascript"><!--
  459. document.write("Last Published: " + document.lastModified);
  460. // --></script>
  461. </div>
  462. <div class="copyright">
  463. Copyright &copy;
  464. 2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  465. </div>
  466. <!--+
  467. |end bottomstrip
  468. +-->
  469. </div>
  470. </body>
  471. </html>