Browse Source

Merge pull request #9497 from p8/sinatra-sequel/iodine

[ruby/sinatra-sequel] Add Iodine server
Mike Smith 7 months ago
parent
commit
6384d9a7fc

+ 10 - 5
frameworks/Ruby/sinatra-sequel/Gemfile

@@ -4,23 +4,28 @@ gem 'json', '~> 2.8'
 gem 'sequel', '~> 5.0'
 gem 'sinatra', '~> 4.0', :require=>'sinatra/base'
 
-group :mysql do
+group :mysql, optional: true do
   gem 'mysql2', '~> 0.5', :platforms=>[:ruby, :mswin]
 end
 
-group :postgresql do
+group :postgresql, optional: true do
   gem 'pg', '~> 1.5', :platforms=>[:ruby, :mswin]
   gem 'sequel_pg', '~> 1.6', :platforms=>:ruby, :require=>false
 end
 
-group :passenger do
+
+group :iodine, optional: true do
+  gem 'iodine', '~> 0.7', platforms: [:ruby, :mswin], require: false
+end
+
+group :passenger, optional: true do
   gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false
 end
 
-group :puma do
+group :puma, optional: true do
   gem 'puma', '~> 6.4', require: false
 end
 
-group :unicorn do
+group :unicorn, optional: true do
   gem 'unicorn', '~> 6.1', platforms: [:ruby, :mswin], require: false
 end

+ 5 - 5
frameworks/Ruby/sinatra-sequel/Gemfile.lock

@@ -3,15 +3,16 @@ GEM
   specs:
     base64 (0.2.0)
     bigdecimal (3.1.8)
+    iodine (0.7.58)
     json (2.8.2)
     kgio (2.11.4)
     mustermann (3.0.3)
       ruby2_keywords (~> 0.0.1)
     mysql2 (0.5.6)
     nio4r (2.7.4)
-    passenger (6.0.23)
+    passenger (6.0.24)
       rack (>= 1.6.13)
-      rackup
+      rackup (>= 2.0.0)
       rake (>= 12.3.3)
     pg (1.5.8)
     puma (6.5.0)
@@ -22,9 +23,8 @@ GEM
       rack (>= 3.0.0, < 4)
     rack-session (2.0.0)
       rack (>= 3.0.0)
-    rackup (2.1.0)
+    rackup (2.2.1)
       rack (>= 3)
-      webrick (~> 1.8)
     raindrops (0.20.1)
     rake (13.2.1)
     ruby2_keywords (0.0.5)
@@ -43,13 +43,13 @@ GEM
     unicorn (6.1.0)
       kgio (~> 2.6)
       raindrops (~> 0.7)
-    webrick (1.8.2)
 
 PLATFORMS
   ruby
   x86_64-darwin-23
 
 DEPENDENCIES
+  iodine (~> 0.7)
   json (~> 2.8)
   mysql2 (~> 0.5)
   passenger (~> 6.0)

+ 20 - 0
frameworks/Ruby/sinatra-sequel/benchmark_config.json

@@ -42,6 +42,26 @@
         "versus": "rack-sequel-postgres-puma-mri",
         "notes": ""
       },
+      "postgres-iodine-mri": {
+        "db_url": "/db",
+        "query_url": "/queries?queries=",
+        "fortune_url": "/fortunes",
+        "update_url": "/updates?queries=",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "Postgres",
+        "framework": "sinatra",
+        "language": "Ruby",
+        "orm": "Full",
+        "platform": "Rack",
+        "webserver": "Iodine",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "sinatra-sequel-postgres-iodine-mri",
+        "versus": "rack-sequel-postgres-iodine-mri",
+        "notes": ""
+      },
       "postgres-passenger-mri": {
         "db_url": "/db",
         "query_url": "/queries?queries=",

+ 3 - 3
frameworks/Ruby/sinatra-sequel/boot.rb

@@ -16,8 +16,8 @@ SERVER_STRING =
     'puma'
   elsif defined?(Unicorn)
     'unicorn'
-  elsif defined?(Agoo)
-    'agoo'
+  elsif defined?(Iodine)
+    'iodine'
   end
 
 Bundler.require(:default) # Load core modules
@@ -39,7 +39,7 @@ def connect(dbtype)
   elsif defined?(Puma) && (threads = Puma.cli_config.options.fetch(:max_threads)) > 1
     opts[:max_connections] = (2 * Math.log(threads)).floor
     opts[:pool_timeout] = 10
-  else
+  elsif defined?(Unicorn) || defined?(Passenger)
     Sequel.single_threaded = true
   end
 

+ 20 - 0
frameworks/Ruby/sinatra-sequel/sinatra-sequel-postgres-iodine-mri.dockerfile

@@ -0,0 +1,20 @@
+FROM ruby:3.4
+
+ENV RUBY_YJIT_ENABLE=1
+
+# Use Jemalloc
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends libjemalloc2
+ENV LD_PRELOAD=libjemalloc.so.2
+
+ADD ./ /sinatra-sequel
+WORKDIR /sinatra-sequel
+
+ENV BUNDLE_WITH=postgresql:iodine
+RUN bundle install --jobs=4 --gemfile=/sinatra-sequel/Gemfile
+
+ENV DBTYPE=postgresql
+
+EXPOSE 8080
+
+CMD bundle exec iodine -p 8080

+ 1 - 1
frameworks/Ruby/sinatra-sequel/sinatra-sequel-postgres-passenger-mri.dockerfile

@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
 ADD ./ /sinatra-sequel
 WORKDIR /sinatra-sequel
 
-ENV BUNDLE_WITHOUT=mysql:puma:unicorn
+ENV BUNDLE_WITH=postgresql:passenger
 RUN bundle install --jobs=4 --gemfile=/sinatra-sequel/Gemfile
 
 # TODO: https://github.com/phusion/passenger/issues/1916

+ 1 - 1
frameworks/Ruby/sinatra-sequel/sinatra-sequel-postgres-unicorn-mri.dockerfile

@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
 ADD ./ /sinatra-sequel
 WORKDIR /sinatra-sequel
 
-ENV BUNDLE_WITHOUT=mysql:passenger:puma
+ENV BUNDLE_WITH=postgresql:unicorn
 RUN bundle install --jobs=4 --gemfile=/sinatra-sequel/Gemfile
 
 ENV DBTYPE=postgresql

+ 1 - 1
frameworks/Ruby/sinatra-sequel/sinatra-sequel-postgres.dockerfile

@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
 ADD ./ /sinatra-sequel
 WORKDIR /sinatra-sequel
 
-ENV BUNDLE_WITHOUT=mysql:passenger:unicorn
+ENV BUNDLE_WITH=postgresql:puma
 RUN bundle install --jobs=4 --gemfile=/sinatra-sequel/Gemfile
 
 ENV DBTYPE=postgresql

+ 1 - 1
frameworks/Ruby/sinatra-sequel/sinatra-sequel.dockerfile

@@ -10,7 +10,7 @@ ENV LD_PRELOAD=libjemalloc.so.2
 ADD ./ /sinatra-sequel
 WORKDIR /sinatra-sequel
 
-ENV BUNDLE_WITHOUT=postgresql:passenger:unicorn
+ENV BUNDLE_WITH=mysql:puma
 RUN bundle install --jobs=4 --gemfile=/sinatra-sequel/Gemfile
 
 ENV DBTYPE=mysql