diff --git a/frameworks/roda/Dockerfile b/frameworks/roda/Dockerfile index 5ac048ee..33d85705 100644 --- a/frameworks/roda/Dockerfile +++ b/frameworks/roda/Dockerfile @@ -12,6 +12,7 @@ ENV RUBY_MN_THREADS=1 ENV RACK_ENV=production ENV WEB_CONCURRENCY=auto ENV MAX_THREADS=4 +ENV MAX_IO_THREADS=10 WORKDIR /app diff --git a/frameworks/roda/Gemfile b/frameworks/roda/Gemfile index cd4e6b6a..6882018b 100644 --- a/frameworks/roda/Gemfile +++ b/frameworks/roda/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' gem 'roda', '~> 3.102' -gem 'puma', '~> 7.2' +gem 'puma', '~> 8.0' gem 'pg', '~> 1.5' gem 'json' gem 'concurrent-ruby' diff --git a/frameworks/roda/Gemfile.lock b/frameworks/roda/Gemfile.lock index 6388ea2e..8be0278b 100644 --- a/frameworks/roda/Gemfile.lock +++ b/frameworks/roda/Gemfile.lock @@ -8,7 +8,7 @@ GEM pg (1.6.3) pg (1.6.3-arm64-darwin) pg (1.6.3-x86_64-linux) - puma (7.2.0) + puma (8.0.1) nio4r (~> 2.0) rack (3.2.5) roda (3.102.0) @@ -32,7 +32,7 @@ DEPENDENCIES connection_pool json pg (~> 1.5) - puma (~> 7.2) + puma (~> 8.0) roda (~> 3.102) CHECKSUMS @@ -43,7 +43,7 @@ CHECKSUMS pg (1.6.3) sha256=1388d0563e13d2758c1089e35e973a3249e955c659592d10e5b77c468f628a99 pg (1.6.3-arm64-darwin) sha256=7240330b572e6355d7c75a7de535edb5dfcbd6295d9c7777df4d9dddfb8c0e5f pg (1.6.3-x86_64-linux) sha256=5d9e188c8f7a0295d162b7b88a768d8452a899977d44f3274d1946d67920ae8d - puma (7.2.0) sha256=bf8ef4ab514a4e6d4554cb4326b2004eba5036ae05cf765cfe51aba9706a72a8 + puma (8.0.1) sha256=7b94e50c07655718c1fb8ae41a11fc06c7d61293208b3aa608ff71a46d3ad37c rack (3.2.5) sha256=4cbd0974c0b79f7a139b4812004a62e4c60b145cba76422e288ee670601ed6d3 roda (3.102.0) sha256=b2156fff6d2b1b52bfac39e4ccde0d820a26594f069c3d9e99cc0853f7ee7dcc diff --git a/frameworks/roda/app.rb b/frameworks/roda/app.rb index 33515609..42bc2bb7 100644 --- a/frameworks/roda/app.rb +++ b/frameworks/roda/app.rb @@ -69,6 +69,7 @@ class App < Roda end r.is 'upload' do + request.env["puma.mark_as_io_bound"].call size = 0 buf = request.body while (chunk = buf.read(65536)) diff --git a/frameworks/roda/config.ru b/frameworks/roda/config.ru index 9695bfd1..1b148cf4 100644 --- a/frameworks/roda/config.ru +++ b/frameworks/roda/config.ru @@ -17,6 +17,21 @@ class MethodGuard end end +# Threads marked as IO bound are allowed to go over Puma's max thread limit. +class MarkAsIOBoundThreads + def initialize(app) + @app = app + end + + def call(env) + if env['PATH_INFO'].start_with? '/baseline' + env["puma.mark_as_io_bound"].call + end + @app.call(env) + end +end + +use MarkAsIOBoundThreads use MethodGuard use Rack::Deflater # enable gzip run App diff --git a/frameworks/roda/puma.rb b/frameworks/roda/puma.rb index e4859fc8..63c90bbf 100644 --- a/frameworks/roda/puma.rb +++ b/frameworks/roda/puma.rb @@ -1,4 +1,5 @@ threads ENV.fetch('MAX_THREADS', 4).to_i +max_io_threads ENV.fetch("MAX_IO_THREADS", 10).to_i tls_cert_path = ENV.fetch('TLS_CERT', '/certs/server.crt') tls_key_path = ENV.fetch('TLS_KEY', '/certs/server.key')