dhcp-perf-guide.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
  4. <!ENTITY mdash "&#x2014;" >
  5. <!ENTITY % version SYSTEM "version.ent">
  6. %version;
  7. ]>
  8. <!--
  9. - Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  10. -
  11. - Permission to use, copy, modify, and/or distribute this software for any
  12. - purpose with or without fee is hereby granted, provided that the above
  13. - copyright notice and this permission notice appear in all copies.
  14. -
  15. - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  16. - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  17. - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  18. - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  19. - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  20. - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21. - PERFORMANCE OF THIS SOFTWARE.
  22. -->
  23. <book>
  24. <?xml-stylesheet href="bind10-guide.css" type="text/css"?>
  25. <bookinfo>
  26. <title>DHCP Performance Guide</title>
  27. <subtitle>Various aspects of DHCP Performance in BIND 10</subtitle>
  28. <copyright>
  29. <year>2012</year><holder>Internet Systems Consortium, Inc.</holder>
  30. </copyright>
  31. <author>
  32. <firstname>Tomasz</firstname>
  33. <surname>Mrugalski</surname>
  34. </author>
  35. <abstract>
  36. <para>BIND 10 is a framework that features Domain Name System
  37. (DNS) suite and Dynamic Host Configuration Protocol (DHCP)
  38. servers with development managed by Internet Systems Consortium (ISC).
  39. This document describes various aspects of DHCP performance,
  40. measurements and tuning. It covers BIND 10 DHCP (codename Kea),
  41. existing ISC DHCP4 software, perfdhcp (a DHCP performance
  42. measurement tool) and other related topics.</para>
  43. </abstract>
  44. <releaseinfo>This is a companion document for BIND 10 version
  45. &__VERSION__;.</releaseinfo>
  46. </bookinfo>
  47. <preface>
  48. <title>Preface</title>
  49. <section id="acknowledgements">
  50. <title>Acknowledgements</title>
  51. <para>ISC would like to acknowledge generous support for
  52. BIND 10 development of DHCPv4 and DHCPv6 components provided
  53. by <ulink url="http://www.comcast.com/">Comcast</ulink>.</para>
  54. </section>
  55. </preface>
  56. <chapter id="intro">
  57. <title>Introduction</title>
  58. <para>
  59. This document is in its early stages of development. It is
  60. expected to grow significantly in a near future. It will
  61. cover topics like database backend perfomance measurements,
  62. pros an cons of various optimization techniques and
  63. tools.
  64. </para>
  65. </chapter>
  66. <chapter id="dhcp4">
  67. <title>ISC DHCP 4.x</title>
  68. <para>
  69. TODO: Write something about ISC DHCP4 here.
  70. </para>
  71. </chapter>
  72. <chapter id="kea">
  73. <title>Kea</title>
  74. <para>
  75. </para>
  76. <section>
  77. <title>Backend performance evaluation</title>
  78. <para>
  79. Kea will support several different database backends, using
  80. both popular databases (like MySQL or SQLite) and
  81. custom-developed solutions (like in-memory database). BIND 10
  82. source code features set of performance microbenchmarks.
  83. These are small tools written in C/C++ that simulate expected
  84. DHCP server behaviour and evaluate the performance of
  85. considered databases.
  86. </para>
  87. <para>
  88. Those benchmarks are stored in tests/tools/dhcp-ubench
  89. directory. This directory contains simplified prototypes for
  90. various DB back-ends that are planned or considered as a
  91. backend engine for BIND10 DHCP. Athough trivial now, they are
  92. expected to evolve into useful tools that will allow users to
  93. measure performance in their specific environment.
  94. </para>
  95. <para>
  96. Currently the following benchmarks are implemented:
  97. <itemizedlist>
  98. <listitem><para>in memory+flat file</para></listitem>
  99. <listitem><para>SQLite</para></listitem>
  100. <listitem><para>MySQL</para></listitem>
  101. </itemizedlist>
  102. </para>
  103. <para>
  104. As they require additional (sometimes heavy) dependencies, they are not
  105. built by default. Actually, their build system is completely separated.
  106. It will be eventually merged with the main BIND10 makefile system, but
  107. that is a low priority for now.
  108. </para>
  109. <para>
  110. All benchmarks will follow the same pattern:
  111. <orderedlist>
  112. <listitem><para>prepare operation (connect to a database, create a file etc.)</para></listitem>
  113. <listitem><para>Measure timestamp 0</para></listitem>
  114. <listitem><para>Commit new lease4 (repeated X times)</para></listitem>
  115. <listitem><para>Measure timestamp 1</para></listitem>
  116. <listitem><para>Search for random lease4 (repeated X times)</para></listitem>
  117. <listitem><para>Measure timestamp 2</para></listitem>
  118. <listitem><para>Update existing lease4 (repeated X times)</para></listitem>
  119. <listitem><para>Measure timestamp 3</para></listitem>
  120. <listitem><para>Delete existing lease4 (repeated X times)</para></listitem>
  121. <listitem><para>Measure timestamp 4</para></listitem>
  122. <listitem><para>Print out statistics, based on X and measured timestamps.</para></listitem>
  123. </orderedlist>
  124. Although this approach does not attempt to simulate actual DHCP server
  125. operation that has mix of all steps intervening, it answers the
  126. questions about basic database strenghts and weak points. In particular
  127. it can show what is the impact of specific DB optimizations, like
  128. changing engine, optimizing for writes/reads etc.
  129. </para>
  130. <para>
  131. The framework attempts to do the same amount of operations for every
  132. backend thus allowing fair complarison between them.
  133. </para>
  134. </section>
  135. <section id="mysql-backend">
  136. <title>MySQL backend</title>
  137. <para>MySQL backend requires MySQL client development libraries. It uses
  138. mysql_config tool (that works similar to pkg-config) to discover required
  139. compilation and linking options. To install required packages on Ubuntu,
  140. use the following command:
  141. <screen>$ <userinput>sudo apt-get install mysql-client mysql-server libmysqlclient-dev</userinput></screen>
  142. Make sure that MySQL server is running. Make sure that you have your setup
  143. configured so there is a user that is able to modify used database.</para>
  144. <para>Before running tests, you need to initialize your database. You can
  145. use mysql.schema script for that purpose. WARNING: It will drop existing
  146. Kea database. Do not run this on your production server. Assuming your
  147. MySQL user is kea, you can initialize your test database by:
  148. <screen>$ <userinput>mysql -u kea -p &lt; mysql.schema</userinput></screen>
  149. </para>
  150. <para>After database is initialized, you are ready to run the test:
  151. <screen>$ <userinput>./mysql_ubench</userinput></screen>
  152. or
  153. <screen>$ <userinput>./mysql_ubench &gt; results->mysql.txt</userinput></screen>
  154. Redirecting output to a file is important, because for each operation
  155. there is a single character printed to show progress. If you have a slow
  156. terminal, this may considerably affect test perfromance. On the other hand,
  157. printing something after each operation is required, as poor DB setting
  158. may slow down operations to around 20 per second. Observant user is expected
  159. to note that initial dots are printed too slowly and abort the test.</para>
  160. <para>Currently all parameters are hardcoded. To modify them, one needs to
  161. modify source code and recompile. Fortunately, that is quite easy.
  162. To modify MySQL parameters, see main() method at the end of mysql_ubench.c
  163. file. That is the plase where one can modify MySQL connection
  164. parameters (MySQL server hostname, user and password and database name).</para>
  165. <section>
  166. <title>MySQL tweaks</title>
  167. <para>To reconfigure mysql_ubench parameters, a modification to the source
  168. code and recompilation is required. All parameters are listed in main()
  169. function in mysql_ubench.cc file, near the end of the file. Currently supported
  170. parameter are (default values specified in brackets):
  171. <orderedlist>
  172. <listitem><para>hostname - name of the host to connect to ("localhost")</para></listitem>
  173. <listitem><para>user - MySQL username ("root")</para></listitem>
  174. <listitem><para>passwd - MySQL password ("secret")</para></listitem>
  175. <listitem><para>dbname - MySQL database name ("kea")</para></listitem>
  176. <listitem><para>num - number of iterations (100)</para></listitem>
  177. <listitem><para>sync - should the operations be performend in synchronous (true)
  178. or asynchronous (false) manner (true)</para></listitem>
  179. <listitem><para>verbose - should the test print out progress? (true)</para></listitem>
  180. </orderedlist>
  181. </para>
  182. <para>One parameter that has huge impact on performance is a a backend engine.
  183. You can get a list of engines of your MySQL implementation by using
  184. <screen>&gt; <userinput>show engines;</userinput></screen>
  185. in your mysql client. Two notable engines are MyISAM and InnoDB. mysql_ubench will
  186. use MyISAM for synchronous mode and InnoDB for asynchronous.</para>
  187. </section>
  188. </section>
  189. <section id="sqlite-ubench">
  190. <title>SQLite-ubench</title>
  191. <para>SQLite backend requires both sqlite3 development and run-time package. Their
  192. names may vary from system to system, but on Ubuntu 12.04 they are called
  193. sqlite3 libsqlite3-dev. To install them, use the following command:
  194. <screen>&gt; <userinput>sudo apt-get install sqlite3 libsqlite3-dev</userinput></screen>
  195. Before running the test the database has to be created. Use the following command for that:
  196. <screen>&gt; <userinput>cat sqlite.schema | sqlite3 sqlite.db</userinput></screen>
  197. A new database called sqlite.db will be created. That is the default name used
  198. by sqlite_ubench test. If you prefer other name, make sure you update
  199. sqlite_ubench.cc accordingly.</para>
  200. <para>Once the database is created, you can run tests:
  201. <screen>&gt; <userinput>./sqlite_ubench</userinput></screen>
  202. or
  203. <screen>&gt; <userinput>./sqlite_ubench > results-sqlite.txt</userinput></screen>
  204. </para>
  205. <section id="sqlite-tweaks">
  206. <title>SQLite tweaks</title>
  207. <para>To reconfigure sqlite_ubench parameters, a modification to the source
  208. code and recompilation is required. All parameters are listed in main()
  209. function in sqlite_ubench.cc file, near the end of the file. Currently supported
  210. parameter are (default values specified in brackets):
  211. <orderedlist>
  212. <listitem><para>filename - name of the database file ("sqlite.db")</para></listitem>
  213. <listitem><para>num - number of iterations (100)</para></listitem>
  214. <listitem><para>sync - should the operations be performend in synchronous (true)
  215. or asynchronous (false) manner (true)</para></listitem>
  216. <listitem><para>verbose - should the test print out progress? (true)</para></listitem>
  217. </orderedlist>
  218. </para>
  219. <para>SQLite can run in asynchronous or synchronous mode. This
  220. mode can be controlled by using sync parameter. It is set
  221. using (PRAGMA synchronous = ON or OFF).</para>
  222. <para>Another tweakable feature is journal mode. It can be
  223. turned to several modes of operation. Its value can be
  224. modified in SQLite_uBenchmark::connect(). See
  225. http://www.sqlite.org/pragma.html#pragma_journal_mode for
  226. detailed explanantion.</para>
  227. </section>
  228. </section>
  229. <section id="memfile-ubench">
  230. <title>memfile-ubench</title>
  231. <para> TODO </para>
  232. <section id="memfile-tweaks">
  233. <title>SQLite tweaks</title>
  234. <para> ... </para>
  235. </section>
  236. </section>
  237. </chapter>
  238. <chapter id="perfdhcp">
  239. <title>perfdhcp</title>
  240. <para>
  241. TODO: Write something about perfdhcp here.
  242. </para>
  243. </chapter>
  244. </book>