GithubHelp home page GithubHelp logo

Client-side load balancing about kit HOT 6 CLOSED

go-kit avatar go-kit commented on May 18, 2024
Client-side load balancing

from kit.

Comments (6)

dahernan avatar dahernan commented on May 18, 2024

Use case:

We currently have a microservice to do service discovery (based in etcd), this service gets the list of server:port to connect, and also notify any changes with a channel.

Current solution:

The current solution to connect microservices is put HAProxy in the middle of services to do load balance, and add/remove services, the config for HAProxy is feed with the list of services from service discovery.

Pros:

  • HAProxy rocks. Good, stable loadbalancer and easy to monitor.
  • The client of the microservice, connects only to one point

Cons:

  • HAProxy is another piece in the middle, it could increase the latency, and is more complex to deploy
  • For a client is two levels of service discovery, you have to discovery the HAProxy instead of the end machines, it adds more complexity to service discovery

Desire Solution:

Be able to use a http.Transport for the http client that supports service discovery and load balancing, so it removes HAProxy as a middleware. (more or less what Netflix Ribbon[1] does).

Pros:

  • Simple model to deploy
  • No need to do service discovery 'twice'
  • it could be easily integrated with Circuit Breakers

Cons:

  • Replace some of the features and monitoring from HAProxy could be really hard an error prone.
  • HAProxy allows dummy clients in multiple languages (they don't need to know about load balancing and service discovery)

[1]https://github.com/Netflix/ribbon

from kit.

peterbourgon avatar peterbourgon commented on May 18, 2024

Brilliant, thank you! Can you say more about how you interact with etcd?

from kit.

dahernan avatar dahernan commented on May 18, 2024

Every micro-service emits heartbeats that are register in a keyspace:
/heartbeats/<service-name>/<host-name>/<port> : timestamp

Discovery service polls that keyspace and maintain another keyspace with the list of the available services based in the last activity

You only need to call Discovery service to get the list of host given a service name.

from kit.

peterbourgon avatar peterbourgon commented on May 18, 2024

Given #67 I think the way this would work would be implementing an etcd Publisher that respected endpoint healthiness. Then that publisher can feed an e.g. RoundRobin LoadBalancer. And then, building an http.Transport that wrapped that load-balanced endpoint.

Does that make sense to you? Any obvious impedance mismatches?

from kit.

dahernan avatar dahernan commented on May 18, 2024

Yeah, that sounds good to me.
I don't see any issue at this moment.

from kit.

peterbourgon avatar peterbourgon commented on May 18, 2024

So, I'll close this in favor of #68. Thanks for the feedback!

from kit.

Related Issues (20)

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.