Skip to content

Commit ccfe5de

Browse files
authored
Use fixed number of Puma threads (#3773)
Instead of specifying different min and max values for the number of threads and letting Puma start and stop threads on demand, a fixed number of threads is configured (i.e. min = max).
1 parent 31c994f commit ccfe5de

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/cloud_controller/runners/puma_runner.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def initialize(config, app, logger, periodic_updater, request_logs)
1616
end
1717

1818
conf.workers(config.get(:puma, :workers) || 1)
19-
conf.threads(0, config.get(:puma, :max_threads) || 1)
19+
num_threads = config.get(:puma, :max_threads) || 1
20+
conf.threads(num_threads, num_threads)
2021

2122
# In theory there shouldn't be any open connections when shutting down Puma as they have either been gracefully
2223
# drained or forcefully terminated (after cc.nginx_drain_timeout) by Nginx. Puma has some built-in (i.e. not

spec/unit/lib/cloud_controller/runners/puma_runner_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module VCAP::CloudController
6363
subject
6464

6565
expect(puma_launcher.config.final_options[:workers]).to eq(num_workers)
66-
expect(puma_launcher.config.final_options[:min_threads]).to eq(0)
66+
expect(puma_launcher.config.final_options[:min_threads]).to eq(max_threads)
6767
expect(puma_launcher.config.final_options[:max_threads]).to eq(max_threads)
6868
end
6969

@@ -75,6 +75,7 @@ module VCAP::CloudController
7575
subject
7676

7777
expect(puma_launcher.config.final_options[:workers]).to eq(1)
78+
expect(puma_launcher.config.final_options[:min_threads]).to eq(1)
7879
expect(puma_launcher.config.final_options[:max_threads]).to eq(1)
7980
end
8081
end

0 commit comments

Comments
 (0)