Zend_TimeSync.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.timesync.introduction">
  4. <title>Introduction</title>
  5. <para>
  6. <classname>Zend_TimeSync</classname> is able to receive internet or network time from a time
  7. server using the <emphasis>NTP</emphasis> or <emphasis>SNTP</emphasis> protocol.
  8. With <classname>Zend_TimeSync</classname>, Zend Framework is able to act independently from
  9. the time settings of the server where it is running.
  10. </para>
  11. <para>
  12. To be independent from the actual time of the server, <classname>Zend_TimeSync</classname>
  13. works with the difference of the real time which is sent through NTP or SNTP and the
  14. internal server's time.
  15. </para>
  16. <note>
  17. <title>Background</title>
  18. <para>
  19. <classname>Zend_TimeSync</classname> is not able to change the server's time, but it
  20. will return a <link linkend="zend.date.introduction">Zend_Date</link> instance from
  21. which the difference from the server's time can be worked with.
  22. </para>
  23. </note>
  24. <sect2 id="zend.timesync.introduction.why">
  25. <title>Why Zend_TimeSync ?</title>
  26. <para>
  27. So why would someone use <classname>Zend_TimeSync</classname> ?
  28. </para>
  29. <para>
  30. Normally every server within a multi-server farm will have a service running which
  31. synchronizes its own time with a time server. So within a standard environment it should
  32. not be necessary to use <classname>Zend_TimeSync</classname>. But it can become handy if
  33. there is no service available and if you don't have the right to install such a service.
  34. </para>
  35. <para>
  36. Here are some example use cases, for which <classname>Zend_TimeSync</classname> is
  37. perfect suited:
  38. </para>
  39. <itemizedlist mark='opencircle'>
  40. <listitem>
  41. <para>
  42. <emphasis>Server without time service</emphasis>
  43. </para>
  44. <para>
  45. If your application is running on a server and this server does not have any
  46. time service running, it may make sense to use
  47. <classname>Zend_TimeSync</classname> in your application.
  48. </para>
  49. </listitem>
  50. <listitem>
  51. <para>
  52. <emphasis>Separate database server</emphasis>
  53. </para>
  54. <para>
  55. If your database is running on a different server and this server is not
  56. connected with <emphasis>NTP</emphasis> or <emphasis>SNTP</emphasis>
  57. to the application server, you might have problems using storing and using time
  58. stamp data.
  59. </para>
  60. </listitem>
  61. <listitem>
  62. <para>
  63. <emphasis>Multiple servers</emphasis>
  64. </para>
  65. <para>
  66. If your application is running on more than one server and these servers' time
  67. bases are not syncronized, you can expect problems within your application when
  68. part of the application is coming from one server and another part from another
  69. server.
  70. </para>
  71. </listitem>
  72. <listitem>
  73. <para>
  74. <emphasis>Batch processing</emphasis>
  75. </para>
  76. <para>
  77. If you want to work with a time service within a batch file or within a
  78. command line application, <classname>Zend_TimeSync</classname> may be of use.
  79. </para>
  80. </listitem>
  81. </itemizedlist>
  82. <para>
  83. <classname>Zend_TimeSync</classname> may provide a good solution in all of these cases
  84. and can be used if you are unable to run any services on your server.
  85. </para>
  86. </sect2>
  87. <sect2 id="zend.timesync.introduction.ntp">
  88. <title>What is NTP ?</title>
  89. <para>
  90. The Network Time Protocol (<emphasis>NTP</emphasis>) is a protocol
  91. for synchronizing multiple systems' clocks over packet-switched, variable-latency data
  92. networks. NTP uses UDP port 123 as its transport layer. See the <ulink
  93. url="http://en.wikipedia.org/wiki/Network_Time_Protocol">wikipedia article</ulink>
  94. for details about this protocol.
  95. </para>
  96. </sect2>
  97. <sect2 id="zend.timesync.introduction.sntp">
  98. <title>What is SNTP?</title>
  99. <para>
  100. The Simple Network Time Protocol (<emphasis>SNTP</emphasis>) is a
  101. protocol synchronizing multiple systems' clocks over packet-switched, variable-latency
  102. data networks. SNTP uses UDP port 37 as its transport layer. It is closely related to
  103. the Network Time Protocol, but simpler.
  104. </para>
  105. </sect2>
  106. <sect2 id="zend.timesync.introduction.problematic">
  107. <title>Problematic usage</title>
  108. <para>
  109. Be warned that when you are using <classname>Zend_TimeSync</classname> you will have to
  110. think about some details related to the structure of time sync and the internet itself.
  111. Correct usage and best practices will be described here. Read carefully before you begin
  112. using <classname>Zend_TimeSync</classname>.
  113. </para>
  114. </sect2>
  115. <sect2 id="zend.timesync.introduction.decision">
  116. <title>Decide which server to use</title>
  117. <para>
  118. You should select the time server that you want to use very carefully according to the
  119. following criteria:
  120. </para>
  121. <itemizedlist mark='opencircle'>
  122. <listitem>
  123. <para>
  124. Distance
  125. </para>
  126. <para>
  127. The distance from your application server to the time server. If your server is
  128. in Europe, it would make little sense to select a time server in Tahiti. Always
  129. select a server which is not far away. This reduces the request time and overall
  130. network load.
  131. </para>
  132. </listitem>
  133. <listitem>
  134. <para>
  135. Speed
  136. </para>
  137. <para>
  138. How long it takes to receive the request is also relevant. Try different servers
  139. to get the best result. If you are requesting a server which is never
  140. accessible, you will always have an unnecessary delay.
  141. </para>
  142. </listitem>
  143. <listitem>
  144. <para>
  145. Splitting
  146. </para>
  147. <para>
  148. Do not always use the same server. All time servers will lock out requests from
  149. servers that are flooding the server. If your application requires heavy use of
  150. time servers, you should consider one of the pools described later.
  151. </para>
  152. </listitem>
  153. </itemizedlist>
  154. <para>
  155. So where can you find a time server? Generally you can use any timeserver you can
  156. connect to. This can be a time server within your LAN or any public time server you have
  157. access to. If you decide to use a public time server, you should consider using a server
  158. pool. Server pools are public addresses from which you will get a random, pooled time
  159. server by requesting the time. This way you will not have to split your requests. There
  160. are public server pools available for many regions which you may use to avoid problems
  161. mentioned above.
  162. </para>
  163. <para>
  164. See <ulink url="http://www.pool.ntp.org">pool.ntp.org</ulink> to find your nearest
  165. server pool. For example, if your server is located within Germany you can connect to
  166. <emphasis>0.europe.pool.ntp.org</emphasis>.
  167. </para>
  168. </sect2>
  169. </sect1>