GithubHelp home page GithubHelp logo

isabella232 / haproxy-neighbors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from getsentry/haproxy-neighbors

0.0 0.0 0.0 29 KB

haproxy with peer service discovery and consistent hashing

License: Apache License 2.0

Dockerfile 2.58% Makefile 4.26% Go 93.15%

haproxy-neighbors's Introduction

haproxy-neighbors

Problems this solves

When running a stateful datastore, it's sometimes desirable to maintain an http level consistent hash between peers amongst the cluster.

This is a challenge when deploying within contexts such as kuberenetes where IPs and hosts move around.

Traditionally for us, we've had smarter clients which did the consistent hashing to all nodes within the cluster, and all clients were required to have the same view of the world with the same algorithms.

This requirement is done in the wrong place and puts extra burden on the clients to do the correct thing.

What this thing does

This moves the burden from the client to do consistent hashing to the service itself.

haproxy-neighbors is indended to work as a sidecar, or a frontend for the datastore. haproxy-neighbors uses SRV DNS records to discover its peers, and configures it's own consistent hashing using haproxy amongst the peers it has found.

This pattern suits well for any stateful store that is accessible via SRV records, and allows the clients to be agnostic and unaware that this behavior even happens.

Clients are able to make a request to any node within the cluster on the frontend port, and requests are forwarded along to either the local peer or a neighbor depending on the hashing required. This adds potentially an extra hop, but shifts the responsibily into the service so clients can be simpler.

Configuration

All configuration is through environment variables, and this is expected to run from its Docker container so it can own the haproxy subprocess.

HAPROXY_ENABLE_LOGS=false  # Enable http logging or not
HAPROXY_BALANCE=uri  # haproxy's 'balance' option
HAPROXY_HTTP_CHECK='meth OPTIONS'  # The http health check to use
HAPROXY_BIND=0.0.0.0:8888  # What port to bind haproxy on, this is the frontend
HAPROXY_THREADS=1  # If you want more than 1 thread for haproxy
HAPROXY_SLOTS=10  # The max number of slots to be allocated for hosts. This number must be higher than the number of hosts within your cluster, otherwise, hosts will just be ignored.
HAPROXY_STATS_BIND=  # Add an ip:port here if you'd like to enable the haproxy admin UI
HAPROXY_HEALTH_BIND=  # Add an ip:port here if you'd like to enable a health check endpoint in haproxy directly
HAPROXY_MAXCONN=500  # How many max connections haproxy can handle
HAPROXY_TIMEOUT_CONNECT=100ms  # haproxy's 'timeout connect' option
HAPROXY_TIMEOUT_CLIENT=5s  # haproxy's 'timeout client' option
HAPROXY_TIMEOUT_SERVER=5s  # haproxy's 'timeout server' option
HAPROXY_TIMEOUT_CHECK=100ms  # haproxy's 'timeout check' option

DISCOVERY_METHOD=dns  # currently required, but this is the only option. This is to future proof.
DISCOVERY_DNS_REFRESH=5s  # how often to query DNS record
DISCOVERY_DNS_NAME=  # The SRV DNS record to use for peers. This must be the form of `_[service]._[proto].[name].`

haproxy-neighbors's People

Contributors

beezz avatar mattrobenolt avatar tonyo 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.