Closed casperisfine closed 1 year ago
Self note: the method name should probably reflect that it's the full server latency we're measuring (network + redis-server time to respond).
I called it RTT for round trip time, that's the industry standard acronym for ping time. "measure_rtt" or just "rtt" would be my suggestion for method name. I would prefer integer microseconds as the return value but traceroute does format RTT as float milliseconds so I can understand that choice.
Ok, renamed it to measure_round_trip_delay
. It's a bit of a mouthful but is clear.
I kept it as float milliseconds, as I think it's easier to work with in most cases, as that's generally the unit used for network operations.
Latency is returned as a Float in milliseconds.
For the Ruby driver, it's equivalent to measuring how long
call("PING")
takes, however with the Hiredis driver, the latency is measured without ever holding the GVL which allows to give a much more accurate measure that isn't impacted by GVL contention.Ref: https://github.com/redis/hiredis-rb/issues/74
Test script:
Note: I definitely see the usefulness of this, but it requires to bypass quite a few layers, which concerns me a bit in term of maintenance. But I'll sleep on it.
cc @mperham @nateberkopec