Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frameworks/sinatra/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ ENV RUBY_YJIT_ENABLE=1
ENV RUBY_MN_THREADS=1
ENV RACK_ENV=production
ENV WEB_CONCURRENCY=auto
ENV MAX_THREADS=4
ENV MAX_THREADS=3
ENV MAX_IO_THREADS=10

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion frameworks/sinatra/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

gem 'sinatra', '~> 4.1'
gem 'puma', '~> 7.2'
gem 'puma', '~> 8.0'
gem 'pg', '~> 1.5'
gem 'json'
gem 'concurrent-ruby'
Expand Down
6 changes: 3 additions & 3 deletions frameworks/sinatra/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
nio4r (2.7.5)
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.6)
rack-protection (4.2.1)
Expand Down Expand Up @@ -38,7 +38,7 @@ DEPENDENCIES
connection_pool
json
pg (~> 1.5)
puma (~> 7.2)
puma (~> 8.0)
sinatra (~> 4.1)

CHECKSUMS
Expand All @@ -51,7 +51,7 @@ CHECKSUMS
nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
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.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
rack-protection (4.2.1) sha256=cf6e2842df8c55f5e4d1a4be015e603e19e9bc3a7178bae58949ccbb58558bac
rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8
Expand Down
15 changes: 15 additions & 0 deletions frameworks/sinatra/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -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
run App
1 change: 1 addition & 0 deletions frameworks/sinatra/puma.rb
Original file line number Diff line number Diff line change
@@ -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')
Expand Down