Skip to content

Add Rails: Ruby on Rails in API mode on Puma (~58k ⭐)#79

Merged
MDA2AV merged 4 commits intoMDA2AV:mainfrom
BennyFranciscus:add-rails
Mar 23, 2026
Merged

Add Rails: Ruby on Rails in API mode on Puma (~58k ⭐)#79
MDA2AV merged 4 commits intoMDA2AV:mainfrom
BennyFranciscus:add-rails

Conversation

@BennyFranciscus
Copy link
Collaborator

Rails — Ruby on Rails (API mode)

Language: Ruby
Framework: Rails (~58k ⭐)
Server: Puma (multi-worker, 4 threads per worker)

Why Rails?

HttpArena already has Sinatra (Ruby micro framework) — Rails completes the Ruby comparison. This is the most iconic web framework ever built. Convention over configuration, the framework that launched a thousand startups. Django vs Flask is already represented for Python — now we have the Ruby equivalent: Rails vs Sinatra.

Implementation

  • Rails 8.0 in API mode (no views, no assets, no ActionCable — pure JSON/text API)
  • Stripped middleware: removed HostAuthorization, RemoteIp, RequestId, Logger, ShowExceptions, Callbacks
  • Pre-computed JSON + gzip payloads at boot (same pattern as other entries)
  • Thread-local SQLite connections with mmap
  • Puma with 1 worker per CPU core, 4 threads each
  • Logging disabled (writes to /dev/null)

The interesting comparison

  • Sinatra vs Rails: micro DSL vs full-stack framework, same language, same server (Puma). How much overhead does Rails' routing, middleware stack, and controller abstraction add?
  • Django vs Rails: the two frameworks that defined modern web development. Same philosophy (batteries-included, convention over configuration), different languages.
  • Flask vs Sinatra: the micro framework comparison (already possible, now with Rails/Django as the full-stack counterpart)

Endpoints

All 8 standard endpoints implemented: /pipeline, /baseline11, /baseline2, /json, /compression, /db, /upload

cc @tenderlove @rafaelfranca @matthewd — would love to see how Rails stacks up in HttpArena! 🚂

@BennyFranciscus BennyFranciscus requested a review from MDA2AV as a code owner March 18, 2026 20:03
@BennyFranciscus
Copy link
Collaborator Author

CI is hitting the port 8080 conflict on the self-hosted runner (stale Docker container from a previous run). Same issue as #75 and #77. Docker build succeeds — it's the docker run -p 8080:8080 that fails because the port is already allocated.

Happy to re-trigger once the runner is cleaned up! 🙂

@BennyFranciscus
Copy link
Collaborator Author

CI is green now ✅ — looks like the port conflict on the runner got resolved. Rails is ready for benchmarking whenever you want to kick it off!

@MDA2AV
Copy link
Owner

MDA2AV commented Mar 23, 2026

@BennyFranciscus failing 2 tests

- Add catch-all route for unknown paths → 404
- Add Rack middleware to reject unknown HTTP methods → 405
- Fixes 2 failing validation tests
@BennyFranciscus
Copy link
Collaborator Author

Fixed both! 🔧

  1. Bad method → 405: Added a Rack middleware at the top of the stack that rejects unknown HTTP methods before they hit Rails routing (which was returning 501).
  2. Unknown path → 404: Added a catch-all route at the bottom of routes.rb.

Pushed — CI should pick it up shortly.

Puma 6.x rejects unknown HTTP methods (like GETT) with 501 at the
server level before Rack sees the request. Use supported_http_methods
:any to let the request through to our Rack middleware which returns
the correct 405 status.
@BennyFranciscus
Copy link
Collaborator Author

Found the root cause of the persistent bad method failure 🔍

Puma 6.x has a built-in HTTP method allowlist that rejects unknown methods (like GETT) with 501 at the server level — before the request even reaches Rack middleware. So my Rack middleware was never getting a chance to return 405.

Fix: added supported_http_methods :any to puma.rb, which tells Puma to pass all methods through to the application layer. The Rack middleware then handles the 405 response as intended.

CI should be green on this run!

@MDA2AV MDA2AV merged commit 8ed10f6 into MDA2AV:main Mar 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants