time syncronization in erlang cluster

WILLIAMS Dominic D.WILLIAMS@REDACTED
Thu Jan 8 14:05:55 CET 2004


> I have a cluster of erlang nodes setup, and wish to synchronize the
> time on the nodes in the cluster, i.e i want to sync the values
> returned by now() on each node without having to restart the erlang
> runtime.
> 
> Any ideas if this can be done?
> 
> Alternatively, Is it possible to re-sync now() with the system time?

Intersting question. I wonder how that could be achieved without
breaking the requirement that two subsequent calls to now() will never
return the same value...

I am also curious to hear how Erlang/OTP can help with this issue.

In the meantime, here is my advice borne from my experience with
real-time distributed systems in my pre-Erlang days:

1) If possible (in particular if its availability can be guaranteed),
   make all applications use the time provided by a time server (which
   you develop). This server should be the only place in your code
   where you access system time. Apart from synchronisation, this
   approach has the nice feature that when testing your application,
   you can cheat, and make the server provide a false time, which
   allows you to test various interesting situations (e.g. time
   changes, leap years... and brutal synchronisations!)  and also lets
   you accelerate time very easily...

2) Use NTP to synchronize all the machines on your network. The real
   NTP protocol (though not Microsoft's SNTP...) has nice features
   such as millisecond precision, and actually adjusting the physical
   frequency of the system clock devices, so that even in the event of
   a network partition and thus temporary absence of synchronisation,
   individual clocks do not drift as much as they used to... In fact,
   NTP could help with the dilemna of resynchronising erlang:now()
   with the system clock without allowing for two subsequent calls
   returning the same thing, because NTP tries not to brutally
   resynchronize system clocks: it tends to slow them down or speed
   them up until they catch up, and then re-adjusts the frequency to
   keep them in sync...

Hope this helps,

Dominic Williams.



More information about the erlang-questions mailing list