Commit eb3f5e67 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '35170-consolidate-redis-pool-config' into 'master'

Use `Runtime.max_threads` when sizing Redis pools

See merge request gitlab-org/gitlab!22420
parents 311ff335 cf0a1f60
......@@ -22,11 +22,8 @@ module Gitlab
def pool_size
# heuristic constant 5 should be a config setting somewhere -- related to CPU count?
size = 5
if Gitlab::Runtime.sidekiq?
# the pool will be used in a multi-threaded context
size += Sidekiq.options[:concurrency]
elsif Gitlab::Runtime.puma?
size += Puma.cli_config.options[:max_threads]
if Gitlab::Runtime.multi_threaded?
size += Gitlab::Runtime.max_threads
end
size
......
......@@ -116,9 +116,9 @@ RSpec.shared_examples "redis_shared_examples" do
clear_pool
end
context 'when running not on sidekiq workers' do
context 'when running on single-threaded runtime' do
before do
allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(false)
allow(Gitlab::Runtime).to receive(:multi_threaded?).and_return(false)
end
it 'instantiates a connection pool with size 5' do
......@@ -128,10 +128,10 @@ RSpec.shared_examples "redis_shared_examples" do
end
end
context 'when running on sidekiq workers' do
context 'when running on multi-threaded runtime' do
before do
allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(true)
allow(Sidekiq).to receive(:options).and_return({ concurrency: 18 })
allow(Gitlab::Runtime).to receive(:multi_threaded?).and_return(true)
allow(Gitlab::Runtime).to receive(:max_threads).and_return(18)
end
it 'instantiates a connection pool with a size based on the concurrency of the worker' do
......
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