1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.timesync.introduction">
4 <title>Introduction</title>
7 <classname>Zend_TimeSync</classname> is able to receive internet or network time from a time
8 server using the <emphasis>NTP</emphasis> or <emphasis>SNTP</emphasis> protocol.
9 With <classname>Zend_TimeSync</classname>, Zend Framework is able to act independently from
10 the time settings of the server where it is running.
14 To be independent from the actual time of the server, <classname>Zend_TimeSync</classname>
15 works with the difference of the real time which is sent through NTP or SNTP and the
16 internal server's time.
20 <title>Background</title>
23 <classname>Zend_TimeSync</classname> is not able to change the server's time, but it
24 will return a <link linkend="zend.date.introduction">Zend_Date</link> instance from
25 which the difference from the server's time can be worked with.
29 <sect2 id="zend.timesync.introduction.why">
30 <title>Why Zend_TimeSync ?</title>
33 So why would someone use <classname>Zend_TimeSync</classname> ?
37 Normally every server within a multi-server farm will have a service running which
38 synchronizes its own time with a time server. So within a standard environment it should
39 not be necessary to use <classname>Zend_TimeSync</classname>. But it can become handy if
40 there is no service available and if you don't have the right to install such a service.
44 Here are some example use cases, for which <classname>Zend_TimeSync</classname> is
48 <itemizedlist mark='opencircle'>
51 <emphasis>Server without time service</emphasis>
55 If your application is running on a server and this server does not have any
56 time service running, it may make sense to use
57 <classname>Zend_TimeSync</classname> in your application.
63 <emphasis>Separate database server</emphasis>
67 If your database is running on a different server and this server is not
68 connected with <emphasis>NTP</emphasis> or <emphasis>SNTP</emphasis>
69 to the application server, you might have problems using storing and using time
76 <emphasis>Multiple servers</emphasis>
80 If your application is running on more than one server and these servers' time
81 bases are not syncronized, you can expect problems within your application when
82 part of the application is coming from one server and another part from another
89 <emphasis>Batch processing</emphasis>
93 If you want to work with a time service within a batch file or within a
94 command line application, <classname>Zend_TimeSync</classname> may be of use.
100 <classname>Zend_TimeSync</classname> may provide a good solution in all of these cases
101 and can be used if you are unable to run any services on your server.
105 <sect2 id="zend.timesync.introduction.ntp">
106 <title>What is NTP ?</title>
109 The Network Time Protocol (<emphasis>NTP</emphasis>) is a protocol
110 for synchronizing multiple systems' clocks over packet-switched, variable-latency data
111 networks. NTP uses UDP port 123 as its transport layer. See the <ulink
112 url="http://en.wikipedia.org/wiki/Network_Time_Protocol">wikipedia article</ulink>
113 for details about this protocol.
117 <sect2 id="zend.timesync.introduction.sntp">
118 <title>What is SNTP?</title>
121 The Simple Network Time Protocol (<emphasis>SNTP</emphasis>) is a
122 protocol synchronizing multiple systems' clocks over packet-switched, variable-latency
123 data networks. SNTP uses UDP port 37 as its transport layer. It is closely related to
124 the Network Time Protocol, but simpler.
128 <sect2 id="zend.timesync.introduction.problematic">
129 <title>Problematic usage</title>
132 Be warned that when you are using <classname>Zend_TimeSync</classname> you will have to
133 think about some details related to the structure of time sync and the internet itself.
134 Correct usage and best practices will be described here. Read carefully before you begin
135 using <classname>Zend_TimeSync</classname>.
139 <sect2 id="zend.timesync.introduction.decision">
140 <title>Decide which server to use</title>
143 You should select the time server that you want to use very carefully according to the
147 <itemizedlist mark='opencircle'>
154 The distance from your application server to the time server. If your server is
155 in Europe, it would make little sense to select a time server in Tahiti. Always
156 select a server which is not far away. This reduces the request time and overall
167 How long it takes to receive the request is also relevant. Try different servers
168 to get the best result. If you are requesting a server which is never
169 accessible, you will always have an unnecessary delay.
179 Do not always use the same server. All time servers will lock out requests from
180 servers that are flooding the server. If your application requires heavy use of
181 time servers, you should consider one of the pools described later.
187 So where can you find a time server? Generally you can use any timeserver you can
188 connect to. This can be a time server within your LAN or any public time server you have
189 access to. If you decide to use a public time server, you should consider using a server
190 pool. Server pools are public addresses from which you will get a random, pooled time
191 server by requesting the time. This way you will not have to split your requests. There
192 are public server pools available for many regions which you may use to avoid problems
197 See <ulink url="http://www.pool.ntp.org">pool.ntp.org</ulink> to find your nearest
198 server pool. For example, if your server is located within Germany you can connect to
199 <emphasis>0.europe.pool.ntp.org</emphasis>.