Needed some guidance for calculating the
# spicedb
m
Needed some guidance for calculating the hit ratio with the spicedb prom metrics
Does this look correct
sum(delta(spicedb_cache_hits_total{cache="namespace"}[1m]))/(sum(delta(spicedb_cache_hits_total{cache="namespace"}[1m])) + sum(delta(spicedb_cache_misses_total{cache="namespace"}[1m])))
y
we're using something similar; i don't know how much to trust it
j
@vroldanbet ^
v
We actually measure cache hits based on the number of dispatches spared
those metrics are for the caches used, and SpiceDB has various caches in place
So what we actually consider cache hit rate is "cached dispatch hit rate", which we compute as
Copy code
sum(rate(spicedb_services_dispatches_sum{cached="true"}[$__rate_interval])) / sum(rate(spicedb_services_dispatches_sum{}[$__rate_interval]))
m
thanks - so if I understand this correctly you are caching the results on one node so you don't need to goto another node to get that data (dispatch spared).
j
correct
m
@Joey are there any knobs to control the caching TTL or the size of the cache in spicedb ?
v
TTL can only be adjusted indirectly by changing the so called "quantization window", which is the window of time in which revisions are quantized to. By default it's 5 seconds, so it you increase to say 10s, your cache TTL will turn into 20s (2 * quantization window)
of course by increasing the quantization window you get more exposure to the new enemy problem, but if stale responses are not a concern for you, then you can definitely play with that nob
cache sizes can also be changed. I'd suggest to run into
spicedb serve help
to see all flags, including cache size flags
m
thanks that's great