Skip to main content

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 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 equal
    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


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.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

failure_detector-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file failure_detector-0.1.1.tar.gz.

File metadata

  • Download URL: failure_detector-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.4.16-linuxkit

File hashes

Hashes for failure_detector-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b0b79b9404c8620956f3a53a886db39bbf90146b6a3c9ab1937cef84b976d8ef
MD5 b93a17a7c7f107a72f684cdd26c897dc
BLAKE2b-256 c0acc725de13ae3ce7a60722424b2c4f11c81ac945ff4d9b3ebc637092f9f3bc

See more details on using hashes here.

File details

Details for the file failure_detector-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: failure_detector-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.4.16-linuxkit

File hashes

Hashes for failure_detector-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9129d43477aae06afd0bd43bf145b9e1a17e9321ce04f4c52182b39832e7dba
MD5 90d3ec84a0983ec689ca04cb0a127987
BLAKE2b-256 a38a8ac5ce9b7c949ecd8c65b87385270171b4cb37858fff84ac07dd5a721d01

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page