Home

Awesome

Overview

Spillway is an Erlang OTP application used for load shedding. The idea behind spillway is to use it to be able to limit the number of in flight concurrent calls to a section of code.

Some examples:

Example of use

A process about to execute a named section of code whose maximum parallelism should be limited will call spillway:enter/2/3 with the name, the weight, and limit.

If the return value is the 2-tuple {true, TotalWeight}, the process may enter the section of code (there now being TotalWeight in use concurrently-executing accesses), and otherwise not.

If the process entered the section of code, it should call spillway:leave/2 with the name and weight after completion.

No special arrangement is made to handle process exits. If a process dies without calling spillway:leave/1, the counter will be inaccurate. This is intentional, and callers should make arrangements to mitigate this occurrence.

case spillway:enter(running_requests, Weight, Limit) of
 {true, Value} ->
        try
           continue_executing(Something);
        after
            spillway:leave(running_requests, Weight)
        end;
 false ->
     discard(Something)

end.

Setup

Implementation

Spillway is implemented based on ETS-based bounded named counters.

Build

$ make $ make ct

1.x Changelog

1.1 2018-07-13