raptor 0.28.0 → 0.29.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 +8 -0
- data/CHANGELOG.md +5 -0
- data/README.md +53 -53
- data/lib/raptor/cluster.rb +2 -1
- data/lib/raptor/control_server.rb +5 -2
- data/lib/raptor/reactor.rb +15 -8
- data/lib/raptor/version.rb +1 -1
- data/lib/raptor/worker.rb +10 -8
- data/sig/generated/raptor/cluster.rbs +1 -1
- data/sig/generated/raptor/control_server.rbs +3 -1
- data/sig/generated/raptor/reactor.rbs +4 -5
- data/sig/generated/raptor/worker.rbs +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6a6d47ad196a81ed02688a02354215ff73727c992215403d46df7524b16437f
|
|
4
|
+
data.tar.gz: 994e7060d8278195ff9af6bcd2f86f3bb0af3335626c40475311ab275351d3cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7febcca4e7599b65ba6c60b193f957a3fa9423c1269517037bbf32e6b01e9b06284dc6072e39d19b2ccf6f00546fea94b37e096ba24ba003d008a2ba0e2acce4
|
|
7
|
+
data.tar.gz: 7761be422a232b755f930ce527d54975c9dc2c4d5d99c6f792226e1c745612d2360b26d54f79f6276f0c6e0d6647a3f3f87b4fe5ce6cf4215892eb5402b61c0e
|
data/.buildkite/pipeline.yml
CHANGED
|
@@ -49,6 +49,7 @@ steps:
|
|
|
49
49
|
- bundle exec rake ci
|
|
50
50
|
|
|
51
51
|
- label: ":ruby: Ruby head"
|
|
52
|
+
priority: -1
|
|
52
53
|
soft_fail: true
|
|
53
54
|
image: "rubylang/ruby:master-dev"
|
|
54
55
|
commands:
|
|
@@ -58,6 +59,7 @@ steps:
|
|
|
58
59
|
- bundle exec rake ci
|
|
59
60
|
|
|
60
61
|
- label: ":ruby: Ruby head +YJIT"
|
|
62
|
+
priority: -1
|
|
61
63
|
soft_fail: true
|
|
62
64
|
image: "rubylang/ruby:master-dev"
|
|
63
65
|
env:
|
|
@@ -69,6 +71,7 @@ steps:
|
|
|
69
71
|
- bundle exec rake ci
|
|
70
72
|
|
|
71
73
|
- label: ":ruby: Ruby head +GC.stress"
|
|
74
|
+
priority: -1
|
|
72
75
|
soft_fail: true
|
|
73
76
|
image: "rubylang/ruby:master-dev"
|
|
74
77
|
env:
|
|
@@ -80,6 +83,7 @@ steps:
|
|
|
80
83
|
- bundle exec rake ci
|
|
81
84
|
|
|
82
85
|
- label: ":ruby: Ruby head +YJIT +GC.stress"
|
|
86
|
+
priority: -1
|
|
83
87
|
soft_fail: true
|
|
84
88
|
image: "rubylang/ruby:master-dev"
|
|
85
89
|
env:
|
|
@@ -161,6 +165,7 @@ steps:
|
|
|
161
165
|
- bundle exec rake ci
|
|
162
166
|
|
|
163
167
|
- label: ":ruby: Ruby head"
|
|
168
|
+
priority: -1
|
|
164
169
|
soft_fail: true
|
|
165
170
|
agents:
|
|
166
171
|
queue: macos
|
|
@@ -174,6 +179,7 @@ steps:
|
|
|
174
179
|
- bundle exec rake ci
|
|
175
180
|
|
|
176
181
|
- label: ":ruby: Ruby head +YJIT"
|
|
182
|
+
priority: -1
|
|
177
183
|
soft_fail: true
|
|
178
184
|
agents:
|
|
179
185
|
queue: macos
|
|
@@ -189,6 +195,7 @@ steps:
|
|
|
189
195
|
- bundle exec rake ci
|
|
190
196
|
|
|
191
197
|
- label: ":ruby: Ruby head +GC.stress"
|
|
198
|
+
priority: -1
|
|
192
199
|
soft_fail: true
|
|
193
200
|
agents:
|
|
194
201
|
queue: macos
|
|
@@ -204,6 +211,7 @@ steps:
|
|
|
204
211
|
- bundle exec rake ci
|
|
205
212
|
|
|
206
213
|
- label: ":ruby: Ruby head +YJIT +GC.stress"
|
|
214
|
+
priority: -1
|
|
207
215
|
soft_fail: true
|
|
208
216
|
agents:
|
|
209
217
|
queue: macos
|
data/CHANGELOG.md
CHANGED
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.29.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
|
|
@@ -281,7 +281,7 @@ statistics. The exporter handles worker forks and restart cleanup automatically.
|
|
|
281
281
|
|
|
282
282
|
## (Micro) Benchmarks
|
|
283
283
|
|
|
284
|
-
Raptor 0.
|
|
284
|
+
Raptor 0.29.0 vs Puma 8.0.2 vs Falcon 0.57.0. Each case has 3 fresh-process samples, interleaved in seeded shuffled
|
|
285
285
|
rounds. Each sample warms up for 3s and measures for 15s. Metrics are independent medians. ± is (max − min) / 2 /
|
|
286
286
|
median, not a confidence interval. Failure counts below each table sum all samples, so a failed run cannot disappear in
|
|
287
287
|
a median. Throughput counts successful ordinary requests only.
|
|
@@ -309,90 +309,90 @@ accounting for shared pages instead of counting them fully in every worker.
|
|
|
309
309
|
|
|
310
310
|
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
311
311
|
| ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
|
|
312
|
-
| Raptor | Fixed (3) | - | 3.
|
|
313
|
-
| Raptor | Scaling (3–16) | - | 8.23k ±0.
|
|
314
|
-
| Puma | Fixed (3) | Fixed (3) | 1.
|
|
315
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 8.15k ±
|
|
316
|
-
| Falcon | Fibers | Fixed (3) | 10.
|
|
317
|
-
| Falcon | Fibers | Scaling (3–16) | 10.
|
|
312
|
+
| Raptor | Fixed (3) | - | 3.35k ±1.4% | - | 47.84 | - | 2.452 | 334.1 |
|
|
313
|
+
| Raptor | Scaling (3–16) | - | 8.23k ±0.7% | - | 22.03 | - | 0.467 | 320.5 |
|
|
314
|
+
| Puma | Fixed (3) | Fixed (3) | 1.41k ±1.4% | 57.9% lower | 133.47 | 179.0% higher | 0.765 | 272.0 |
|
|
315
|
+
| Puma | Scaling (3–16) | Scaling (3–16) | 8.15k ±0.6% | 0.9% lower | 22.20 | 0.7% higher | 0.462 | 317.6 |
|
|
316
|
+
| Falcon | Fibers | Fixed (3) | 10.90k ±0.8% | 225.1% higher | 15.68 | 67.2% lower | 0.445 | 467.5 |
|
|
317
|
+
| Falcon | Fibers | Scaling (3–16) | 10.90k ±0.8% | 32.5% higher | 15.68 | 28.8% lower | 0.445 | 467.5 |
|
|
318
318
|
|
|
319
319
|
### IO over HTTP/1.1 keep-alive
|
|
320
320
|
|
|
321
321
|
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
322
322
|
| ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
|
|
323
|
-
| Raptor | Fixed (3) | - | 3.
|
|
324
|
-
| Raptor | Scaling (3–16) | - | 7.38k ±0.
|
|
325
|
-
| Raptor | Fixed (16) | - | 7.
|
|
326
|
-
| Puma | Fixed (3) | Fixed (3) | 1.
|
|
327
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 7.
|
|
328
|
-
| Puma | Fixed (16) | Fixed (16) | 7.
|
|
329
|
-
| Falcon | Fibers | Fixed (3) | 7.
|
|
330
|
-
| Falcon | Fibers | Scaling (3–16) | 7.
|
|
331
|
-
| Falcon | Fibers | Fixed (16) | 7.
|
|
323
|
+
| Raptor | Fixed (3) | - | 3.20k ±9.2% | - | 50.70 | - | 2.390 | 345.1 |
|
|
324
|
+
| Raptor | Scaling (3–16) | - | 7.38k ±0.6% | - | 24.60 | - | 0.463 | 342.4 |
|
|
325
|
+
| Raptor | Fixed (16) | - | 7.52k ±0.0% | - | 24.18 | - | 0.457 | 338.3 |
|
|
326
|
+
| Puma | Fixed (3) | Fixed (3) | 1.39k ±1.4% | 56.7% lower | 111.46 | 119.8% higher | 0.734 | 282.1 |
|
|
327
|
+
| Puma | Scaling (3–16) | Scaling (3–16) | 7.49k ±0.4% | 1.6% higher | 24.20 | 1.6% lower | 0.439 | 312.4 |
|
|
328
|
+
| Puma | Fixed (16) | Fixed (16) | 7.57k ±0.9% | 0.6% higher | 24.10 | 0.3% lower | 0.429 | 318.1 |
|
|
329
|
+
| Falcon | Fibers | Fixed (3) | 7.44k ±1.4% | 132.3% higher | 24.53 | 51.6% lower | 0.384 | 334.2 |
|
|
330
|
+
| Falcon | Fibers | Scaling (3–16) | 7.44k ±1.4% | 0.8% higher | 24.53 | 0.3% lower | 0.384 | 334.2 |
|
|
331
|
+
| Falcon | Fibers | Fixed (16) | 7.44k ±1.4% | 1.1% lower | 24.53 | 1.5% higher | 0.384 | 334.2 |
|
|
332
332
|
|
|
333
333
|
### IO over HTTP/2
|
|
334
334
|
|
|
335
|
-
| Server | Mode | Raptor baseline | req/s
|
|
336
|
-
| ------ | -------------- | --------------- |
|
|
337
|
-
| Raptor | Fixed (3) | - | 1.
|
|
338
|
-
| Raptor | Scaling (3–16) | - |
|
|
339
|
-
| Falcon | Fibers | Fixed (3) | 7.
|
|
340
|
-
| Falcon | Fibers | Scaling (3–16) | 7.
|
|
335
|
+
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
336
|
+
| ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
|
|
337
|
+
| Raptor | Fixed (3) | - | 1.55k ±0.8% | - | 120.06 | - | 0.842 | 418.9 |
|
|
338
|
+
| Raptor | Scaling (3–16) | - | 8.46k ±3.7% | - | 21.77 | - | 0.553 | 928.8 |
|
|
339
|
+
| Falcon | Fibers | Fixed (3) | 7.18k ±4.2% | 363.9% higher | 26.01 | 78.3% lower | 0.435 | 529.6 |
|
|
340
|
+
| Falcon | Fibers | Scaling (3–16) | 7.18k ±4.2% | 15.1% lower | 26.01 | 19.5% higher | 0.435 | 529.6 |
|
|
341
341
|
|
|
342
342
|
### CPU over HTTP/1.1
|
|
343
343
|
|
|
344
344
|
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
345
345
|
| ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
|
|
346
|
-
| Raptor | Fixed (3) | - | 3.
|
|
347
|
-
| Raptor | Scaling (3–16) | - | 3.
|
|
348
|
-
| Puma | Fixed (3) | Fixed (3) | 3.
|
|
349
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 3.
|
|
350
|
-
| Falcon | Fibers | Fixed (3) | 3.
|
|
351
|
-
| Falcon | Fibers | Scaling (3–16) | 3.
|
|
346
|
+
| Raptor | Fixed (3) | - | 3.33k ±0.3% | - | 68.91 | - | 2.570 | 507.8 |
|
|
347
|
+
| Raptor | Scaling (3–16) | - | 3.39k ±3.0% | - | 62.76 | - | 2.430 | 489.6 |
|
|
348
|
+
| Puma | Fixed (3) | Fixed (3) | 3.27k ±2.3% | 2.0% lower | 56.55 | 17.9% lower | 2.496 | 443.3 |
|
|
349
|
+
| Puma | Scaling (3–16) | Scaling (3–16) | 3.27k ±4.6% | 3.7% lower | 48.35 | 23.0% lower | 2.200 | 439.0 |
|
|
350
|
+
| Falcon | Fibers | Fixed (3) | 3.47k ±0.7% | 4.1% higher | 47.50 | 31.1% lower | 2.473 | 421.1 |
|
|
351
|
+
| Falcon | Fibers | Scaling (3–16) | 3.47k ±0.7% | 2.2% higher | 47.50 | 24.3% lower | 2.473 | 421.1 |
|
|
352
352
|
|
|
353
353
|
### CPU over HTTP/1.1 keep-alive
|
|
354
354
|
|
|
355
355
|
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
356
356
|
| ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
|
|
357
|
-
| Raptor | Fixed (3) | - | 3.
|
|
358
|
-
| Raptor | Scaling (3–16) | - | 3.
|
|
359
|
-
| Puma | Fixed (3) | Fixed (3) | 3.
|
|
360
|
-
| Puma | Scaling (3–16) | Scaling (3–16) |
|
|
361
|
-
| Falcon | Fibers | Fixed (3) | 3.
|
|
362
|
-
| Falcon | Fibers | Scaling (3–16) | 3.
|
|
357
|
+
| Raptor | Fixed (3) | - | 3.12k ±0.4% | - | 48.97 | - | 2.570 | 476.6 |
|
|
358
|
+
| Raptor | Scaling (3–16) | - | 3.02k ±2.0% | - | 50.35 | - | 2.593 | 504.5 |
|
|
359
|
+
| Puma | Fixed (3) | Fixed (3) | 3.51k ±0.9% | 12.5% higher | 51.41 | 5.0% higher | 2.346 | 381.8 |
|
|
360
|
+
| Puma | Scaling (3–16) | Scaling (3–16) | 2.94k ±4.4% | 2.8% lower | 64.76 | 28.6% higher | 2.243 | 469.3 |
|
|
361
|
+
| Falcon | Fibers | Fixed (3) | 3.13k ±0.6% | 0.1% higher | 68.29 | 39.4% higher | 2.806 | 536.3 |
|
|
362
|
+
| Falcon | Fibers | Scaling (3–16) | 3.13k ±0.6% | 3.4% higher | 68.29 | 35.6% higher | 2.806 | 536.3 |
|
|
363
363
|
|
|
364
364
|
### CPU over HTTP/2
|
|
365
365
|
|
|
366
366
|
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
367
367
|
| ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
|
|
368
|
-
| Raptor | Fixed (3) | - | 3.
|
|
369
|
-
| Raptor | Scaling (3–16) | - | 3.
|
|
370
|
-
| Falcon | Fibers | Fixed (3) | 2.
|
|
371
|
-
| Falcon | Fibers | Scaling (3–16) | 2.
|
|
368
|
+
| Raptor | Fixed (3) | - | 3.45k ±3.9% | - | 67.62 | - | 2.425 | 581.6 |
|
|
369
|
+
| Raptor | Scaling (3–16) | - | 3.35k ±1.6% | - | 64.00 | - | 2.409 | 584.6 |
|
|
370
|
+
| Falcon | Fibers | Fixed (3) | 2.71k ±28.6% | 21.6% lower | 151.92 | 124.7% higher | 2.494 | 575.5 |
|
|
371
|
+
| Falcon | Fibers | Scaling (3–16) | 2.71k ±28.6% | 19.3% lower | 151.92 | 137.4% higher | 2.494 | 575.5 |
|
|
372
372
|
|
|
373
373
|
### 64 KiB body over HTTP/1.1 keep-alive
|
|
374
374
|
|
|
375
|
-
| Server | Mode | Raptor baseline | req/s
|
|
376
|
-
| ------ | -------------- | --------------- |
|
|
377
|
-
| Raptor | Scaling (3–16) | - |
|
|
378
|
-
| Puma | Scaling (3–16) | Scaling (3–16) |
|
|
379
|
-
| Falcon | Fibers | Scaling (3–16) |
|
|
375
|
+
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
376
|
+
| ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
|
|
377
|
+
| Raptor | Scaling (3–16) | - | 93.53k ±1.0% | - | 3.71 | - | 0.052 | 501.2 |
|
|
378
|
+
| Puma | Scaling (3–16) | Scaling (3–16) | 84.26k ±0.5% | 9.9% lower | 3.94 | 6.1% higher | 0.056 | 1210.8 |
|
|
379
|
+
| Falcon | Fibers | Scaling (3–16) | 97.44k ±1.1% | 4.2% higher | 3.96 | 6.7% higher | 0.053 | 341.9 |
|
|
380
380
|
|
|
381
381
|
### IO + SSE (native) over HTTP/1.1 keep-alive
|
|
382
382
|
|
|
383
383
|
| Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
|
|
384
384
|
| ------------- | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
|
|
385
|
-
| Raptor | Fixed (3) | - | 3.
|
|
386
|
-
| Raptor | Scaling (3–16) | - | 7.
|
|
387
|
-
| Puma | Fixed (3) | Fixed (3) | 0.34k ±
|
|
388
|
-
| Puma | Scaling (3–16) | Scaling (3–16) | 7.
|
|
389
|
-
| Falcon | Fibers | Fixed (3) | 7.
|
|
390
|
-
| Falcon | Fibers | Scaling (3–16) | 7.
|
|
391
|
-
| Raptor (enum) | Fixed (3) | - | 0.88k ±
|
|
385
|
+
| Raptor | Fixed (3) | - | 3.16k ±12.5% | - | 50.55 | - | 2.374 | 347.8 |
|
|
386
|
+
| Raptor | Scaling (3–16) | - | 7.42k ±1.5% | - | 24.45 | - | 0.470 | 341.1 |
|
|
387
|
+
| Puma | Fixed (3) | Fixed (3) | 0.34k ±5.3% | 89.3% lower | 328.18 | 549.2% higher | 1.712 | 243.8 |
|
|
388
|
+
| Puma | Scaling (3–16) | Scaling (3–16) | 7.44k ±3.6% | 0.2% higher | 24.32 | 0.5% lower | 0.435 | 311.0 |
|
|
389
|
+
| Falcon | Fibers | Fixed (3) | 7.58k ±4.2% | 140.0% higher | 24.24 | 52.0% lower | 0.385 | 335.5 |
|
|
390
|
+
| Falcon | Fibers | Scaling (3–16) | 7.58k ±4.2% | 2.2% higher | 24.24 | 0.9% lower | 0.385 | 335.5 |
|
|
391
|
+
| Raptor (enum) | Fixed (3) | - | 0.88k ±4.2% | - | 63.87 | - | 8.136 | 330.3 |
|
|
392
392
|
|
|
393
|
-
Puma, Fixed (3) had
|
|
393
|
+
Puma, Fixed (3) had 57 timeouts, 1 stalled stream across all samples.
|
|
394
394
|
|
|
395
|
-
Raptor (enum), Fixed (3) had
|
|
395
|
+
Raptor (enum), Fixed (3) had 8 timeouts, 1 stalled stream across all samples.
|
|
396
396
|
|
|
397
397
|
> ruby 4.1.0dev (2026-11-10T00:02:04Z HEAD 7a07e456e4) +YJIT +PRISM [aarch64-linux]
|
|
398
398
|
> 10 workers, 120 HTTP/1.1 client connections, 40 HTTP/2 connections × 3 streams.
|
data/lib/raptor/cluster.rb
CHANGED
|
@@ -151,7 +151,7 @@ module Raptor
|
|
|
151
151
|
# @option options [Hash] :http2 HTTP/2-specific settings
|
|
152
152
|
# @option options [Integer] :worker_boot_timeout seconds to wait for a worker to finish booting before killing it
|
|
153
153
|
# @option options [Integer] :worker_timeout seconds to wait for a booted worker to check in before killing it
|
|
154
|
-
# @option options [Integer] :worker_drain_timeout seconds
|
|
154
|
+
# @option options [Integer] :worker_drain_timeout total seconds to drain application work and detached responses
|
|
155
155
|
# @option options [Integer] :worker_shutdown_timeout seconds to wait for graceful worker exit before force-killing
|
|
156
156
|
# @option options [Integer, Array<Integer>, nil] :refork_after request-count threshold(s) at which a warm worker is promoted to a fork source for phased refork; nil or 0 disables. Requires `PR_SET_CHILD_SUBREAPER` (Linux)
|
|
157
157
|
# @option options [Array<Proc>] :before_fork procs called in the master before each direct worker fork, not seed forks
|
|
@@ -872,6 +872,7 @@ module Raptor
|
|
|
872
872
|
#
|
|
873
873
|
# @rbs (Integer index, Integer phase) -> void
|
|
874
874
|
def run_worker(index, phase)
|
|
875
|
+
@control_server&.shutdown
|
|
875
876
|
@fork_w.close if @fork_w && !@fork_w.closed?
|
|
876
877
|
@resp_r.close if @resp_r && !@resp_r.closed?
|
|
877
878
|
|
|
@@ -16,6 +16,7 @@ module Raptor
|
|
|
16
16
|
# @rbs @path: String
|
|
17
17
|
# @rbs @stats: ^() -> Hash[Symbol, untyped]
|
|
18
18
|
# @rbs @server: UNIXServer?
|
|
19
|
+
# @rbs @owner_pid: Integer?
|
|
19
20
|
# @rbs @client: Atom
|
|
20
21
|
# @rbs @thread: Thread?
|
|
21
22
|
|
|
@@ -35,6 +36,7 @@ module Raptor
|
|
|
35
36
|
@path = uri.path
|
|
36
37
|
@stats = stats
|
|
37
38
|
@server = nil
|
|
39
|
+
@owner_pid = nil
|
|
38
40
|
@client = Atom.new(nil)
|
|
39
41
|
@thread = nil
|
|
40
42
|
end
|
|
@@ -47,6 +49,7 @@ module Raptor
|
|
|
47
49
|
def bind
|
|
48
50
|
remove_stale_socket
|
|
49
51
|
@server = UNIXServer.new(@path)
|
|
52
|
+
@owner_pid = Process.pid
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
# Starts serving requests in a background thread.
|
|
@@ -65,7 +68,7 @@ module Raptor
|
|
|
65
68
|
end
|
|
66
69
|
end
|
|
67
70
|
|
|
68
|
-
# Stops serving and removes the socket.
|
|
71
|
+
# Stops serving and removes the socket path only in the binding process.
|
|
69
72
|
#
|
|
70
73
|
# @return [void]
|
|
71
74
|
#
|
|
@@ -81,7 +84,7 @@ module Raptor
|
|
|
81
84
|
@server&.close
|
|
82
85
|
client.close if client.is_a?(UNIXSocket)
|
|
83
86
|
@thread&.join
|
|
84
|
-
File.delete(@path) rescue nil
|
|
87
|
+
File.delete(@path) rescue nil if Process.pid == @owner_pid
|
|
85
88
|
end
|
|
86
89
|
|
|
87
90
|
private
|
data/lib/raptor/reactor.rb
CHANGED
|
@@ -573,23 +573,30 @@ module Raptor
|
|
|
573
573
|
wakeup rescue nil
|
|
574
574
|
end
|
|
575
575
|
|
|
576
|
-
# Waits for detached responses
|
|
577
|
-
# the worker drain period.
|
|
576
|
+
# Waits for detached responses until the shared drain deadline, then cancels any still open.
|
|
578
577
|
#
|
|
579
|
-
# @param
|
|
578
|
+
# @param deadline [Float] monotonic time at which request draining ends
|
|
580
579
|
# @return [void]
|
|
581
580
|
#
|
|
582
|
-
# @rbs (
|
|
583
|
-
def drain_detached_bodies(
|
|
581
|
+
# @rbs (Float deadline) -> void
|
|
582
|
+
def drain_detached_bodies(deadline)
|
|
584
583
|
barrier = AtomicBoolean.new(false)
|
|
585
584
|
@io_queue << [:barrier, nil, barrier]
|
|
586
585
|
wakeup rescue nil
|
|
587
586
|
@io_applied.wait { barrier.true? }
|
|
588
587
|
|
|
589
|
-
|
|
590
|
-
|
|
588
|
+
remaining = deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
589
|
+
if remaining.positive?
|
|
590
|
+
begin
|
|
591
|
+
Timeout.timeout(remaining) do
|
|
592
|
+
@detached_drained.wait { @detached_count.value.zero? }
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
return
|
|
596
|
+
rescue Timeout::Error
|
|
597
|
+
end
|
|
591
598
|
end
|
|
592
|
-
|
|
599
|
+
|
|
593
600
|
@io_queue << [:cancel_all]
|
|
594
601
|
wakeup rescue nil
|
|
595
602
|
@detached_drained.wait { @detached_count.value.zero? }
|
data/lib/raptor/version.rb
CHANGED
data/lib/raptor/worker.rb
CHANGED
|
@@ -179,14 +179,16 @@ module Raptor
|
|
|
179
179
|
@reactor_thread.value if @reactor_thread && !@reactor_thread.alive?
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
# Drains
|
|
183
|
-
# A seed keeps its listeners open
|
|
182
|
+
# Drains app work and detached responses within one shared timeout, then
|
|
183
|
+
# releases the serving threads and parser Ractors. A seed keeps its listeners open.
|
|
184
184
|
#
|
|
185
185
|
# @rbs (?close_listeners: bool) -> void
|
|
186
186
|
def shutdown(close_listeners: true)
|
|
187
187
|
return if @stopped
|
|
188
188
|
|
|
189
189
|
@stopped = true
|
|
190
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + @options[:worker_drain_timeout]
|
|
191
|
+
|
|
190
192
|
begin
|
|
191
193
|
if close_listeners
|
|
192
194
|
@server&.shutdown
|
|
@@ -198,9 +200,9 @@ module Raptor
|
|
|
198
200
|
@http1&.shutdown
|
|
199
201
|
if @reactor_thread&.alive?
|
|
200
202
|
@http2&.shutdown(@reactor)
|
|
201
|
-
@reactor.drain_detached_bodies(
|
|
203
|
+
@reactor.drain_detached_bodies(deadline)
|
|
202
204
|
end
|
|
203
|
-
drain_thread_pool if @thread_pool
|
|
205
|
+
drain_thread_pool(deadline) if @thread_pool
|
|
204
206
|
@reactor&.shutdown
|
|
205
207
|
begin
|
|
206
208
|
@reactor_thread&.join
|
|
@@ -213,16 +215,16 @@ module Raptor
|
|
|
213
215
|
|
|
214
216
|
private
|
|
215
217
|
|
|
216
|
-
# Waits for app work to finish within the
|
|
218
|
+
# Waits for app work to finish within the shared drain deadline.
|
|
217
219
|
#
|
|
218
|
-
# @rbs () -> void
|
|
219
|
-
def drain_thread_pool
|
|
220
|
+
# @rbs (Float deadline) -> void
|
|
221
|
+
def drain_thread_pool(deadline)
|
|
220
222
|
drain_thread = Thread.new do
|
|
221
223
|
Thread.current.name = "Thread Pool Drain"
|
|
222
224
|
|
|
223
225
|
@thread_pool.shutdown
|
|
224
226
|
end
|
|
225
|
-
return if drain_thread.join(
|
|
227
|
+
return if drain_thread.join([deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC), 0].max)
|
|
226
228
|
|
|
227
229
|
Log.warn "Force-killing in-flight app threads after #{@options[:worker_drain_timeout]}s drain timeout"
|
|
228
230
|
@thread_pool.instance_variable_get(:@threads).each(&:kill)
|
|
@@ -180,7 +180,7 @@ module Raptor
|
|
|
180
180
|
# @option options [Hash] :http2 HTTP/2-specific settings
|
|
181
181
|
# @option options [Integer] :worker_boot_timeout seconds to wait for a worker to finish booting before killing it
|
|
182
182
|
# @option options [Integer] :worker_timeout seconds to wait for a booted worker to check in before killing it
|
|
183
|
-
# @option options [Integer] :worker_drain_timeout seconds
|
|
183
|
+
# @option options [Integer] :worker_drain_timeout total seconds to drain application work and detached responses
|
|
184
184
|
# @option options [Integer] :worker_shutdown_timeout seconds to wait for graceful worker exit before force-killing
|
|
185
185
|
# @option options [Integer, Array<Integer>, nil] :refork_after request-count threshold(s) at which a warm worker is promoted to a fork source for phased refork; nil or 0 disables. Requires `PR_SET_CHILD_SUBREAPER` (Linux)
|
|
186
186
|
# @option options [Array<Proc>] :before_fork procs called in the master before each direct worker fork, not seed forks
|
|
@@ -11,6 +11,8 @@ module Raptor
|
|
|
11
11
|
|
|
12
12
|
@server: UNIXServer?
|
|
13
13
|
|
|
14
|
+
@owner_pid: Integer?
|
|
15
|
+
|
|
14
16
|
@client: Atom
|
|
15
17
|
|
|
16
18
|
@thread: Thread?
|
|
@@ -40,7 +42,7 @@ module Raptor
|
|
|
40
42
|
# @rbs () -> void
|
|
41
43
|
def start: () -> void
|
|
42
44
|
|
|
43
|
-
# Stops serving and removes the socket.
|
|
45
|
+
# Stops serving and removes the socket path only in the binding process.
|
|
44
46
|
#
|
|
45
47
|
# @return [void]
|
|
46
48
|
#
|
|
@@ -359,14 +359,13 @@ module Raptor
|
|
|
359
359
|
# @rbs (Integer id, Integer stream_id) -> void
|
|
360
360
|
def cancel_http2_body: (Integer id, Integer stream_id) -> void
|
|
361
361
|
|
|
362
|
-
# Waits for detached responses
|
|
363
|
-
# the worker drain period.
|
|
362
|
+
# Waits for detached responses until the shared drain deadline, then cancels any still open.
|
|
364
363
|
#
|
|
365
|
-
# @param
|
|
364
|
+
# @param deadline [Float] monotonic time at which request draining ends
|
|
366
365
|
# @return [void]
|
|
367
366
|
#
|
|
368
|
-
# @rbs (
|
|
369
|
-
def drain_detached_bodies: (
|
|
367
|
+
# @rbs (Float deadline) -> void
|
|
368
|
+
def drain_detached_bodies: (Float deadline) -> void
|
|
370
369
|
|
|
371
370
|
# Stores an HTTP/2 connection's socket, state, writer, and flow
|
|
372
371
|
# controller in the reactor's per-connection maps.
|
|
@@ -73,17 +73,17 @@ module Raptor
|
|
|
73
73
|
# @rbs () -> void
|
|
74
74
|
def join: () -> void
|
|
75
75
|
|
|
76
|
-
# Drains
|
|
77
|
-
# A seed keeps its listeners open
|
|
76
|
+
# Drains app work and detached responses within one shared timeout, then
|
|
77
|
+
# releases the serving threads and parser Ractors. A seed keeps its listeners open.
|
|
78
78
|
#
|
|
79
79
|
# @rbs (?close_listeners: bool) -> void
|
|
80
80
|
def shutdown: (?close_listeners: bool) -> void
|
|
81
81
|
|
|
82
82
|
private
|
|
83
83
|
|
|
84
|
-
# Waits for app work to finish within the
|
|
84
|
+
# Waits for app work to finish within the shared drain deadline.
|
|
85
85
|
#
|
|
86
|
-
# @rbs () -> void
|
|
87
|
-
def drain_thread_pool: () -> void
|
|
86
|
+
# @rbs (Float deadline) -> void
|
|
87
|
+
def drain_thread_pool: (Float deadline) -> void
|
|
88
88
|
end
|
|
89
89
|
end
|