Skip to content

Commit 50c96af

Browse files
committed
[ruby/sinatra] Add agoo server
Agoo should should improve sinatra results: +------------+---------+------+------+-----+-----+-------+--------------+ | branch_name|plaintext|update| json| db|query|fortune|weighted_score| +------------+---------+------+------+-----+-----+-------+--------------+ | master| 92523| 9634| 92989|38761|14495| 22834| 1242| |sinatra/agoo| 150163| 16868|133183|50760|47776| 27544| 2550| +------------+---------+------+------+-----+-----+-------+--------------+
1 parent 36a565a commit 50c96af

9 files changed

+63
-14
lines changed

frameworks/Ruby/sinatra/Gemfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,27 @@ gem 'activerecord', '~> 7.2', require: 'active_record'
44
gem 'json', '~> 2.8'
55
gem 'sinatra', '~> 4.0', require: 'sinatra/base'
66

7-
group :mysql do
7+
group :mysql, optional: true do
88
gem 'mysql2', '~> 0.5', :platforms=>[:ruby, :mswin]
99
end
1010

11-
group :postgresql do
11+
group :postgresql, optional: true do
1212
gem 'pg', '~> 1.5', platforms: [:ruby, :mswin]
1313
end
1414

15-
group :passenger do
15+
group :passenger, optional: true do
1616
gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false
1717
end
1818

19-
group :puma do
19+
group :puma, optional: true do
2020
gem 'puma', '~> 6.4', require: false
2121
end
2222

2323
group :unicorn do
2424
gem 'unicorn', '~> 6.1', platforms: [:ruby, :mswin], require: false
2525
end
26+
27+
group :agoo, optional: true do
28+
gem 'agoo', require: false
29+
gem 'rackup'
30+
end

frameworks/Ruby/sinatra/Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GEM
1818
minitest (>= 5.1)
1919
securerandom (>= 0.3)
2020
tzinfo (~> 2.0, >= 2.0.5)
21+
agoo (2.15.13)
2122
base64 (0.2.0)
2223
bigdecimal (3.1.8)
2324
concurrent-ruby (1.3.4)
@@ -74,11 +75,13 @@ PLATFORMS
7475

7576
DEPENDENCIES
7677
activerecord (~> 7.2)
78+
agoo
7779
json (~> 2.8)
7880
mysql2 (~> 0.5)
7981
passenger (~> 6.0)
8082
pg (~> 1.5)
8183
puma (~> 6.4)
84+
rackup
8285
sinatra (~> 4.0)
8386
unicorn (~> 6.1)
8487

frameworks/Ruby/sinatra/benchmark_config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@
4444
"versus": "rack-postgres-puma-mri",
4545
"notes": ""
4646
},
47+
"postgres-agoo-mri": {
48+
"json_url": "/json",
49+
"db_url": "/db",
50+
"query_url": "/queries?queries=",
51+
"fortune_url": "/fortunes",
52+
"update_url": "/updates?queries=",
53+
"plaintext_url": "/plaintext",
54+
"port": 8080,
55+
"approach": "Realistic",
56+
"classification": "Micro",
57+
"database": "Postgres",
58+
"framework": "sinatra",
59+
"language": "Ruby",
60+
"orm": "Full",
61+
"platform": "Rack",
62+
"webserver": "Agoo",
63+
"os": "Linux",
64+
"database_os": "Linux",
65+
"display_name": "sinatra-postgres-agoo-mri",
66+
"versus": "rack-postgres-agoo-mri",
67+
"notes": ""
68+
},
4769
"postgres-passenger-mri": {
4870
"db_url": "/db",
4971
"query_url": "/queries?queries=",

frameworks/Ruby/sinatra/boot.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010

1111
SERVER_STRING =
1212
if defined?(PhusionPassenger)
13-
[
14-
PhusionPassenger::SharedConstants::SERVER_TOKEN_NAME,
15-
PhusionPassenger::VERSION_STRING
16-
].join('/').freeze
13+
'passenger'
1714
elsif defined?(Puma)
18-
Puma::Const::PUMA_SERVER_STRING
15+
'puma'
1916
elsif defined?(Unicorn)
20-
Unicorn::HttpParser::DEFAULTS['SERVER_SOFTWARE']
17+
'unicorn'
18+
elsif defined?(Agoo)
19+
'agoo'
2120
end
2221

2322
Bundler.require(:default) # Load core modules
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM ruby:3.4-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+
ADD ./ /sinatra
11+
WORKDIR /sinatra
12+
13+
ENV BUNDLE_WITH=postgresql:agoo
14+
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile
15+
16+
ENV DBTYPE=postgresql
17+
18+
EXPOSE 8080
19+
20+
CMD RACK_ENV=production bundle exec rackup -r agoo -s agoo -p 8080 -q -O workers=$(ruby config/auto_tune.rb | grep -Eo '[0-9]+' | head -n 1)

frameworks/Ruby/sinatra/sinatra-postgres-passenger-mri.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
1010
ADD ./ /sinatra
1111
WORKDIR /sinatra
1212

13-
ENV BUNDLE_WITHOUT=mysql:puma:unicorn
13+
ENV BUNDLE_WITH=postgresql:passenger
1414
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile
1515

1616
# TODO: https://github.com/phusion/passenger/issues/1916

frameworks/Ruby/sinatra/sinatra-postgres-unicorn-mri.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
1010
ADD ./ /sinatra
1111
WORKDIR /sinatra
1212

13-
ENV BUNDLE_WITHOUT=mysql:passenger:puma
13+
ENV BUNDLE_WITH=postgresql:unicorn
1414
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile
1515

1616
ENV DBTYPE=postgresql

frameworks/Ruby/sinatra/sinatra-postgres.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
1010
ADD ./ /sinatra
1111
WORKDIR /sinatra
1212

13-
ENV BUNDLE_WITHOUT=mysql:passenger:unicorn
13+
ENV BUNDLE_WITH=postgresql:puma
1414
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile
1515

1616
ENV DBTYPE=postgresql

frameworks/Ruby/sinatra/sinatra.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
1010
ADD ./ /sinatra
1111
WORKDIR /sinatra
1212

13-
ENV BUNDLE_WITHOUT=postgresql:passenger:unicorn
13+
ENV BUNDLE_WITH=mysql:puma
1414
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile
1515

1616
ENV DBTYPE=mysql

0 commit comments

Comments
 (0)