1

I am experiencing a very strange behavior for which I struggle to identify the source, but assume it's the computer clock. Here is the setup and synopsis:

I have two computers on my home network connecting to the internet over a modem. One (computer A) is connected via RJ45, the other (computer B) via WLAN. Both machines run Windows 10 and on both machines I have exactly the same stack for an application: Postgresql 13 database and a Java app.

I am using the Java app to monitor events through a websocket which arrive every several millisecond. The events are published on a server on the internet and contain a timestamp with milisecond granularity.

The Java app parses the message and stores them in a postgresql table. This table also contains a field which simply captures the time of the insert automatically (using default now()).

To understand the latency between the event and the recording in the database, I did a comparison of the event time and the insertion time. On computer B (which uses the WLAN connection), I found the latency to be aound 5 milliseconds, which is perfectly acceptable. On computer A however, with exactly the same software stack, this "latency" is surprisingly high at about 2 to 3 seconds and varies a lot. Furthermore, in some instances the insertion time is recorded as BEFOR the event time, which is an impossibily and which makes me believe that it's not a latency issue but an issue with what time the "now()" function in postgresql is getting from the computer.

Using http://time.is, I checked the accuracy of the computer clock, and indeed on computer B, the time shows as "exact", whereas on computer A it shows as having a 0.7 second difference. Also resynching the time does not make any difference. I then used the NetTime application to use a different synchronization method, and noticed that the clock is reported as 28ms of, and a few seconds later it's -1 second off. In otherwords, although I just did the synching, it pretty much immediately is out of synch again and varies around between being too slow and too fast.

My main concern is the time difference or latency on the first computer, computer A and given those observations regarding the clock's variability, plus the fact that the software stack is 100% identical, I presume the problem lies with the computer clock. Unfortunately I don't know how best to validate this assumption, and if I'm correct how to even resolve the problem, as I never heard of computer clocks showing such behaviours. But ... could it be something else and I'm chasing after the wrong rabbit here? Could it be any LAN related problem, and how would I check that, as there are no other noticable problems.

Any help would be greatly appreciated.

Peter K.
  • 111

0 Answers0