In a normal application, a simple call to
time.Now() in most languages will suffice for getting a timestamp, but what about in a web application spread over multiple servers? As I understand it
time.Now() will use the current system time, but there's no reliable way of telling after the fact if that time was synchronised with the rest of the machines. By this point you're throwing data into persistent storage with inconsistent timestamps which is not such a problem for created/modified times when inserting into a database, but a bigger problem when tracking event timing).
The best way I see to mitigate this is to have all machines request a timestamp from one specific 'master' machine, but then I thought what about latency? What if the network is busy and the response is delayed? There's several flaws with this method but I can't think of a more reliable one other than using CPU and network resources synchronising the time every few seconds.
What is the accepted best practice/industry standard here?