bookkeeperOverview.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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>BookKeeper overview</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/zookeeper/">ZooKeeper</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/zookeeper/"><img class="logoImage" alt="ZooKeeper" src="images/zookeeper_small.gif" title="ZooKeeper: distributed coordination"></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/zookeeper/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">ZooKeeper 3.3 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_1.1', 'skin/')" id="menu_1.1Title" class="menutitle">Overview</div>
  105. <div id="menu_1.1" class="menuitemgroup">
  106. <div class="menuitem">
  107. <a href="index.html">Welcome</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="zookeeperOver.html">Overview</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="zookeeperStarted.html">Getting Started</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="releasenotes.html">Release Notes</a>
  117. </div>
  118. </div>
  119. <div onclick="SwitchMenu('menu_1.2', 'skin/')" id="menu_1.2Title" class="menutitle">Developer</div>
  120. <div id="menu_1.2" class="menuitemgroup">
  121. <div class="menuitem">
  122. <a href="api/index.html">API Docs</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="zookeeperProgrammers.html">Programmer's Guide</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="javaExample.html">Java Example</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="zookeeperTutorial.html">Barrier and Queue Tutorial</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="recipes.html">Recipes</a>
  135. </div>
  136. </div>
  137. <div onclick="SwitchMenu('menu_selected_1.3', 'skin/')" id="menu_selected_1.3Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">BookKeeper</div>
  138. <div id="menu_selected_1.3" class="selectedmenuitemgroup" style="display: block;">
  139. <div class="menuitem">
  140. <a href="bookkeeperStarted.html">Getting started</a>
  141. </div>
  142. <div class="menupage">
  143. <div class="menupagetitle">Overview</div>
  144. </div>
  145. <div class="menuitem">
  146. <a href="bookkeeperConfig.html">Setup guide</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="bookkeeperProgrammer.html">Programmer's guide</a>
  150. </div>
  151. </div>
  152. <div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle">Admin &amp; Ops</div>
  153. <div id="menu_1.4" class="menuitemgroup">
  154. <div class="menuitem">
  155. <a href="zookeeperAdmin.html">Administrator's Guide</a>
  156. </div>
  157. <div class="menuitem">
  158. <a href="zookeeperQuotas.html">Quota Guide</a>
  159. </div>
  160. <div class="menuitem">
  161. <a href="zookeeperJMX.html">JMX</a>
  162. </div>
  163. <div class="menuitem">
  164. <a href="zookeeperObservers.html">Observers Guide</a>
  165. </div>
  166. </div>
  167. <div onclick="SwitchMenu('menu_1.5', 'skin/')" id="menu_1.5Title" class="menutitle">Contributor</div>
  168. <div id="menu_1.5" class="menuitemgroup">
  169. <div class="menuitem">
  170. <a href="zookeeperInternals.html">ZooKeeper Internals</a>
  171. </div>
  172. </div>
  173. <div onclick="SwitchMenu('menu_1.6', 'skin/')" id="menu_1.6Title" class="menutitle">Miscellaneous</div>
  174. <div id="menu_1.6" class="menuitemgroup">
  175. <div class="menuitem">
  176. <a href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
  177. </div>
  178. <div class="menuitem">
  179. <a href="http://wiki.apache.org/hadoop/ZooKeeper/FAQ">FAQ</a>
  180. </div>
  181. <div class="menuitem">
  182. <a href="http://hadoop.apache.org/zookeeper/mailing_lists.html">Mailing Lists</a>
  183. </div>
  184. </div>
  185. <div id="credit"></div>
  186. <div id="roundbottom">
  187. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  188. <!--+
  189. |alternative credits
  190. +-->
  191. <div id="credit2"></div>
  192. </div>
  193. <!--+
  194. |end Menu
  195. +-->
  196. <!--+
  197. |start content
  198. +-->
  199. <div id="content">
  200. <div title="Portable Document Format" class="pdflink">
  201. <a class="dida" href="bookkeeperOverview.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  202. PDF</a>
  203. </div>
  204. <h1>BookKeeper overview</h1>
  205. <div id="minitoc-area">
  206. <ul class="minitoc">
  207. <li>
  208. <a href="#bk_Overview">BookKeeper overview</a>
  209. <ul class="minitoc">
  210. <li>
  211. <a href="#bk_basicComponents">Basic elements</a>
  212. </li>
  213. <li>
  214. <a href="#bk_moreDetail">In slightly more detail...</a>
  215. </li>
  216. </ul>
  217. </li>
  218. </ul>
  219. </div>
  220. <a name="N10009"></a><a name="bk_Overview"></a>
  221. <h2 class="h3">BookKeeper overview</h2>
  222. <div class="section">
  223. <p>This document explains basic concepts of BookKeeper. We start by discussing
  224. the basic elements of BookKeeper, and next we discuss how they work together.
  225. </p>
  226. <a name="N10012"></a><a name="bk_basicComponents"></a>
  227. <h3 class="h4">Basic elements</h3>
  228. <p>
  229. BookKeeper uses four basic elements:
  230. </p>
  231. <ul>
  232. <li>
  233. <p>
  234. <strong>Ledger</strong>: A ledger is a sequence of entries, and each entry is a sequence of bytes. Entries are
  235. written sequentially to a ledger and at most once. Consequently, ledgers have an append-only semantics;
  236. </p>
  237. </li>
  238. <li>
  239. <p>
  240. <strong>BookKeeper client</strong>: A client runs along with a BookKeeper application, and it enables applications
  241. to execute operations on ledgers, such as creating a ledger and writing to it;
  242. </p>
  243. </li>
  244. <li>
  245. <p>
  246. <strong>Bookie</strong>: A bookie is a BookKeeper storage server. Bookies store the content of ledgers. For any given
  247. ledger L, we call an <em>ensemble</em> the group of bookies storing the content of L. For performance, we store on
  248. each bookie of an ensemble only a fragment of a ledger. That is, we stripe when writing entries to a ledger such that
  249. each entry is written to sub-group of bookies of the ensemble.
  250. </p>
  251. </li>
  252. <li>
  253. <p>
  254. <strong>Metadata storage service</strong>: BookKeeper requires a metadata storage service to store information related
  255. to ledgers and available bookies. We currently use ZooKeeper for such a task.
  256. </p>
  257. </li>
  258. </ul>
  259. <a name="N10046"></a><a name="bk_moreDetail"></a>
  260. <h3 class="h4">In slightly more detail...</h3>
  261. <p> BookKeeper implements highly available logs, and it has been designed with write-ahead logging in mind. Besides high availability
  262. due to the replicated nature of the service, it provides high throughput due to striping. As we write entries in a subset of bookies of an
  263. ensemble and rotate writes across available quorums, we are able to increase throughput with the number of servers for both reads and writes.
  264. Scalability is a property that is possible to achieve in this case due to the use of quorums. Other replication techniques, such as
  265. state-machine replication, do not enable such a property.
  266. </p>
  267. <p> An application first creates a ledger before writing to bookies through a local BookKeeper client instance. To
  268. create a ledger, an application has to specify which kind of ledger it wants to use: self-verifying or generic. Self-verifying
  269. includes a digest on every entry, which enables a reduction on the degree of replication. Generic ledgers do not store a digest
  270. along with entries at the cost of using more bookies.
  271. </p>
  272. <p> Upon creating a ledger, a BookKeeper clients writes metadata about the ledger to ZooKeeper. A given client first creates
  273. a znode named "L" as a child of "/ledger" with the SEQUENCE flag. ZooKeeper consequently assigns a unique sequence number to the
  274. node, naming the node "/Lx", where x is the sequence number assigned. We use this sequence number as the identifier of the ledger.
  275. This identifier is necessary when opening a ledger. We also store the ensemble composition so that readers know which set of bookies
  276. of access for a given ledger.
  277. </p>
  278. <p>
  279. Each ledger currently has a single writer. This writer has to execute a close ledger operation before any other client can read
  280. from it. If the writer of a ledger does not close a ledger properly because, for example, it has crashed before having the
  281. opportunity of closing the ledger, then the next client that tries to open a ledger executes an procedure to recover it. As closing a ledger
  282. consists essentially of writing the last entry written to a ledger to ZooKeeper, the recovery procedure simply finds the last entry
  283. written correctly and writes it to ZooKeeper in the form of a close znode as a child of "/Lx", where x is the identifier of the ledger.
  284. </p>
  285. <p>
  286. Note that currently this recovery procedure is executed automatically upon trying to open a ledger and no explicit action is necessary.
  287. Although two clients may try to recover a ledger concurrently, only one will succeed, the first one that is able to create the close znode
  288. for the ledger.
  289. </p>
  290. </div>
  291. <p align="right">
  292. <font size="-2"></font>
  293. </p>
  294. </div>
  295. <!--+
  296. |end content
  297. +-->
  298. <div class="clearboth">&nbsp;</div>
  299. </div>
  300. <div id="footer">
  301. <!--+
  302. |start bottomstrip
  303. +-->
  304. <div class="lastmodified">
  305. <script type="text/javascript"><!--
  306. document.write("Last Published: " + document.lastModified);
  307. // --></script>
  308. </div>
  309. <div class="copyright">
  310. Copyright &copy;
  311. 2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  312. </div>
  313. <!--+
  314. |end bottomstrip
  315. +-->
  316. </div>
  317. </body>
  318. </html>