Alex66

Alex66

Phi_accrual - source-agnostic φ-accrual failure detector for Elixir/OTP

Two libraries. φ-accrual failure detector (Hayashibara 2004) split into core + transport.

phi_accrual 1.0phi_accrual | Hex

Source-agnostic. Feed in heartbeat arrivals, read out φ. No transport, no membership, no thresholding baked in.

  • Dual-α EWMA (separate smoothing for mean and variance)
  • Four-state result: :steady / :recovering / :insufficient_data / :stale
  • :erlang.system_monitor integration → local_pause? + confidence flags on φ output (:long_gc, :long_schedule, :busy_dist_port)
  • Per-node estimator GenServer under DynamicSupervisor + Registry
  • Overload shedding with telemetry
  • Optional PhiAccrual.Threshold module with hysteresis — multiple instances coexist (φ=4 for dashboards, φ=8 for routing)
  • Telemetry schema committed under SemVer, breaking changes only in v2
PhiAccrual.observe(:"peer@host")
PhiAccrual.phi(:"peer@host")
#=> {:ok, 0.42, :steady}

Bundled DistributionPing reference source for apps with no existing cross-node chatter. Inherits BEAM distribution head-of-line blocking — observable via confidence: false on φ events, but not fixable at this layer.

phi_accrual_udp 0.1.x (alpha)phi_accrual_udp | Hex

Dedicated UDP socket source. Escapes BEAM distribution HoL. Public API and wire format may change before 1.0 based on real-deployment feedback.

Wire format is 12 bytes fixed:

<<magic::16, version::8, flags::8, timestamp::64-unsigned>>
magic     = 0xCEA6
version   = 0x01
flags     = 0x00   (reserved)
timestamp = u64 ms (sender's clock; diagnostic only)

Receiver-driven clock discipline — the EWMA uses local monotonic receipt time, never the packet timestamp. Packet timestamp is for one-way delay diagnostics when NTP-synced, nothing more.

UDP is unauthenticated. Default node_resolver returns {ip, port} which is fine for dev/demos but proliferates estimator state under Sender restarts and NAT timeouts. Production deployments should supply a stable resolver mapping {ip, port} → application identifier.

Why split. φ math has zero variety — closed. Transport variety is high (UDP, BEAM dist, gRPC, MQTT, EDI cadence). Separate packages, separate repos, independent versioning. Anyone can write another transport against the public PhiAccrual.observe/2 contract.

Limitations worth knowing before wiring φ to anything irreversible:

  • Gaussian assumption misbehaves under bimodal BEAM-GC inter-arrival distributions. Correlate with :erlang.statistics(:garbage_collection) before acting on high φ. Non-parametric / mixture estimator is a v2 consideration once real traces exist.
  • One :erlang.system_monitor per node — if another library subscribes, one wins silently.

Apache-2.0 both. Feedback welcome, especially on UDP from anyone running it in anger.

https://github.com/thatsme/phi_accrual

Where Next?

Popular in Announcing Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
Crowdhailer
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure). 1.0-rc.1 is now available. To use it re...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement