Skip to content
forked from lrascao/raterl

An erlang ETS based rate limiter inspired by Jobs

License

Notifications You must be signed in to change notification settings

dsrosario/raterl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raterl

Erlang flow control application heavily inspired in jobs and ratx, ETS based bypasses the jobs_server single process bottleneck while providing rate and counter flow control.

Supports

TODO

  • Queues
  • Modifiers

Examples

Rate flow control

A typical use case is restricting the number of logins per second on a system, you'd start by the configuration:

[{raterl, [
    {queues, [
        {logins, [
            {regulator, [
                {name, max_login_rate}, 
                {type, rate},
                {limit, 100}   %% ensures that we get no more than x logins per second
            ]}
        ]}
    ]}
  ]
}].

Then on the code you ask permission from raterl before accepting a login:

    case catch raterl:run(login_requests, {rate, max_login_rate},
                          AcceptFun) of
        limit_reached ->
            {error, throttled};
        Ret -> Ret
    end;

Build

$ rebar3 compile

About

An erlang ETS based rate limiter inspired by Jobs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 91.6%
  • Makefile 8.4%