Browse Source

[ruby/rack] Add Pitchfork server (#9733)

Pitchfork is a preforking HTTP server based on Unicorn (which hasn't
seen an update since 2021).
Petrik de Heus 5 months ago
parent
commit
1bf0a220fc

+ 4 - 0
frameworks/Ruby/rack/Gemfile

@@ -22,6 +22,10 @@ group :iodine, optional: true do
   gem 'iodine', '~> 0.7', platforms: %i[ruby mswin]
 end
 
+group :pitchfork, optional: true do
+  gem 'pitchfork', '~> 0.17'
+end
+
 group :puma, optional: true do
   gem 'puma', '~> 6.5'
 end

+ 5 - 0
frameworks/Ruby/rack/Gemfile.lock

@@ -65,6 +65,7 @@ GEM
     language_server-protocol (3.17.0.4)
     lint_roller (1.1.0)
     localhost (1.3.1)
+    logger (1.6.6)
     mapping (1.1.1)
     memory-leak (0.5.2)
     metrics (0.12.2)
@@ -75,6 +76,9 @@ GEM
       ast (~> 2.4.1)
       racc
     pg (1.5.9)
+    pitchfork (0.17.0)
+      logger
+      rack (>= 2.0)
     protocol-hpack (1.5.1)
     protocol-http (0.49.0)
     protocol-http1 (0.30.0)
@@ -139,6 +143,7 @@ DEPENDENCIES
   jdbc-postgres (~> 42.2)
   json (~> 2.10)
   pg (~> 1.5)
+  pitchfork (~> 0.17)
   puma (~> 6.5)
   rack (~> 3.0)
   rack-test

+ 1 - 0
frameworks/Ruby/rack/README.md

@@ -18,6 +18,7 @@ The tests were run with:
 * [Puma 6.4](http://puma.io/)
 * [Iodine](https://github.com/boazsegev/iodine)
 * [Falcon](https://github.com/socketry/falcon)
+* [Pitchfork](https://github.com/Shopify/pitchfork)
 * [Sequel 5](https://sequel.jeremyevans.net/)
 
 

+ 21 - 0
frameworks/Ruby/rack/benchmark_config.json

@@ -106,6 +106,27 @@
         "database_os": "Linux",
         "display_name": "rack-puma-jruby-sequel-raw",
         "notes": ""
+      },
+      "pitchfork": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "db_url": "/db",
+        "query_url": "/queries?queries=",
+        "fortune_url": "/fortunes",
+        "update_url": "/updates?queries=",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Platform",
+        "orm": "raw",
+        "database": "Postgres",
+        "framework": "rack",
+        "language": "Ruby",
+        "platform": "Mri",
+        "webserver": "Pitchfork",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "rack-pitchfork-mri-sequel-raw",
+        "notes": ""
       }
     }
   ]

+ 11 - 0
frameworks/Ruby/rack/config/auto_tune.rb

@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+require_relative 'auto_tune'
+require 'sequel'
+num_workers, = auto_tune
+
+worker_processes num_workers
+
+before_fork do |_server|
+  Sequel::DATABASES.each(&:disconnect)
+end

+ 22 - 0
frameworks/Ruby/rack/falcon.rb

@@ -0,0 +1,22 @@
+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
+
+WORKDIR /rack
+
+COPY Gemfile ./
+
+ENV BUNDLE_FORCE_RUBY_PLATFORM=true
+RUN bundle config set with 'pitchfork'
+RUN bundle install --jobs=8
+
+COPY . .
+
+EXPOSE 8080
+
+CMD bundle exec pitchfork -c config/pitchfork.rb -o 0.0.0.0 -p 8080 -E production