From 6a06f9b3dbe2c1d0765cd71126345d0db4bfff93 Mon Sep 17 00:00:00 2001 From: Petrik Date: Tue, 9 Jun 2026 21:36:20 +0200 Subject: [PATCH] [rails] Mark async-db calls as IO bound --- frameworks/rails/app/controllers/application_controller.rb | 2 +- frameworks/rails/config/application.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frameworks/rails/app/controllers/application_controller.rb b/frameworks/rails/app/controllers/application_controller.rb index e1ef3b386..d051f8cc2 100644 --- a/frameworks/rails/app/controllers/application_controller.rb +++ b/frameworks/rails/app/controllers/application_controller.rb @@ -41,6 +41,6 @@ def self.redis end def self.pool_size - ENV.fetch('RAILS_MAX_THREADS', 4).to_i + ENV.fetch('RAILS_MAX_THREADS', 4).to_i + ENV.fetch("MAX_IO_THREADS", 10).to_i end end diff --git a/frameworks/rails/config/application.rb b/frameworks/rails/config/application.rb index 80112231e..4eb37e8d1 100644 --- a/frameworks/rails/config/application.rb +++ b/frameworks/rails/config/application.rb @@ -19,12 +19,14 @@ def call(env) # Threads marked as IO bound are allowed to go over Puma's max thread limit. class MarkAsIOBoundThreads + IOBoundPaths = %w[/baseline11 /baseline2 /async-db].map { [_1, nil] }.to_h.freeze + def initialize(app) @app = app end def call(env) - if env['PATH_INFO'].start_with?('/baseline') + if IOBoundPaths.has_key? env['PATH_INFO'] env["puma.mark_as_io_bound"].call end @app.call(env)