Skip to content

Commit b05a563

Browse files
committed
[ruby/grape] Use Iodine instead of Unicorn
Unicorn is no longer maintained. Replace with Iodine, as it performs better in these benchmarks.
1 parent 94ef1d2 commit b05a563

File tree

10 files changed

+26
-193
lines changed

10 files changed

+26
-193
lines changed

frameworks/Ruby/grape/Gemfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
source 'https://rubygems.org'
22

33
gem 'mysql2', '0.5.6'
4-
gem 'unicorn', '6.1.0'
5-
gem 'puma', '~> 7.1'
64
gem 'activerecord', '~> 8.1.0', :require => 'active_record'
75
gem 'grape', '2.1.1'
86
gem 'json', '~> 2.9'
7+
8+
group :iodine, optional: true do
9+
gem "iodine", "~> 0.7", require: false
10+
end
11+
12+
group :puma, optional: true do
13+
gem "puma", "~> 7.1", require: false
14+
end

frameworks/Ruby/grape/Gemfile.lock

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ GEM
5050
zeitwerk
5151
i18n (1.14.7)
5252
concurrent-ruby (~> 1.0)
53+
iodine (0.7.58)
5354
json (2.16.0)
54-
kgio (2.11.4)
5555
logger (1.6.6)
5656
minitest (5.25.4)
5757
mustermann (3.0.3)
@@ -63,15 +63,11 @@ GEM
6363
puma (7.1.0)
6464
nio4r (~> 2.0)
6565
rack (3.2.3)
66-
raindrops (0.20.1)
6766
ruby2_keywords (0.0.5)
6867
securerandom (0.4.1)
6968
timeout (0.4.3)
7069
tzinfo (2.0.6)
7170
concurrent-ruby (~> 1.0)
72-
unicorn (6.1.0)
73-
kgio (~> 2.6)
74-
raindrops (~> 0.7)
7571
uri (1.0.3)
7672
zeitwerk (2.7.2)
7773

@@ -83,10 +79,10 @@ PLATFORMS
8379
DEPENDENCIES
8480
activerecord (~> 8.1.0)
8581
grape (= 2.1.1)
82+
iodine (~> 0.7)
8683
json (~> 2.9)
8784
mysql2 (= 0.5.6)
8885
puma (~> 7.1)
89-
unicorn (= 6.1.0)
9086

9187
BUNDLED WITH
9288
2.7.0

frameworks/Ruby/grape/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ comparing a variety of web servers.
1212
The tests were run with:
1313

1414
* [Ruby 3.4](http://www.ruby-lang.org/)
15-
* [Grape 2.0.0](http://www.ruby-grape.org/)
16-
* [Unicorn 6.1.0](https://yhbt.net/unicorn/)
17-
* [Puma 6.4](https://puma.io/)
15+
* [Grape 2.1](http://www.ruby-grape.org/)
16+
* [Iodine](https://github.com/boazsegev/iodine)
17+
* [Puma 7](https://puma.io/)
1818

1919
## Paths & Source for Tests
2020

frameworks/Ruby/grape/benchmark_config.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"notes": "",
2323
"versus": "rack-puma-mri"
2424
},
25-
"unicorn": {
25+
"iodine": {
2626
"json_url": "/json",
2727
"db_url": "/db",
2828
"query_url": "/query?queries=",
@@ -36,12 +36,12 @@
3636
"language": "Ruby",
3737
"orm": "Full",
3838
"platform": "Rack",
39-
"webserver": "Unicorn",
39+
"webserver": "Iodine",
4040
"os": "Linux",
4141
"database_os": "Linux",
42-
"display_name": "grape [unicorn]",
42+
"display_name": "grape [iodine]",
4343
"notes": "",
44-
"versus": "rack-unicorn-mri"
44+
"versus": "rack-iodine-mri"
4545
}
4646
}]
4747
}

frameworks/Ruby/grape/config.ru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module Acme
7979
class API < Grape::API
8080
before do
8181
header 'Date', Time.now.httpdate if defined?(Puma)
82-
header 'Server', 'WebServer'
82+
header 'Server', 'grape'
8383
end
8484
logger nil
8585
content_type :json, 'application/json'

frameworks/Ruby/grape/config.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ platform = "Rack"
1717
webserver = "Puma"
1818
versus = "rack-puma-mri"
1919

20-
[unicorn]
20+
[iodine]
2121
urls.plaintext = "/plaintext"
2222
urls.json = "/json"
2323
urls.db = "/db"
@@ -30,5 +30,5 @@ database_os = "Linux"
3030
os = "Linux"
3131
orm = "Full"
3232
platform = "Rack"
33-
webserver = "Unicorn"
34-
versus = "rack-unicorn-mri"
33+
webserver = "Iodine"
34+
versus = "rack-iodine-mri"

frameworks/Ruby/grape/config/nginx.conf

Lines changed: 0 additions & 158 deletions
This file was deleted.

frameworks/Ruby/grape/config/unicorn.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

frameworks/Ruby/grape/grape-unicorn.dockerfile renamed to frameworks/Ruby/grape/grape-iodine.dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ ADD ./ /grape
1313

1414
WORKDIR /grape
1515

16+
RUN bundle config set with 'iodine'
1617
RUN bundle install --jobs=4 --gemfile=/grape/Gemfile
1718

19+
ENV RACK_ENV=production
20+
1821
EXPOSE 8080
1922

20-
CMD nginx -c /grape/config/nginx.conf && bundle exec unicorn -E production -c config/unicorn.rb
23+
CMD bundle exec iodine -p 8080 -w $(ruby config/auto_tune.rb | grep -Eo '[0-9]+' | head -n 1)

frameworks/Ruby/grape/grape.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ADD ./ /grape
1111

1212
WORKDIR /grape
1313

14+
RUN bundle config set with 'puma'
1415
RUN bundle install --jobs=4 --gemfile=/grape/Gemfile
1516

1617
ENV WEB_CONCURRENCY=auto

0 commit comments

Comments
 (0)