fpco / libraries

FP Complete libraries mega-repo
2 stars 0 forks source link

Investigate getting current time from redis #148

Closed kantp closed 8 years ago

kantp commented 8 years ago

We're having issues where clock skew adversely affects our heartbeat check.

We should consider using the redis TIME command http://redis.io/commands/time, instead of getUTCTime, so that we have one clock that all nodes agree on.

kantp commented 8 years ago

Using the current time from redis will involve an additional roundtrip to the database. @bitonic hat the idea to avoid that via lua scripting, but apparently using TIME in scripts is forbidden in redis, because it could lead to issues on a cluster.

I have another idea, that avoids the clock skew problems, and should also lead to simpler, and more robust, code in the heartbeat checker.

Instead of periodically updating a timestamp as its heartbeat, each worker will

The heartbeat check will

On the side of checkHeartbeats, we will still need a clock, but only for

For both purposes, a clock skew is not dangerous: at worst, we make more heartbeat checks than we had planned.

I'm currently exploring the implementation of this design.

kantp commented 8 years ago

I have made a slight modification to the design above