Skip to content

Draft: Introduction of short-lived in-memory cache for reads distribution

Pavlo Strokov requested to merge ps-read-dist-caching into master

With enabled distributed_reads feature each read operation leads to a database query execution to get state of the storages for particular repository. More reads leads to more database access, so pressure to it increases linear (or worse). To mitigate this pressure a short-living cache added before accessing database. The expiration of the entries could be set via configuration file: distributed_reads_cache_expiration key. The default is 1s.

To monitor the cache use a new counter was added: gitaly_praefect_uptodate_storages_cache_access_total. It tracks amount of cache hits, misses and populates per virtual repository.
And one metric to track error rate of getting up to date storages: gitaly_praefect_uptodate_storages_errors_total gitaly_praefect_uptodate_storages_cache_access_total.

Closes: #3053 (closed)

Marked as WIP as I didn't test it locally yet.
Also I plan to add a couple of metrics, so we can see how it is used.

Edited by Pavlo Strokov

Merge request reports