Skip to content

Commit 696ac97

Browse files
authored
Merge pull request #674 from p8/sinatra/puma-8-marks-as-io-bound
[sinatra] Update puma to 8.0
2 parents 8b0daa5 + 3955d81 commit 696ac97

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

frameworks/sinatra/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ENV RUBY_YJIT_ENABLE=1
1111
ENV RUBY_MN_THREADS=1
1212
ENV RACK_ENV=production
1313
ENV WEB_CONCURRENCY=auto
14-
ENV MAX_THREADS=4
14+
ENV MAX_THREADS=3
15+
ENV MAX_IO_THREADS=10
1516

1617
WORKDIR /app
1718

frameworks/sinatra/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source 'https://rubygems.org'
22

33
gem 'sinatra', '~> 4.1'
4-
gem 'puma', '~> 7.2'
4+
gem 'puma', '~> 8.0'
55
gem 'pg', '~> 1.5'
66
gem 'json'
77
gem 'concurrent-ruby'

frameworks/sinatra/Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GEM
1010
nio4r (2.7.5)
1111
pg (1.6.3-arm64-darwin)
1212
pg (1.6.3-x86_64-linux)
13-
puma (7.2.0)
13+
puma (8.0.1)
1414
nio4r (~> 2.0)
1515
rack (3.2.6)
1616
rack-protection (4.2.1)
@@ -38,7 +38,7 @@ DEPENDENCIES
3838
connection_pool
3939
json
4040
pg (~> 1.5)
41-
puma (~> 7.2)
41+
puma (~> 8.0)
4242
sinatra (~> 4.1)
4343

4444
CHECKSUMS
@@ -51,7 +51,7 @@ CHECKSUMS
5151
nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
5252
pg (1.6.3-arm64-darwin) sha256=7240330b572e6355d7c75a7de535edb5dfcbd6295d9c7777df4d9dddfb8c0e5f
5353
pg (1.6.3-x86_64-linux) sha256=5d9e188c8f7a0295d162b7b88a768d8452a899977d44f3274d1946d67920ae8d
54-
puma (7.2.0) sha256=bf8ef4ab514a4e6d4554cb4326b2004eba5036ae05cf765cfe51aba9706a72a8
54+
puma (8.0.1) sha256=7b94e50c07655718c1fb8ae41a11fc06c7d61293208b3aa608ff71a46d3ad37c
5555
rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
5656
rack-protection (4.2.1) sha256=cf6e2842df8c55f5e4d1a4be015e603e19e9bc3a7178bae58949ccbb58558bac
5757
rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8

frameworks/sinatra/config.ru

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ class MethodGuard
1717
end
1818
end
1919

20+
# Threads marked as IO bound are allowed to go over Puma's max thread limit.
21+
class MarkAsIOBoundThreads
22+
def initialize(app)
23+
@app = app
24+
end
25+
26+
def call(env)
27+
if env['PATH_INFO'].start_with? '/baseline'
28+
env["puma.mark_as_io_bound"].call
29+
end
30+
@app.call(env)
31+
end
32+
end
33+
34+
use MarkAsIOBoundThreads
2035
use MethodGuard
2136
use Rack::Deflater
2237
run App

frameworks/sinatra/puma.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
threads ENV.fetch('MAX_THREADS', 4).to_i
2+
max_io_threads ENV.fetch("MAX_IO_THREADS", 10).to_i
23

34
tls_cert_path = ENV.fetch('TLS_CERT', '/certs/server.crt')
45
tls_key_path = ENV.fetch('TLS_KEY', '/certs/server.key')

0 commit comments

Comments
 (0)