问题
I am creating data on several machines, processing the data in parallel, and then aggregating to a separate machine. What is the best way to sort the aggregated data by creation time, accurate to say, +/- 5 seconds? If all of the machines have their system time synchronized via NTP, is tacking on an integer timestamp, from the UNIX epoch, on each source machine, going to be reliable enough?
回答1:
After puzzling over this for a very short time, the best technique I can think of so far would be to maintain a monotonic clock on the source machines, and rather than adding an absolute(ish) timestamp to the data, add "age since creation" to each processed element, as calculated by ticks of the monotonic clock, and sort by this age on the aggregating machine. This leaves room for error due to network delay, so I'm open to more suggestions (barring reimplementing NTP, as in this answer.)
来源:https://stackoverflow.com/questions/57278471/whats-an-effective-way-to-sort-data-objects-by-creation-time-after-aggregating