Skip to content

Erlang loadbalancer built on top of revolver with dynamic pooling

License

Notifications You must be signed in to change notification settings

byronpc/minigun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minigun

minigun is a round-robin load balancer built on top of revolver with additional features such as built-in pool and dynamic pooling

like revolver, this is perfect for fast parallelization of equally sized tasks.

configuration

revolver options (See revolver for more information)

RevolverOpts = #{
  min_alive_ratio          => 1.00,
  reconnect_delay          => 1000,
  max_message_queue_length => 2,
  connect_at_start         => true
}

worker child spec

ChildSpec = #{
  start     => {minigun_pong, start_link, []},
  restart   => permanent,
  shutdown  => 5000,
  type      => worker,
  modules   => [minigun_pong]
}

Minigun Opts

MinigunOpts = #{
  pool_id       => pong,        % pool id
  pool_size     => 2,           % initial size of the pool
  pool_limit    => 4,           % maximum size of the pool
  janitor_ttl   => 30000,       % janitor interval for idle worker cleanup
  child_spec    => ChildSpec,   % worker child spec
  revolver_opts => RevolverOpts % revolver options
}

usage

You can start multiple minigun instances.

To manually start the supervisor:

1> minigun_sup:start_link(Opts)
{ok,<0.122.0>}

To include minigun in your supervisor:

SupervisorOpts = #{
  id        => minigun_sup
  start     => {minigun_sup, start_link, MinigunOpts},
  restart   => permanent,
  shutdown  => infinity,
  type      => supervisor,
  modules   => [minigun_sup]
}

Elixir:

opts = %{
  pool_id:    pong,
  pool_size:  2,
  pool_limit: 4,
  janitor_ttl: 30000,
  child_spec: worker(:minigun_pong, []),
  revolver_opts: %{
    min_alive_ratio: 1.00,
    reconnect_delay: 1000,
    max_message_queue_length: 2,
    connect_at_start: true
  }
}

supervisor(:minigun_sup, opts)

To retrieve a minigun_pool pid

1> minigun:pid(pong).
<0.40.0>

About

Erlang loadbalancer built on top of revolver with dynamic pooling

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages