a3kov

a3kov

Atomic Bucket - fast single node rate limiter implementing Token Bucket algorithm

Atomic Bucket

Fast single node rate limiter implementing Token Bucket algorithm. The goal is to provide dependable solution that JustWorks™ with a focus on performance, correctness and ease of use. Bucket data is stored using :atomics module. Bucket references are stored in ETS and optionally cached as persistent terms.

Features

  • lock-free and race-free with compare-and-swap operations

  • BlazingFast™ performance, see benchmarks section in the readme. Req/s go brrrrrr

  • monotonic timer for correct calculations

  • millisecond tick supporting wider range of parameters and preventing request starvation

  • automatic calculation of bucket parameters based on average rate and burst size

  • handy timeouts for retries

  • compile-time validation of arguments when possible

  • only fixed request cost is supported for now

Links

Package
Docs
Source

Most Liked

jsm

jsm

If you’re interested, this uses atomics as well: Once - Ecto type for globally unique 64-bits IDs generated by multiple Elixir nodes (to be precise, the underlying NoNoncense lib does).

a3kov

a3kov

Version 0.2.0 comes with new advanced features via raw_request/5:

  • Support for variable request cost for cases where multiple operations have different cost, but share the same budget.
  • Support for negative cost (“token refunds”). Can be useful where an allowed operation failed and we don’t want it to “steal” the budget.

Unless some new ideas appear the library seems feature-complete at this point.

Asd

Asd

This is a great library. The implementation is much more efficient and does not contain concurrency bugs like Hammer’s leaky bucket implementation.

Definitely gonna use it in one of my projects. One request is to leave the atomics ref management to the user!

Where Next?

Popular in Announcing Top

Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Thank...
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
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: GitHub - tmbb/phoenix_ws: Websockets implemented over Phoenix Ch...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 11241 107
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
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
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54996 245
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
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement