Coder Social home page Coder Social logo

hackney_disp's Introduction

hackney_disp

Load-balanced Pool dispatcher based on dispcount for hackney.

Like the default pool handler hackney_pool, but with the difference that for each endpoint (domain/ip + port + ssl) of requests, a load balancer is started allowing as many connections as mentioned in the configuration.

Each load balancer has N workers that will connect on-demand to each client.

The load balancer/pools/dispatcher mechanism is based on dispcount, which will randomly contact workers. This means that even though few connections might be required, the nondeterministic dispatching may make all connections open at some point. As such, it should be used in cases where the load is somewhat predictable in terms of base levels.

When to use it?

Whenever the HTTP client you're currently using happens to block trying to access resources that are too scarce for the load required, you may experience something similar to bufferbloat, where the queuing up of requests ends up ruining latency for everyone, making the overall response time terribly slow.

In the case of Erlang, this may happen over pools (like the default) that dispatch resources through message passing. Then the process' mailbox ends up as a bottleneck that makes the application too slow. Dispcount was developed to solve similar issues by avoiding all message passing on busy workers.

WARNING: use with caution, this pool handler is considered as experimental. It's for now nased on the code from the dlhttpc project and adapted to hackney. How to use it?

In your application config set the pool_handler property to hackney_disp:

{hackney, [
    {pool_handler, hackney_disp},
    {restart, permanent},
    {shutdown, 10000},
    {maxr, 10},
    {maxt, 1}
    ...
]}

and hackney will automatically use this pool.

The restart, shutdown, maxr, and maxt values allow to configure the supervisor that will take care of that dispatcher. You can set the maximum number of connections with the options passed to the client: [{max_connections, 200}] .

Note: for now you can't force the pool handler / client.

hackney_disp's People

Contributors

benoitc avatar dakrone avatar

Watchers

 avatar  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.