Zend_TimeSync.xml 8.0 KB

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