Commit ecf0bf11 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'smaller-prom-redis-keys' into 'master'

Reduce redis key size by half for Prometheus::ProxyService

See merge request gitlab-org/gitlab!20006
parents ac9bf675 5ddf55ac
......@@ -5,9 +5,17 @@ module Prometheus
include ReactiveCaching
include Gitlab::Utils::StrongMemoize
self.reactive_cache_key = ->(service) { service.cache_key }
self.reactive_cache_key = ->(service) { [] }
self.reactive_cache_lease_timeout = 30.seconds
self.reactive_cache_refresh_interval = 30.seconds
# reactive_cache_refresh_interval should be set to a value higher than
# reactive_cache_lifetime. If the refresh_interval is less than lifetime
# then the ReactiveCachingWorker will re-query prometheus for this
# PromQL query even though it's (probably) already been picked up by
# the frontend
# refresh_interval should be set less than lifetime only if this data
# is expected to change *and* be fetched again by the frontend
self.reactive_cache_refresh_interval = 90.seconds
self.reactive_cache_lifetime = 1.minute
self.reactive_cache_worker_finder = ->(_id, *args) { from_cache(*args) }
......
---
title: Reduce redis key size for the Prometheus proxy and the amount of queries by half
merge_request: 20006
author:
type: performance
......@@ -8,6 +8,12 @@ describe Prometheus::ProxyService do
set(:project) { create(:project) }
set(:environment) { create(:environment, project: project) }
describe 'configuration' do
it 'ReactiveCaching refresh is not needed' do
expect(described_class.reactive_cache_refresh_interval).to be > described_class.reactive_cache_lifetime
end
end
describe '#initialize' do
let(:params) { ActionController::Parameters.new(query: '1').permit! }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment