raptor 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59fe5e87d01266b5c1c95e08e24339fc1bae9748c9ed814d4694903a2bbce8c5
4
- data.tar.gz: 53cb18d26ad63f298a7a94496c536b561de3c7be29113df8ee77736d20c9019e
3
+ metadata.gz: 6f72ac9941a9da99f3fe49f3464ac925ff6304cf196836502a480220eb99d48f
4
+ data.tar.gz: 7a72e415e3663c54ac3c4f2fcfd13481356b3357693298c082f2b2eda3727182
5
5
  SHA512:
6
- metadata.gz: e8a0997c88a5f7962cf9ae1d1a7e5ceb18830a321fc722cd88e87e848e998a68f0d2aa6bb091b5f6c0a7a074666a580150038d8ea52820f0518ff9f14e745ca7
7
- data.tar.gz: 67178c0c92dca4d419f2127185c0df981f67e9e5e561b05d2f0c67fdb953db5db1d5866ae35d2b2a48b8a2bfe02439d7a41305da7fa691c04d3057edfbce73a0
6
+ metadata.gz: bf330c4d82552ee29b56b4bf0998355d3faad012147a5d34b9ade39d1f333ef4cc46b9d0e81c9b96516462fa920c3efe0c849fb716cdb158261cc3a6aff5014c
7
+ data.tar.gz: 9ff03e07f24109d0c1a0af66c309b6a49fa8f45c6db0aecd0a1c8507082d2e558a67bf72c01bf6c59f83c2aa379a41e8046f2b91f2d17deb8ecd59c5e44b162f
@@ -18,6 +18,17 @@ steps:
18
18
  - bundle install
19
19
  - bundle exec rake ci
20
20
 
21
+ - label: ":rails: Rails system tests"
22
+ image: "ruby:4.0"
23
+ env:
24
+ BROWSER_PATH: /usr/bin/chromium
25
+ commands:
26
+ - ruby -v
27
+ - apt-get update && apt-get install -y chromium
28
+ - bundle install
29
+ - bundle exec rails --version
30
+ - bundle exec rake test:rails
31
+
21
32
  - label: ":ruby: Ruby 4.0 +GC.stress"
22
33
  image: "ruby:4.0"
23
34
  env:
@@ -88,7 +99,7 @@ steps:
88
99
  queue: macos
89
100
  commands:
90
101
  - brew install --quiet ruby@4.0
91
- - export PATH="$(brew --prefix ruby@4.0)/bin:$PATH"
102
+ - export PATH="$(brew --prefix ruby@4.0)/bin:$$PATH"
92
103
  - bundle config set --local path .bundle
93
104
  - ruby -v
94
105
  - bundle install
@@ -101,12 +112,27 @@ steps:
101
112
  RUBY_YJIT_ENABLE: "1"
102
113
  commands:
103
114
  - brew install --quiet ruby@4.0
104
- - export PATH="$(brew --prefix ruby@4.0)/bin:$PATH"
115
+ - export PATH="$(brew --prefix ruby@4.0)/bin:$$PATH"
105
116
  - bundle config set --local path .bundle
106
117
  - ruby -v
107
118
  - bundle install
108
119
  - bundle exec rake ci
109
120
 
121
+ - label: ":rails: Rails system tests"
122
+ agents:
123
+ queue: macos
124
+ env:
125
+ BROWSER_PATH: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
126
+ commands:
127
+ - brew install --quiet ruby@4.0
128
+ - export PATH="$(brew --prefix ruby@4.0)/bin:$$PATH"
129
+ - test -x "$$BROWSER_PATH" || brew install --cask --quiet google-chrome
130
+ - bundle config set --local path .bundle
131
+ - ruby -v
132
+ - bundle install
133
+ - bundle exec rails --version
134
+ - bundle exec rake test:rails
135
+
110
136
  - label: ":ruby: Ruby 4.0 +GC.stress"
111
137
  agents:
112
138
  queue: macos
@@ -114,7 +140,7 @@ steps:
114
140
  RUBY_GC_STRESS: "1"
115
141
  commands:
116
142
  - brew install --quiet ruby@4.0
117
- - export PATH="$(brew --prefix ruby@4.0)/bin:$PATH"
143
+ - export PATH="$(brew --prefix ruby@4.0)/bin:$$PATH"
118
144
  - bundle config set --local path .bundle
119
145
  - ruby -v
120
146
  - bundle install
@@ -128,7 +154,7 @@ steps:
128
154
  RUBY_GC_STRESS: "1"
129
155
  commands:
130
156
  - brew install --quiet ruby@4.0
131
- - export PATH="$(brew --prefix ruby@4.0)/bin:$PATH"
157
+ - export PATH="$(brew --prefix ruby@4.0)/bin:$$PATH"
132
158
  - bundle config set --local path .bundle
133
159
  - ruby -v
134
160
  - bundle install
@@ -141,7 +167,7 @@ steps:
141
167
  commands:
142
168
  - brew unlink ruby
143
169
  - brew install --HEAD --quiet ruby
144
- - export PATH="$(brew --prefix ruby)/bin:$PATH"
170
+ - export PATH="$(brew --prefix ruby)/bin:$$PATH"
145
171
  - bundle config set --local path .bundle
146
172
  - ruby -v
147
173
  - bundle install
@@ -156,7 +182,7 @@ steps:
156
182
  commands:
157
183
  - brew unlink ruby
158
184
  - brew install --HEAD --quiet ruby
159
- - export PATH="$(brew --prefix ruby)/bin:$PATH"
185
+ - export PATH="$(brew --prefix ruby)/bin:$$PATH"
160
186
  - bundle config set --local path .bundle
161
187
  - ruby -v
162
188
  - bundle install
@@ -171,7 +197,7 @@ steps:
171
197
  commands:
172
198
  - brew unlink ruby
173
199
  - brew install --HEAD --quiet ruby
174
- - export PATH="$(brew --prefix ruby)/bin:$PATH"
200
+ - export PATH="$(brew --prefix ruby)/bin:$$PATH"
175
201
  - bundle config set --local path .bundle
176
202
  - ruby -v
177
203
  - bundle install
@@ -187,7 +213,7 @@ steps:
187
213
  commands:
188
214
  - brew unlink ruby
189
215
  - brew install --HEAD --quiet ruby
190
- - export PATH="$(brew --prefix ruby)/bin:$PATH"
216
+ - export PATH="$(brew --prefix ruby)/bin:$$PATH"
191
217
  - bundle config set --local path .bundle
192
218
  - ruby -v
193
219
  - bundle install
data/AGENTS.md ADDED
@@ -0,0 +1,25 @@
1
+ # Repository conventions
2
+
3
+ ## Code organisation
4
+
5
+ - Follow local style so the repository reads as one cohesive codebase.
6
+ - Group and order related declarations logically throughout the repository, not just in Ruby code. Use consistent names,
7
+ placement, and spacing to make relationships clear.
8
+ - Use blank lines to separate logical steps and final return values, without fragmenting closely related code.
9
+ - Separate standard-library, third-party, and project requires with blank lines, keeping `require_relative` separate.
10
+ Respect load-order dependencies and order semantically rather than alphabetically.
11
+ - Prefer `atomic-ruby`'s CAS-based queues and synchronisation in server internals. Use mutex-backed alternatives only
12
+ when their semantics justify them, and avoid busy-spinning across blocking operations.
13
+
14
+ ## Documentation and commits
15
+
16
+ - Keep comments focused on what and why. Explain implementation details only when the intent is otherwise unclear.
17
+ - Normally match commit subjects to changelog entries. Preserve separate entries for distinct changes worth calling out.
18
+ - Use inline code formatting for code references in commit subjects and changelog entries where applicable.
19
+
20
+ ## Tests
21
+
22
+ - Load `test_helper` first in test files and group test-support requires together, respecting boot dependencies.
23
+ - Rely on assertions' default failure messages rather than adding custom messages.
24
+ - Follow suite conventions for descriptions, setup, and assertions. Use Minitest's `parallelize_me!` when tests can
25
+ safely run independently.
data/CHANGELOG.md CHANGED
@@ -1,24 +1,34 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.27.0] - 2026-11-10
4
+
5
+ - Support master-owned Rack listeners across worker forks
6
+ - Add `after_worker_exit` hooks
7
+ - Add `after_worker_drain` hooks
8
+
9
+ ## [0.26.0] - 2026-11-10
10
+
11
+ - Add in-process Rack serving
12
+
3
13
  ## [0.25.0] - 2026-11-08
4
14
 
5
- - Replace nio4r with io-event for reactor I/O readiness without changing application threading
15
+ - Use `io-event` for reactor I/O readiness
6
16
 
7
17
  ## [0.24.0] - 2026-11-08
8
18
 
9
- - Honour `connection.max_body_size` for HTTP/2 request bodies without closing other streams
10
- - Wait for all current workers to boot before notifying systemd that Raptor is ready
11
- - Prefer each over call for HTTP/1 Rack response bodies that implement both
12
- - Reject empty HTTP/1 Content-Length values and unsupported transfer codings before reading request bodies
13
- - Preserve request Version headers instead of replacing them with the HTTP protocol
14
- - Trim leading tabs as optional HTTP/1 header whitespace
15
- - Honour HTTP/1 Connection token lists, with close taking precedence over keep-alive
16
- - Run worker boot hooks before starting application threads, parsers, and request handling
17
- - Close HTTP/2 response bodies when writing fails or a stream is cancelled
18
- - Bound HTTP/1 chunk size lines and trailers, including incomplete metadata
19
- - Reject invalid CRLF delimiters after HTTP/1 chunk payloads
20
- - Prefer hyphenated request headers over underscore aliases and reject HTTP/1 framing aliases
21
- - Add plugins with lifecycle hooks, cluster stats, and managed background threads
19
+ - Enforce request body limits on HTTP/2 streams
20
+ - Notify systemd only after every current worker boots
21
+ - Prefer enumerable Rack bodies over callable streaming
22
+ - Reject empty request lengths and unsupported transfer codings
23
+ - Preserve `Version` request headers in the Rack environment
24
+ - Trim optional leading tabs from HTTP/1 header values
25
+ - Honour HTTP/1 `Connection` token lists
26
+ - Complete worker boot hooks before starting request handling
27
+ - Close HTTP/2 response bodies when writing fails
28
+ - Bound HTTP/1 chunk size lines and trailers
29
+ - Validate HTTP/1 chunk payload delimiters
30
+ - Preserve request header identity during Rack normalization
31
+ - Add plugins
22
32
 
23
33
  ## [0.23.0] - 2026-10-18
24
34
 
@@ -32,13 +42,13 @@
32
42
  - Apply HTTP/2 initial window changes to responses waiting for flow control
33
43
  - Default `SERVER_NAME` for HTTP/2 requests without a host name
34
44
  - Join repeated HTTP/2 request headers instead of keeping only the last
35
- - Ignore HTTP/2 DATA frames for streams that already closed
45
+ - Ignore HTTP/2 `DATA` frames for streams that already closed
36
46
  - Credit each HTTP/2 stream window for the data that stream receives
37
- - Strip padding from HTTP/2 DATA and HEADERS frames
47
+ - Strip padding from HTTP/2 `DATA` and `HEADERS` frames
38
48
  - Encode and decode long HTTP/2 header strings without overflowing the stack
39
49
  - Limit HTTP/2 request header lists to 112 KiB
40
50
  - Reject HTTP/2 frames larger than the maximum frame size
41
- - Send GOAWAY when an HTTP/2 frame fails to decode
51
+ - Send `GOAWAY` when an HTTP/2 frame fails to decode
42
52
  - Keep pipelined HTTP/1.1 requests out of the previous request's body
43
53
  - Process chunked requests on kept-alive HTTP/1.1 connections without waiting for more data
44
54
  - Validate request framing on kept-alive HTTP/1.1 connections
@@ -97,12 +107,12 @@
97
107
  - Close connected control socket clients during shutdown
98
108
  - Skip TCP corking when `writev(2)` emits a response in one call
99
109
  - Return idle HTTP/1.1 keep-alive connections to the reactor without waiting
100
- - Increase the HTTP/1.1 keep-alive request limit to 1,000 and requeue the connection when other work is waiting
101
- - Add a read-only `/stats` control socket
102
- - Pass the worker index to worker boot and shutdown hooks
103
- - Add `RAPTOR_WORKERS`, `RAPTOR_THREADS`, and `RAPTOR_MAX_THREADS`
110
+ - Increase HTTP/1.1 keep-alive request limit
111
+ - Expose cluster stats over a control socket
112
+ - Pass worker indexes to lifecycle hooks
113
+ - Add worker and thread environment variables
104
114
  - Make worker CPU affinity opt-in
105
- - Add request-local thread and Fiber cleanup options
115
+ - Clean request-local state between requests
106
116
 
107
117
  ## [0.19.0] - 2026-08-29
108
118
 
@@ -173,7 +183,7 @@
173
183
  ## [0.10.0] - 2026-07-07
174
184
 
175
185
  - Memoize the server port string for the Rack env
176
- - Parse the Host header without regex
186
+ - Parse the `Host` header without regex
177
187
  - Apply `TCP_NODELAY` on the listener rather than each accepted socket
178
188
  - Buffer chunked body writes up to 512KB before flushing
179
189
  - Add `QUERY_STRING` to the Rack env template
@@ -188,7 +198,7 @@
188
198
  - Batch response header and body writes into a single `writev(2)` syscall
189
199
  - Close the binder as the last step of graceful shutdown
190
200
  - Lower the backpressure floor for tighter load balancing on small pools
191
- - Add load-aware `SO_REUSEPORT` routing on Linux via an attached BPF program
201
+ - Add load-aware `SO_REUSEPORT` routing via an attached BPF program
192
202
  - Reuse per-thread read buffers across HTTP/1.1 requests
193
203
  - Preserve the first `--bind` when it equals the default
194
204
 
@@ -235,7 +245,7 @@
235
245
 
236
246
  - Load `raptor.rb` or `config/raptor.rb` by default when no config path is supplied
237
247
  - Honour the peer's HTTP/2 flow-control windows when sending `DATA` frames
238
- - Assemble HEADERS across `CONTINUATION` frames
248
+ - Assemble `HEADERS` across `CONTINUATION` frames
239
249
  - Validate HTTP/2 stream IDs and emit `GOAWAY` on protocol errors
240
250
  - Offload TLS handshakes to the thread pool to keep the server thread responsive
241
251
  - Exit eager keep-alive loops on cluster shutdown
data/README.md CHANGED
@@ -37,7 +37,7 @@ run proc { |_env| [200, { "content-type" => "text/plain" }, ["Hello, World!"]] }
37
37
  ```
38
38
  > bundle exec raptor -w 10 -t 3 hello_world.ru
39
39
  [Raptor 39704|Main|Main] Cluster initializing:
40
- [Raptor 39704|Main|Main] ├─ Version: 0.23.0
40
+ [Raptor 39704|Main|Main] ├─ Version: 0.27.0
41
41
  [Raptor 39704|Main|Main] ├─ Ruby Version: ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +YJIT +PRISM [arm64-darwin25]
42
42
  [Raptor 39704|Main|Main] ├─ Environment: development
43
43
  [Raptor 39704|Main|Main] ├─ Master PID: 39704
@@ -76,6 +76,30 @@ Also works with `rackup` and `rails server`:
76
76
  Rails apps using `SOLID_QUEUE_IN_PUMA` run jobs through `config/puma.rb`, which Raptor does not load. Run `bin/jobs` as
77
77
  a separately supervised process or container instead.
78
78
 
79
+ ### Rails system tests
80
+
81
+ Use Raptor as Capybara's server without forking, so Rails can share transactional test data with browser requests.
82
+ Add this to your system test setup, alongside your browser driver configuration:
83
+
84
+ ```ruby
85
+ require "rackup"
86
+ require "rackup/handler/raptor"
87
+
88
+ Capybara.register_server :raptor do |app, port, host|
89
+ Rackup::Handler::Raptor.run(app, Host: host, Port: port, Workers: 0) do |server|
90
+ at_exit { server.shutdown }
91
+ end
92
+ end
93
+ Capybara.server = :raptor
94
+ ```
95
+
96
+ The exit hook shuts the server down before Ruby tears down its background threads.
97
+
98
+ For other in-process uses, `require "raptor/embedded"` and call `Raptor::Embedded.new(app, host: "127.0.0.1", port: 0)`.
99
+ `start` returns when serving is ready, `port` reports the bound port, `shutdown` drains requests and releases resources,
100
+ and `join` waits for termination. Call `shutdown` before process exit. The embedded server leaves signal handlers and
101
+ process-wide configuration to its caller. Cluster plugins and process lifecycle hooks do not run in this mode.
102
+
79
103
  ## Configuration
80
104
 
81
105
  Raptor reads options from a Ruby config file, environment variables, and command line flags, in increasing order of
@@ -124,8 +148,11 @@ working directory. Pass `-c PATH` to point at a specific file.
124
148
  worker_shutdown_timeout: 30,
125
149
  refork_after: 1000, # `nil` on non-Linux
126
150
  before_fork: [],
151
+ after_fork: [],
127
152
  before_worker_boot: [],
128
153
  before_worker_shutdown: [],
154
+ after_worker_drain: [],
155
+ after_worker_exit: [],
129
156
  before_refork: [],
130
157
  plugins: [],
131
158
  stats_file: "tmp/raptor.json",
@@ -167,21 +194,9 @@ Raptor::Plugin.create(:stats_logger) do
167
194
  end
168
195
  ```
169
196
 
170
- For an existing class, inherit from `Raptor::Plugin` and register it with
171
- `Raptor::Plugin.register(:stats_logger, MyStatsLogger)` instead.
172
-
173
- `start(cluster)` runs once before the initial workers fork. `cluster.options` exposes configuration, including
174
- plugin-specific keys. Append callbacks to its `before_fork`, `before_worker_boot`, `before_worker_shutdown`, and
175
- `before_refork` arrays during startup. If your plugin opens a listener, close the worker's inherited copy with
176
- `cluster.options[:before_worker_boot] << proc { @listener.close }` so only the master serves it.
177
-
178
- `cluster.stats` returns per-worker snapshots. `cluster.stats_hash` returns the same aggregate structure as `GET /stats`,
179
- including boot status, busy threads, capacity, backlog, and request counts. Both remain available while workers drain.
180
-
181
- Override `stop` to close listeners and flush exporters. Raptor calls it after workers exit, in reverse plugin order,
182
- then stops and joins threads created with `in_background`. These callbacks also run before hot restart and when startup
183
- fails, so `stop` must handle partially initialized resources. Worker replacement and phased restart keep the same
184
- master plugin instances running.
197
+ `cluster.options` exposes configuration and lifecycle hooks. `cluster.stats` and `cluster.stats_hash` provide worker
198
+ and aggregate statistics. Override `stop` to release plugin resources after workers exit, including during hot restart.
199
+ See the [API documentation](https://joshuay03.github.io/raptor/Raptor/Plugin.html) for lifecycle details.
185
200
 
186
201
  ## Bindings
187
202
 
@@ -250,7 +265,7 @@ Set `control_url` to a Unix socket URL such as `unix:///tmp/raptor-control.sock`
250
265
 
251
266
  ## (Micro) Benchmarks
252
267
 
253
- Raptor 0.25.0 vs Puma 8.0.2 vs Falcon 0.57.0. Each case has 3 fresh-process samples, interleaved in seeded shuffled
268
+ Raptor 0.27.0 vs Puma 8.0.2 vs Falcon 0.57.0. Each case has 3 fresh-process samples, interleaved in seeded shuffled
254
269
  rounds. Each sample warms up for 3s and measures for 15s. Metrics are independent medians. ± is (max − min) / 2 /
255
270
  median, not a confidence interval. Failure counts below each table sum all samples, so a failed run cannot disappear in
256
271
  a median. Throughput counts successful ordinary requests only.
@@ -278,92 +293,92 @@ accounting for shared pages instead of counting them fully in every worker.
278
293
 
279
294
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
280
295
  | ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
281
- | Raptor | Fixed (3) | - | 3.41k ±0.9% | - | 44.85 | - | 2.438 | 363.9 |
282
- | Raptor | Scaling (3–16) | - | 8.12k ±0.8% | - | 22.30 | - | 0.495 | 332.2 |
283
- | Puma | Fixed (3) | Fixed (3) | 1.53k ±1.3% | 55.0% lower | 118.30 | 163.8% higher | 0.950 | 289.8 |
284
- | Puma | Scaling (3–16) | Scaling (3–16) | 8.22k ±0.3% | 1.3% higher | 22.02 | 1.3% lower | 0.484 | 337.6 |
285
- | Falcon | Fibers | Fixed (3) | 10.87k ±0.4% | 218.7% higher | 15.63 | 65.1% lower | 0.468 | 437.3 |
286
- | Falcon | Fibers | Scaling (3–16) | 10.87k ±0.4% | 34.0% higher | 15.63 | 29.9% lower | 0.468 | 437.3 |
296
+ | Raptor | Fixed (3) | - | 3.35k ±1.2% | - | 49.00 | - | 2.421 | 337.8 |
297
+ | Raptor | Scaling (3–16) | - | 8.21k ±0.6% | - | 22.09 | - | 0.468 | 323.6 |
298
+ | Puma | Fixed (3) | Fixed (3) | 1.53k ±0.7% | 54.4% lower | 120.94 | 146.8% higher | 0.969 | 272.0 |
299
+ | Puma | Scaling (3–16) | Scaling (3–16) | 8.15k ±0.5% | 0.7% lower | 22.23 | 0.6% higher | 0.467 | 319.5 |
300
+ | Falcon | Fibers | Fixed (3) | 11.07k ±0.5% | 230.3% higher | 15.44 | 68.5% lower | 0.439 | 446.6 |
301
+ | Falcon | Fibers | Scaling (3–16) | 11.07k ±0.5% | 34.8% higher | 15.44 | 30.1% lower | 0.439 | 446.6 |
287
302
 
288
303
  ### IO over HTTP/1.1 keep-alive
289
304
 
290
305
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
291
306
  | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
292
- | Raptor | Fixed (3) | - | 3.40k ±3.1% | - | 38.77 | - | 2.440 | 369.9 |
293
- | Raptor | Scaling (3–16) | - | 7.44k ±0.4% | - | 24.43 | - | 0.494 | 356.2 |
294
- | Raptor | Fixed (16) | - | 7.55k ±2.0% | - | 24.11 | - | 0.475 | 358.0 |
295
- | Puma | Fixed (3) | Fixed (3) | 1.50k ±0.8% | 56.0% lower | 104.07 | 168.5% higher | 1.038 | 299.3 |
296
- | Puma | Scaling (3–16) | Scaling (3–16) | 7.44k ±0.3% | 0.1% higher | 24.44 | 0.1% higher | 0.441 | 341.3 |
297
- | Puma | Fixed (16) | Fixed (16) | 7.59k ±1.2% | 0.5% higher | 23.94 | 0.7% lower | 0.442 | 345.2 |
298
- | Falcon | Fibers | Fixed (3) | 7.58k ±4.3% | 123.1% higher | 23.89 | 38.4% lower | 0.408 | 365.3 |
299
- | Falcon | Fibers | Scaling (3–16) | 7.58k ±4.3% | 1.9% higher | 23.89 | 2.2% lower | 0.408 | 365.3 |
300
- | Falcon | Fibers | Fixed (16) | 7.58k ±4.3% | 0.4% higher | 23.89 | 0.9% lower | 0.408 | 365.3 |
307
+ | Raptor | Fixed (3) | - | 3.09k ±6.5% | - | 51.42 | - | 2.346 | 348.9 |
308
+ | Raptor | Scaling (3–16) | - | 7.39k ±0.6% | - | 24.67 | - | 0.465 | 344.2 |
309
+ | Raptor | Fixed (16) | - | 7.48k ±0.5% | - | 24.30 | - | 0.453 | 344.1 |
310
+ | Puma | Fixed (3) | Fixed (3) | 1.49k ±0.4% | 51.7% lower | 100.59 | 95.6% higher | 1.009 | 282.5 |
311
+ | Puma | Scaling (3–16) | Scaling (3–16) | 7.39k ±0.4% | 0.0% higher | 24.58 | 0.4% lower | 0.434 | 310.0 |
312
+ | Puma | Fixed (16) | Fixed (16) | 7.52k ±0.4% | 0.5% higher | 24.16 | 0.6% lower | 0.428 | 316.3 |
313
+ | Falcon | Fibers | Fixed (3) | 7.34k ±2.1% | 137.4% higher | 24.78 | 51.8% lower | 0.382 | 329.6 |
314
+ | Falcon | Fibers | Scaling (3–16) | 7.34k ±2.1% | 0.7% lower | 24.78 | 0.4% higher | 0.382 | 329.6 |
315
+ | Falcon | Fibers | Fixed (16) | 7.34k ±2.1% | 1.9% lower | 24.78 | 2.0% higher | 0.382 | 329.6 |
301
316
 
302
317
  ### IO over HTTP/2
303
318
 
304
- | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
305
- | ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
306
- | Raptor | Fixed (3) | - | 1.60k ±0.3% | - | 130.95 | - | 0.937 | 474.6 |
307
- | Raptor | Scaling (3–16) | - | 8.03k ±5.7% | - | 23.92 | - | 0.573 | 905.4 |
308
- | Falcon | Fibers | Fixed (3) | 7.55k ±10.7% | 370.7% higher | 25.90 | 80.2% lower | 0.462 | 497.3 |
309
- | Falcon | Fibers | Scaling (3–16) | 7.55k ±10.7% | 5.9% lower | 25.90 | 8.3% higher | 0.462 | 497.3 |
319
+ | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
320
+ | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
321
+ | Raptor | Fixed (3) | - | 1.61k ±0.3% | - | 131.78 | - | 0.901 | 410.2 |
322
+ | Raptor | Scaling (3–16) | - | 7.24k ±8.6% | - | 30.21 | - | 0.563 | 940.4 |
323
+ | Falcon | Fibers | Fixed (3) | 7.82k ±1.7% | 386.4% higher | 25.75 | 80.5% lower | 0.426 | 526.6 |
324
+ | Falcon | Fibers | Scaling (3–16) | 7.82k ±1.7% | 8.0% higher | 25.75 | 14.7% lower | 0.426 | 526.6 |
310
325
 
311
326
  ### CPU over HTTP/1.1
312
327
 
313
328
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
314
329
  | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
315
- | Raptor | Fixed (3) | - | 3.38k ±1.4% | - | 68.70 | - | 2.546 | 506.9 |
316
- | Raptor | Scaling (3–16) | - | 3.37k ±2.4% | - | 63.69 | - | 2.482 | 532.6 |
317
- | Puma | Fixed (3) | Fixed (3) | 3.17k ±1.2% | 6.2% lower | 56.91 | 17.2% lower | 2.521 | 451.2 |
318
- | Puma | Scaling (3–16) | Scaling (3–16) | 3.20k ±3.9% | 5.1% lower | 50.38 | 20.9% lower | 2.236 | 460.7 |
319
- | Falcon | Fibers | Fixed (3) | 3.40k ±1.0% | 0.7% higher | 47.88 | 30.3% lower | 2.533 | 428.3 |
320
- | Falcon | Fibers | Scaling (3–16) | 3.40k ±1.0% | 0.9% higher | 47.88 | 24.8% lower | 2.533 | 428.3 |
330
+ | Raptor | Fixed (3) | - | 3.40k ±1.5% | - | 66.74 | - | 2.519 | 511.8 |
331
+ | Raptor | Scaling (3–16) | - | 3.45k ±3.9% | - | 62.67 | - | 2.389 | 504.6 |
332
+ | Puma | Fixed (3) | Fixed (3) | 3.24k ±0.9% | 4.7% lower | 57.00 | 14.6% lower | 2.457 | 444.5 |
333
+ | Puma | Scaling (3–16) | Scaling (3–16) | 3.09k ±2.7% | 10.4% lower | 49.54 | 21.0% lower | 2.182 | 437.4 |
334
+ | Falcon | Fibers | Fixed (3) | 3.53k ±0.8% | 3.8% higher | 47.04 | 29.5% lower | 2.430 | 432.3 |
335
+ | Falcon | Fibers | Scaling (3–16) | 3.53k ±0.8% | 2.2% higher | 47.04 | 24.9% lower | 2.430 | 432.3 |
321
336
 
322
337
  ### CPU over HTTP/1.1 keep-alive
323
338
 
324
339
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
325
340
  | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
326
- | Raptor | Fixed (3) | - | 3.09k ±3.7% | - | 59.42 | - | 2.732 | 503.7 |
327
- | Raptor | Scaling (3–16) | - | 2.93k ±2.0% | - | 50.46 | - | 2.645 | 518.6 |
328
- | Puma | Fixed (3) | Fixed (3) | 3.41k ±6.7% | 10.7% higher | 57.91 | 2.5% lower | 2.423 | 406.4 |
329
- | Puma | Scaling (3–16) | Scaling (3–16) | 2.79k ±1.6% | 4.9% lower | 66.33 | 31.5% higher | 2.291 | 497.1 |
330
- | Falcon | Fibers | Fixed (3) | 3.01k ±6.2% | 2.5% lower | 73.18 | 23.1% higher | 2.920 | 563.1 |
331
- | Falcon | Fibers | Scaling (3–16) | 3.01k ±6.2% | 2.6% higher | 73.18 | 45.0% higher | 2.920 | 563.1 |
341
+ | Raptor | Fixed (3) | - | 3.12k ±0.3% | - | 50.35 | - | 2.534 | 483.3 |
342
+ | Raptor | Scaling (3–16) | - | 2.99k ±2.1% | - | 50.79 | - | 2.532 | 502.5 |
343
+ | Puma | Fixed (3) | Fixed (3) | 3.49k ±6.5% | 11.7% higher | 51.75 | 2.8% higher | 2.319 | 383.4 |
344
+ | Puma | Scaling (3–16) | Scaling (3–16) | 3.00k ±3.8% | 0.5% higher | 64.39 | 26.8% higher | 2.224 | 470.8 |
345
+ | Falcon | Fibers | Fixed (3) | 3.17k ±0.2% | 1.7% higher | 67.10 | 33.3% higher | 2.763 | 529.6 |
346
+ | Falcon | Fibers | Scaling (3–16) | 3.17k ±0.2% | 6.1% higher | 67.10 | 32.1% higher | 2.763 | 529.6 |
332
347
 
333
348
  ### CPU over HTTP/2
334
349
 
335
350
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
336
351
  | ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
337
- | Raptor | Fixed (3) | - | 3.20k ±2.9% | - | 72.40 | - | 2.401 | 621.4 |
338
- | Raptor | Scaling (3–16) | - | 3.11k ±1.4% | - | 75.04 | - | 2.403 | 597.8 |
339
- | Falcon | Fibers | Fixed (3) | 2.45k ±20.8% | 23.4% lower | 147.43 | 103.6% higher | 2.616 | 567.1 |
340
- | Falcon | Fibers | Scaling (3–16) | 2.45k ±20.8% | 21.2% lower | 147.43 | 96.5% higher | 2.616 | 567.1 |
352
+ | Raptor | Fixed (3) | - | 3.32k ±3.7% | - | 70.25 | - | 2.374 | 583.2 |
353
+ | Raptor | Scaling (3–16) | - | 3.31k ±0.9% | - | 60.05 | - | 2.347 | 562.3 |
354
+ | Falcon | Fibers | Fixed (3) | 2.36k ±18.9% | 29.0% lower | 127.17 | 81.0% higher | 2.399 | 561.8 |
355
+ | Falcon | Fibers | Scaling (3–16) | 2.36k ±18.9% | 28.8% lower | 127.17 | 111.8% higher | 2.399 | 561.8 |
341
356
 
342
357
  ### 64 KiB body over HTTP/1.1 keep-alive
343
358
 
344
359
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
345
360
  | ------ | -------------- | --------------- | ------------- | --------------- | ------ | ------------- | ---------- | ------- |
346
- | Raptor | Scaling (3–16) | - | 96.95k ±0.5% | - | 3.59 | - | 0.051 | 554.2 |
347
- | Puma | Scaling (3–16) | Scaling (3–16) | 90.31k ±0.5% | 6.8% lower | 3.56 | 0.9% lower | 0.052 | 1447.0 |
348
- | Falcon | Fibers | Scaling (3–16) | 106.79k ±0.8% | 10.2% higher | 3.70 | 3.0% higher | 0.050 | 642.1 |
361
+ | Raptor | Scaling (3–16) | - | 94.57k ±1.5% | - | 3.70 | - | 0.051 | 592.0 |
362
+ | Puma | Scaling (3–16) | Scaling (3–16) | 88.51k ±0.7% | 6.4% lower | 3.67 | 0.6% lower | 0.054 | 1201.7 |
363
+ | Falcon | Fibers | Scaling (3–16) | 103.00k ±5.1% | 8.9% higher | 3.84 | 3.9% higher | 0.051 | 341.1 |
349
364
 
350
365
  ### IO + SSE (native) over HTTP/1.1 keep-alive
351
366
 
352
367
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
353
368
  | ------------- | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
354
- | Raptor | Fixed (3) | - | 3.43k ±8.5% | - | 35.14 | - | 2.448 | 378.5 |
355
- | Raptor | Scaling (3–16) | - | 7.58k ±1.5% | - | 23.79 | - | 0.485 | 373.3 |
356
- | Puma | Fixed (3) | Fixed (3) | 0.34k ±6.3% | 90.0% lower | 327.51 | 832.1% higher | 1.744 | 281.0 |
357
- | Puma | Scaling (3–16) | Scaling (3–16) | 7.38k ±1.4% | 2.6% lower | 24.55 | 3.2% higher | 0.443 | 339.9 |
358
- | Falcon | Fibers | Fixed (3) | 7.51k ±4.0% | 118.8% higher | 24.31 | 30.8% lower | 0.413 | 371.0 |
359
- | Falcon | Fibers | Scaling (3–16) | 7.51k ±4.0% | 1.0% lower | 24.31 | 2.2% higher | 0.413 | 371.0 |
360
- | Raptor (enum) | Fixed (3) | - | 0.89k ±3.3% | - | 58.38 | - | 8.363 | 356.0 |
369
+ | Raptor | Fixed (3) | - | 2.74k ±6.2% | - | 59.25 | - | 2.298 | 341.5 |
370
+ | Raptor | Scaling (3–16) | - | 7.41k ±1.2% | - | 24.53 | - | 0.471 | 345.4 |
371
+ | Puma | Fixed (3) | Fixed (3) | 0.34k ±5.4% | 87.5% lower | 361.94 | 510.8% higher | 1.715 | 263.9 |
372
+ | Puma | Scaling (3–16) | Scaling (3–16) | 7.34k ±1.0% | 1.0% lower | 24.70 | 0.7% higher | 0.430 | 310.9 |
373
+ | Falcon | Fibers | Fixed (3) | 7.30k ±1.0% | 165.9% higher | 24.88 | 58.0% lower | 0.379 | 356.6 |
374
+ | Falcon | Fibers | Scaling (3–16) | 7.30k ±1.0% | 1.6% lower | 24.88 | 1.5% higher | 0.379 | 356.6 |
375
+ | Raptor (enum) | Fixed (3) | - | 0.88k ±0.3% | - | 66.74 | - | 8.142 | 382.6 |
361
376
 
362
- Puma, Fixed (3) had 34 timeouts, 1 stalled stream across all samples.
377
+ Puma, Fixed (3) had 37 timeouts, 1 stalled stream across all samples.
363
378
 
364
- Raptor (enum), Fixed (3) had 24 timeouts across all samples.
379
+ Raptor (enum), Fixed (3) had 16 timeouts across all samples.
365
380
 
366
- > ruby 4.1.0dev (2026-11-07T16:07:23Z HEAD e67e4a6960) +YJIT +PRISM [aarch64-linux]
381
+ > ruby 4.1.0dev (2026-11-10T00:02:04Z HEAD 7a07e456e4) +YJIT +PRISM [aarch64-linux]
367
382
  > 10 workers, 120 HTTP/1.1 client connections, 40 HTTP/2 connections × 3 streams.
368
383
 
369
384
  Run [bin/benchmark](bin/benchmark) to reproduce.
data/Rakefile CHANGED
@@ -20,6 +20,13 @@ Rake::ExtensionTask.new("raptor_native", GEMSPEC) do |ext|
20
20
  ext.lib_dir = "lib/raptor"
21
21
  end
22
22
 
23
+ namespace :test do
24
+ desc "Run Rails system tests"
25
+ task rails: :compile do
26
+ ruby "-Itest", "test/system/rails.rb"
27
+ end
28
+ end
29
+
23
30
  namespace :bpf do
24
31
  task :compile do
25
32
  if RUBY_PLATFORM.include?("linux")
@@ -41,6 +48,6 @@ namespace :rbs do
41
48
  end
42
49
  end
43
50
 
44
- task default: %i[clobber compile bpf:compile rbs:generate test]
45
- task build: %i[clobber compile rbs:generate]
46
- task ci: %i[clobber compile test]
51
+ task default: [:clobber, :compile, :"bpf:compile", :"rbs:generate", :test]
52
+ task build: [:clobber, :compile, :"rbs:generate"]
53
+ task ci: [:clobber, :compile, :test]
@@ -12,24 +12,31 @@ module Rackup
12
12
  Port: 9292
13
13
  }.freeze
14
14
 
15
- # Boots a Raptor cluster serving the given Rack application.
15
+ # Serves the given Rack application using the handler options.
16
16
  #
17
17
  # @param app [#call] the Rack application to serve
18
18
  # @param options [Hash] handler options provided by Rackup or the host
19
- # @yield before the cluster starts running
20
- # @yieldparam cluster [::Raptor::Cluster] the cluster instance
19
+ # @yield before the server starts running
20
+ # @yieldparam server [::Raptor::Cluster, ::Raptor::Embedded] the server instance
21
21
  # @return [void]
22
22
  #
23
- # @rbs (^(Hash[String, untyped]) -> [Integer, Hash[String, String | Array[String]], untyped] app, **untyped options) { (::Raptor::Cluster) -> void } -> void
23
+ # @rbs (^(Hash[String, untyped]) -> [Integer, Hash[String, String | Array[String]], untyped] app, **untyped options) { (::Raptor::Cluster | ::Raptor::Embedded) -> void } -> void
24
24
  def self.run(app, **options)
25
25
  require_relative "../../raptor/cli"
26
26
  require_relative "../../raptor/cluster"
27
+ require_relative "../../raptor/embedded"
27
28
 
28
- cluster = ::Raptor::Cluster.new(build_cluster_options(app, options))
29
+ configuration = build_options(app, options)
30
+ server = if configuration[:workers].zero?
31
+ configuration.delete(:app)
32
+ ::Raptor::Embedded.new(app, **configuration)
33
+ else
34
+ ::Raptor::Cluster.new(configuration)
35
+ end
29
36
 
