network_resiliency 0.7.14 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/network_resiliency/adapter/http.rb +3 -2
- data/lib/network_resiliency/version.rb +1 -1
- data/lib/network_resiliency.rb +22 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a0b6dd58bb024a582f951fd5aa8105506a8c2ffee8dddac284128a09fc844a
|
4
|
+
data.tar.gz: 7b978707f7788382cca10421190942c7395423d363eb222ddb0e5d1f5f1d734d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae2e38bf103409e575f31245634fca438992e9a50415b5c1d0bfa16e75016513a378ad2f0a9c2adef3c22a6392ef2ed1d9da67c26fff745b799bad2c83806e74
|
7
|
+
data.tar.gz: aad0e97f32f64ecb254ee5095375119bf0ff307ab578a7566280e93994c6a59ea3eb3d135a2e1a89bef4ae3f90d4ab94af149dd274594c9f1bcda76f777c2b0e
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,10 +6,11 @@ module NetworkResiliency
|
|
6
6
|
extend self
|
7
7
|
|
8
8
|
ERRORS = [
|
9
|
-
Timeout::Error,
|
10
9
|
IOError,
|
11
|
-
SystemCallError,
|
12
10
|
(OpenSSL::OpenSSLError if defined?(OpenSSL::SSL)),
|
11
|
+
SocketError,
|
12
|
+
SystemCallError,
|
13
|
+
Timeout::Error,
|
13
14
|
].compact
|
14
15
|
|
15
16
|
REQUEST_TIMEOUT_HEADER = "X-Request-Timeout"
|
data/lib/network_resiliency.rb
CHANGED
@@ -21,7 +21,7 @@ module NetworkResiliency
|
|
21
21
|
ADAPTERS = [ :http, :faraday, :redis, :mysql, :postgres, :rails ].freeze
|
22
22
|
DEFAULT_TIMEOUT_MIN = 10 # ms
|
23
23
|
MODE = [ :observe, :resilient ].freeze
|
24
|
-
RESILIENCY_THRESHOLD =
|
24
|
+
RESILIENCY_THRESHOLD = 100
|
25
25
|
SAMPLE_RATE = {
|
26
26
|
timeout: 0.1,
|
27
27
|
stats: 0.1,
|
@@ -271,7 +271,7 @@ module NetworkResiliency
|
|
271
271
|
key = [ adapter, action, destination ].join(":")
|
272
272
|
stats = StatsEngine.add(key, duration)
|
273
273
|
|
274
|
-
if stats.n > RESILIENCY_THRESHOLD *
|
274
|
+
if stats.n > RESILIENCY_THRESHOLD * 5
|
275
275
|
# downsample to age out old stats
|
276
276
|
stats.scale!(50)
|
277
277
|
end
|
@@ -338,8 +338,17 @@ module NetworkResiliency
|
|
338
338
|
destination: destination,
|
339
339
|
}
|
340
340
|
|
341
|
-
|
342
|
-
|
341
|
+
p99 = (stats.avg + stats.stdev * 3)
|
342
|
+
|
343
|
+
# add margin of error / normalize
|
344
|
+
p99 = if stats.n >= RESILIENCY_THRESHOLD * 2
|
345
|
+
p99.power_ceil
|
346
|
+
else
|
347
|
+
# larger margin of error
|
348
|
+
p99.order_of_magnitude(ceil: true)
|
349
|
+
end
|
350
|
+
|
351
|
+
# enforce minimum timeout
|
343
352
|
p99 = [ p99, timeout_min ].max
|
344
353
|
|
345
354
|
timeouts = []
|
@@ -350,11 +359,16 @@ module NetworkResiliency
|
|
350
359
|
if p99 < max
|
351
360
|
timeouts << p99
|
352
361
|
|
353
|
-
#
|
354
|
-
|
362
|
+
# make a second, more lenient attempt
|
363
|
+
|
364
|
+
if p99 * 100 < max
|
365
|
+
# max is excessively high
|
366
|
+
timeouts << p99 * 100
|
367
|
+
elsif p99 * 10 < max
|
355
368
|
# use remaining time for second attempt
|
356
369
|
timeouts << max - p99
|
357
370
|
else
|
371
|
+
# max is smallish
|
358
372
|
timeouts << max
|
359
373
|
|
360
374
|
NetworkResiliency.statsd&.increment(
|
@@ -376,10 +390,8 @@ module NetworkResiliency
|
|
376
390
|
else
|
377
391
|
timeouts << p99
|
378
392
|
|
379
|
-
#
|
380
|
-
|
381
|
-
# unbounded second attempt
|
382
|
-
timeouts << nil
|
393
|
+
# second attempt
|
394
|
+
timeouts << p99 * 100
|
383
395
|
|
384
396
|
NetworkResiliency.statsd&.increment(
|
385
397
|
"network_resiliency.timeout.missing",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: network_resiliency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pepper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|