Statix is an Elixir client for StatsD-compatible servers. It is focused on speed without sacrificing simplicity, completeness, or correctness.
What makes Statix the fastest library around:
- direct sending to socket [1]
- caching of the UDP packet header
- connection pooling to distribute the metric sending
- diligent usage of IO lists
[1] In contrast with process-based clients, Statix has lower memory consumption and higher throughput – Statix v1.0.0 does about 876640 counter increments per flush:
It is possible to measure that yourself.
for _ <- 1..10_000 do
Task.start(fn ->
for _ <- 1..10_000 do
StatixSample.increment("sample", 1)
end
end)
endMake sure you have StatsD server running to get more realistic results.
See the documentation for detailed usage information.
Statix Compatibility: Statix, does not yet support OTP-26. It is using Port.command instead of :gen_udp.send, as the former was considered more performant for OTP 25 and older versions. However, due to OTP updates occurring at the networking layer, this approach no longer works. Now, gen_udp.send has been optimized, rendering the previous workaround obsolete.
-
Open PR: There is an open pull request in the Statix repository addressing this issue: Pull Request #72. This PR aims to update the codebase to support OTP-26 and utilize the optimized
gen_udp.sendfunction. -
Erlang Discussion: For further insights, you can refer to the Erlang discussion about the breaking change in
Port.commandfor OTP-26: Issue #7130.
By utilizing the forked repository of Statix, we can maintain compatibility with OTP-26. As Statix evolves and potentially adds support for our current version, we aim to transition back to the main Statix repository. Alternatively, we'll explore alternatives should the need arise in the future.
Add Statix as a dependency to your mix.exs file:
defp deps() do
[{:statix, ">= 0.0.0"}]
endThen run mix deps.get in your shell to fetch the dependencies.
This software is licensed under the ISC license.
