Module: ThreeScale::Backend::Manifest
- Defined in:
- lib/3scale/backend/manifest.rb
Class Method Summary collapse
-
.compute_workers(ncpus) ⇒ Object
Compute workers based on LISTENER_WORKERS and PUMA_WORKERS env variables.
- .report ⇒ Object
- .server_model ⇒ Object
-
.thread_safe? ⇒ Boolean
Thread safety of our application.
Class Method Details
.compute_workers(ncpus) ⇒ Object
Compute workers based on LISTENER_WORKERS and PUMA_WORKERS env variables. The former takes precedence. If those envs do not exist or are empty, use number of cpus
24 25 26 27 28 29 30 |
# File 'lib/3scale/backend/manifest.rb', line 24 def compute_workers(ncpus) return 0 unless Process.respond_to?(:fork) compute_workers_from_env(LISTENER_WORKERS) || compute_workers_from_env(PUMA_WORKERS) || ncpus * PUMA_WORKERS_CPUMULT end |
.report ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/3scale/backend/manifest.rb', line 56 def report { version: ThreeScale::Backend::VERSION, root_dir: ThreeScale::Backend::Util.root_dir, servers: ThreeScale::Backend::Server.list, thread_safe: thread_safe?, server_model: server_model, } end |
.server_model ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/3scale/backend/manifest.rb', line 32 def server_model # Serving model settings here # # compute default workers and threads values # We want to adapt workers and threads to our characteristics. # Note that these values will likely need to be tweaked depending on # the Ruby implementation and how our app behaves! ncpus = ThreeScale::Backend::Util.number_of_cpus workers = compute_workers ncpus # if no workers but mt-safe, we spawn more threads. min_threads, max_threads = if thread_safe? shift = workers.zero? ? 2 : 0 [ncpus << shift, ncpus << 1 + shift] else [1, 1] end { ncpus: ncpus, workers: workers, min_threads: min_threads, max_threads: max_threads } end |
.thread_safe? ⇒ Boolean
Thread safety of our application. Turn this on if we ever are MT safe.
17 18 19 |
# File 'lib/3scale/backend/manifest.rb', line 17 def thread_safe? false end |