Skip to content

Commit af90b94

Browse files
committed
[ruby/rack] Add Itsi webserver for Rack
1 parent 65fc874 commit af90b94

File tree

7 files changed

+86
-4
lines changed

7 files changed

+86
-4
lines changed

frameworks/Ruby/rack/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ group :iodine, optional: true do
2222
gem 'iodine', '~> 0.7', platforms: %i[ruby windows]
2323
end
2424

25+
group :itsi, optional: true do
26+
gem 'itsi'
27+
end
28+
2529
group :passenger, optional: true do
2630
gem 'logger' # required by passenger on Ruby 3.5
2731
gem 'passenger', '~> 6.1', platforms: [:ruby, :windows], require: false

frameworks/Ruby/rack/Gemfile.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ GEM
6060
io-event (1.9.0)
6161
io-stream (0.6.1)
6262
iodine (0.7.58)
63+
itsi (0.2.18)
64+
itsi-scheduler (~> 0.2.18)
65+
itsi-server (~> 0.2.18)
66+
itsi-scheduler (0.2.18)
67+
rb_sys (~> 0.9.91)
68+
itsi-server (0.2.18)
69+
json (~> 2)
70+
prism (~> 1.4)
71+
rack (>= 1.6)
72+
rb_sys (~> 0.9.91)
6373
json (2.13.2)
6474
language_server-protocol (3.17.0.4)
6575
lint_roller (1.1.0)
@@ -84,6 +94,7 @@ GEM
8494
pitchfork (0.17.0)
8595
logger
8696
rack (>= 2.0)
97+
prism (1.4.0)
8798
protocol-hpack (1.5.1)
8899
protocol-http (0.54.0)
89100
protocol-http1 (0.35.2)
@@ -104,6 +115,9 @@ GEM
104115
rack (>= 3)
105116
rainbow (3.1.1)
106117
rake (13.3.0)
118+
rake-compiler-dock (1.9.1)
119+
rb_sys (0.9.117)
120+
rake-compiler-dock (= 1.9.1)
107121
regexp_parser (2.10.0)
108122
rubocop (1.73.2)
109123
json (~> 2.3)
@@ -145,6 +159,7 @@ DEPENDENCIES
145159
connection_pool (~> 2.4)
146160
falcon (~> 0.47)
147161
iodine (~> 0.7)
162+
itsi
148163
jdbc-postgres (~> 42.2)
149164
json (~> 2.10)
150165
logger

frameworks/Ruby/rack/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ The tests were run with:
1313

1414
* [Ruby 3.4](http://www.ruby-lang.org/)
1515
* [JRuby 9.4](http://jruby.org/)
16-
* [Rack 3.1](http://rack.github.com/)
17-
* [Unicorn 6.1.0](http://unicorn.bogomips.org/)
18-
* [Puma 7](http://puma.io/)
19-
* [Iodine](https://github.com/boazsegev/iodine)
16+
* [Rack 3](http://rack.github.com/)
2017
* [Falcon](https://github.com/socketry/falcon)
18+
* [Iodine](https://github.com/boazsegev/iodine)
19+
* [Itsi](https://github.com/wouterken/itsi)
20+
* [Passenger](https://github.com/phusion/passenger)
2121
* [Pitchfork](https://github.com/Shopify/pitchfork)
22+
* [Puma](http://puma.io/)
2223
* [Sequel 5](https://sequel.jeremyevans.net/)
2324

2425

frameworks/Ruby/rack/benchmark_config.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@
6565
"display_name": "rack [falcon]",
6666
"notes": ""
6767
},
68+
"itsi": {
69+
"json_url": "/json",
70+
"plaintext_url": "/plaintext",
71+
"db_url": "/db",
72+
"query_url": "/queries?queries=",
73+
"fortune_url": "/fortunes",
74+
"update_url": "/updates?queries=",
75+
"port": 8080,
76+
"approach": "Realistic",
77+
"classification": "Platform",
78+
"orm": "raw",
79+
"database": "Postgres",
80+
"framework": "rack",
81+
"language": "Ruby",
82+
"platform": "Mri",
83+
"webserver": "Itsi",
84+
"os": "Linux",
85+
"database_os": "Linux",
86+
"display_name": "rack [itsi]",
87+
"notes": ""
88+
},
6889
"jruby": {
6990
"json_url": "/json",
7091
"plaintext_url": "/plaintext",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require_relative 'auto_tune'
2+
3+
rackup_file './config.ru'
4+
5+
ruby_thread_request_backlog_size 10_000
6+
7+
preload false
8+
9+
num_workers, num_threads = auto_tune
10+
11+
workers num_workers
12+
threads num_threads
13+
fiber_scheduler false

frameworks/Ruby/rack/hello_world.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class HelloWorld
4545
def initialize
4646
if defined?(Puma) && (threads = Puma.cli_config.options.fetch(:max_threads)) > 1
4747
max_connections = threads
48+
elsif defined?(Itsi)
49+
require_relative 'config/auto_tune'
50+
_num_workers, num_threads = auto_tune
51+
max_connections = num_threads
4852
else
4953
max_connections = 512
5054
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ruby:3.5-rc
2+
3+
ENV RUBY_YJIT_ENABLE=1
4+
5+
# Use Jemalloc
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends libjemalloc2
8+
ENV LD_PRELOAD=libjemalloc.so.2
9+
10+
RUN apt-get install -y build-essential libclang-dev
11+
12+
WORKDIR /rack
13+
14+
COPY Gemfile* ./
15+
16+
ENV BUNDLE_FORCE_RUBY_PLATFORM=true
17+
RUN bundle config set with 'itsi'
18+
RUN bundle install --jobs=8
19+
20+
COPY . .
21+
22+
EXPOSE 8080
23+
24+
CMD bundle exec itsi start -C config/itsi.rb --bind "http://tfb-server:8080"

0 commit comments

Comments
 (0)