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 +4 -4
- data/.buildkite/pipeline.yml +34 -8
- data/AGENTS.md +25 -0
- data/CHANGELOG.md +35 -25
- data/README.md +82 -67
- data/Rakefile +10 -3
- data/lib/rackup/handler/raptor.rb +19 -12
- data/lib/raptor/binder.rb +17 -5
- data/lib/raptor/cli.rb +32 -2
- data/lib/raptor/cluster.rb +62 -141
- data/lib/raptor/embedded.rb +225 -0
- data/lib/raptor/plugin.rb +1 -0
- data/lib/raptor/reactor.rb +21 -4
- data/lib/raptor/version.rb +1 -1
- data/lib/raptor/worker.rb +200 -0
- data/sig/generated/rackup/handler/raptor.rbs +8 -8
- data/sig/generated/raptor/cli.rbs +5 -0
- data/sig/generated/raptor/cluster.rbs +22 -35
- data/sig/generated/raptor/embedded.rbs +93 -0
- data/sig/generated/raptor/plugin.rbs +1 -0
- data/sig/generated/raptor/worker.rbs +77 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f72ac9941a9da99f3fe49f3464ac925ff6304cf196836502a480220eb99d48f
|
|
4
|
+
data.tar.gz: 7a72e415e3663c54ac3c4f2fcfd13481356b3357693298c082f2b2eda3727182
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf330c4d82552ee29b56b4bf0998355d3faad012147a5d34b9ade39d1f333ef4cc46b9d0e81c9b96516462fa920c3efe0c849fb716cdb158261cc3a6aff5014c
|
|
7
|
+
data.tar.gz: 9ff03e07f24109d0c1a0af66c309b6a49fa8f45c6db0aecd0a1c8507082d2e558a67bf72c01bf6c59f83c2aa379a41e8046f2b91f2d17deb8ecd59c5e44b162f
|
data/.buildkite/pipeline.yml
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
-
|
|
15
|
+
- Use `io-event` for reactor I/O readiness
|
|
6
16
|
|
|
7
17
|
## [0.24.0] - 2026-11-08
|
|
8
18
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- Prefer
|
|
12
|
-
- Reject empty
|
|
13
|
-
- Preserve request
|
|
14
|
-
- Trim leading tabs
|
|
15
|
-
- Honour HTTP/1 Connection token lists
|
|
16
|
-
-
|
|
17
|
-
- Close HTTP/2 response bodies when writing fails
|
|
18
|
-
- Bound HTTP/1 chunk size lines and trailers
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
- Add plugins
|
|
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
|
|
101
|
-
-
|
|
102
|
-
- Pass
|
|
103
|
-
- Add
|
|
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
|
-
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
171
|
-
|
|
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.
|
|
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.
|
|
282
|
-
| Raptor | Scaling (3–16) | - | 8.
|
|
283
|
-
| Puma | Fixed (3) | Fixed (3) | 1.53k ±
|
|
284
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 8.
|
|
285
|
-
| Falcon | Fibers | Fixed (3) |
|
|
286
|
-
| Falcon | Fibers | Scaling (3–16) |
|
|
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.
|
|
293
|
-
| Raptor | Scaling (3–16) | - | 7.
|
|
294
|
-
| Raptor | Fixed (16) | - | 7.
|
|
295
|
-
| Puma | Fixed (3) | Fixed (3) | 1.
|
|
296
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 7.
|
|
297
|
-
| Puma | Fixed (16) | Fixed (16) | 7.
|
|
298
|
-
| Falcon | Fibers | Fixed (3) | 7.
|
|
299
|
-
| Falcon | Fibers | Scaling (3–16) | 7.
|
|
300
|
-
| Falcon | Fibers | Fixed (16) | 7.
|
|
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
|
|
305
|
-
| ------ | -------------- | --------------- |
|
|
306
|
-
| Raptor | Fixed (3) | - | 1.
|
|
307
|
-
| Raptor | Scaling (3–16) | - |
|
|
308
|
-
| Falcon | Fibers | Fixed (3) | 7.
|
|
309
|
-
| Falcon | Fibers | Scaling (3–16) | 7.
|
|
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.
|
|
316
|
-
| Raptor | Scaling (3–16) | - | 3.
|
|
317
|
-
| Puma | Fixed (3) | Fixed (3) | 3.
|
|
318
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 3.
|
|
319
|
-
| Falcon | Fibers | Fixed (3) | 3.
|
|
320
|
-
| Falcon | Fibers | Scaling (3–16) | 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.
|
|
327
|
-
| Raptor | Scaling (3–16) | - | 2.
|
|
328
|
-
| Puma | Fixed (3) | Fixed (3) | 3.
|
|
329
|
-
| Puma | Scaling (3–16) | Scaling (3–16) |
|
|
330
|
-
| Falcon | Fibers | Fixed (3) | 3.
|
|
331
|
-
| Falcon | Fibers | Scaling (3–16) | 3.
|
|
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.
|
|
338
|
-
| Raptor | Scaling (3–16) | - | 3.
|
|
339
|
-
| Falcon | Fibers | Fixed (3) | 2.
|
|
340
|
-
| Falcon | Fibers | Scaling (3–16) | 2.
|
|
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) | - |
|
|
347
|
-
| Puma | Scaling (3–16) | Scaling (3–16) |
|
|
348
|
-
| Falcon | Fibers | Scaling (3–16) |
|
|
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) | - |
|
|
355
|
-
| Raptor | Scaling (3–16) | - | 7.
|
|
356
|
-
| Puma | Fixed (3) | Fixed (3) | 0.34k ±
|
|
357
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 7.
|
|
358
|
-
| Falcon | Fibers | Fixed (3) | 7.
|
|
359
|
-
| Falcon | Fibers | Scaling (3–16) | 7.
|
|
360
|
-
| Raptor (enum) | Fixed (3) | - | 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
|
|
377
|
+
Puma, Fixed (3) had 37 timeouts, 1 stalled stream across all samples.
|
|
363
378
|
|
|
364
|
-
Raptor (enum), Fixed (3) had
|
|
379
|
+
Raptor (enum), Fixed (3) had 16 timeouts across all samples.
|
|
365
380
|
|
|
366
|
-
> ruby 4.1.0dev (2026-11-
|
|
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:
|
|
45
|
-
task build:
|
|
46
|
-
task ci:
|
|
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
|
-
#
|
|
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
|
|
20
|
-
# @yieldparam
|
|
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
|
-
|
|
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
|
|
37
|
+
yield server if block_given?
|
|
31
38
|
|
|
32
|
-
|
|
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
|
|
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}]
|
|
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.
|
|
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 :
|
|
126
|
+
private_class_method :build_options
|
|
120
127
|
end
|
|
121
128
|
|
|
122
129
|
register :raptor, Raptor
|