A Pythonic implementation of the Phi-Accrual failure detector
Project description
failure-detector
A Pythonic implementation of the Phi-Accrual Failure Detector.
Phi-Accrual Failure Detectors detect system outages by statistically modeling inter-arrival times of heartbeat (ping) messages over time. The system is declared as unavailable once heartbeats are significantly delayed compared to those recently observed.
Usage
Install with pip
:
$ pip install failure-detector
Detecting network outages works roughly as follows:
from failure_detector import PhiAccrualFailureDetector
detector = PhiAccrualFailureDetector(
# suspicion threshold for which the detector declares the system unavailable
threshold=7.0,
# initial estimate of the mean heartbeat inter-arrival time (20ms)
mean_estimate=20.0,
# A lower bound for on the standard-deviation of heartbeat inter-arrival
# times. The computation of the phi-value uses #max(min_stddev, sample
# stddev); this prevents the estimated distribution from collapsing when
# e.g., all sampled heartbeats are the same
mean_stddev=3.0,
# size of the sample buffer of previous heartbeat inter-arrival times
num_samples=30
)
while True:
# perform heartbeat every second
time.sleep(1)
heartbeat_ms = ... # ping some endpoint
if not detector.evaluate(heartbeat_ms):
# report system as unavailable
else:
# add to sample buffer
detector.observe(heartbeat_ms)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
failure_detector-0.1.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for failure_detector-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96a907604d4a054c435667d2a76126576c28a81bd0bcddf33e8226442daaaf52 |
|
MD5 | 745e58649a5d40e089d4bcf3aac12fd1 |
|
BLAKE2b-256 | 9e23a72a2dc0a67d0f38035c1837403b354dc0bd3fb930b37139e477239ddba0 |