30
- yield cluster if block_given?
37
+ yield server if block_given?
31
38
 
32
- cluster.run
39
+ server.run
33
40
  end
34
41
 
35
42
  # Returns the handler-specific options surfaced by `rackup --help`.
@@ -41,24 +48,24 @@ module Rackup
41
48
  {
42
49
  "Host=HOST" => "Hostname to listen on (default: #{DEFAULT_OPTIONS[:Host]})",
43
50
  "Port=PORT" => "Port to listen on (default: #{DEFAULT_OPTIONS[:Port]})",
44
- "Workers=NUM" => "Number of worker processes (default: available processor count)",
51
+ "Workers=NUM" => "Number of worker processes, or 0 for in-process serving (default: available processor count)",
45
52
  "Threads=NUM" => "Number of threads per worker (default: 3)",
46
53
  "MaxThreads=NUM" => "Maximum threads per worker (`unlimited` for no limit; default: unlimited)",
47
54
  "Config=PATH" => "Load additional configuration from PATH"
48
55
  }
49
56
  end
50
57
 
51
- # Builds a Raptor cluster options hash from Rack handler options.
58
+ # Builds Raptor server configuration from Rack handler options.
52
59
  #
53
60
  # Options not explicitly supplied by the user (per the `:user_supplied_options`
54
61
  # key) are treated as host-provided defaults.
55
62
  #
56
63
  # @param app [#call] the Rack application to serve
57
64
  # @param options [Hash] handler options provided by Rackup or the host
58
- # @return [Hash{Symbol => untyped}] cluster configuration
65
+ # @return [Hash{Symbol => untyped}] server configuration
59
66
  #
60
67
  # @rbs (^(Hash[String, untyped]) -> [Integer, Hash[String, String | Array[String]], untyped] app, Hash[Symbol, untyped] options) -> Hash[Symbol, untyped]
61
- def self.build_cluster_options(app, options)
68
+ def self.build_options(app, options)
62
69
  defaults = DEFAULT_OPTIONS.dup
63
70
 
64
71
  if (user_supplied_options = options.delete(:user_supplied_options))
@@ -116,7 +123,7 @@ module Rackup
116
123
  result[:on_error] = config[:on_error] if config.key?(:on_error)
117
124
  config.merge(result)
118
125
  end
119
- private_class_method :build_cluster_options
126
+ private_class_method :build_options
120
127
  end
121
128
 
122
129
  register :raptor, Raptor