Giter VIP home page Giter VIP logo

honey_pool's Introduction

master branch

honey_pool

honey_pool is yet another gun connection pool based on worker pool.

Alpha Quality: Things can change.

WHY Honey Pool

Consider using honey_pool when your hackney_pool hangs while sending massive amount of HTTP reqs. honey_pool starts multiple connection pools using worker pool, and manages gun HTTP connections in the pools.

HOW TO USE

In the rebar.config deps, have:

{honey_pool, {git, "git://github.com/yowcow/honey_pool.git", {branch, "master"}}}

and start application honey_pool in your app, then try in shell:

1> logger:set_primary_config(level, info).
ok

2> honey_pool:dump_state().
[#{await_up_conns => #{},host_conns => #{},up_conns => #{}},
 #{await_up_conns => #{},host_conns => #{},up_conns => #{}},
 #{await_up_conns => #{},host_conns => #{},up_conns => #{}}]

3> honey_pool:get("http://example.com/", 100).
{error,{checkout,{timeout,await_up}}}

4> honey_pool:dump_state().
[#{await_up_conns => #{},
   host_conns =>
       #{{"example.com",80,tcp} =>
             [{<0.195.0>,#Ref<0.485877779.3106144257.39748>,
               #Ref<0.485877779.3106144257.39749>}]},
   up_conns => #{<0.195.0> => {"example.com",80,tcp}}},
 #{await_up_conns => #{},host_conns => #{},up_conns => #{}},
 #{await_up_conns => #{},host_conns => #{},up_conns => #{}}]

5> honey_pool:summarize_state().
[#{host_conns => [{{"example.com",80,tcp},1}],
   total_conns => #{await_up => 0,up => 1}},
 #{host_conns => [],total_conns => #{await_up => 0,up => 0}},
 #{host_conns => [],total_conns => #{await_up => 0,up => 0}}]

HOW TO CONFIGURE

In the sys.config, have:

{honey_pool, [
              %% honey pool configurations
              {idle_timeout, 60000}, %% close connection after 60 sec of idle
              %% worker pool configurations (see worker pool docs for details)
              {wpool, [
                       {workers, 10}, %% start 10 connection pools
                       {overrun_warning, 50} %% warn when a pool takes over 50 msec to respond
                      ]},
              %% gun configurations (see gun docs for details)
              {gun_opt, #{
                          retry => 0, %% let go dead connections
                          connect_timeout => 1000 %% give up connecting after 1000 msec
                         }}
             ]}

honey_pool's People

Contributors

yowcow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.