Coder Social home page Coder Social logo

Comments (2)

shubhamranjan avatar shubhamranjan commented on July 24, 2024

initialize the _lastNodeIndex of the EtcdClient with a random selected node from the node list.

This sounds like a better idea.

from dotnet-etcd.

yoricksmeets avatar yoricksmeets commented on July 24, 2024

The changes made will now always use random to pick a new node but I was expecting that we would only use random for the initial start node and use the increase by one method after selecting the first node.

Given a 3 node cluster.
For this cluster we start 5 clients. The clients will create a number of streams over their lifetime:

  1. Will start 21 streams
  2. Will start 10 streams
  3. Will start 19 streams
  4. Will start 1 stream
  5. Will start 3 streams

The solution before this change would have the following behaviour:

  • 1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3
  • 1,2,3,1,2,3,1,2,3,1
  • 1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3
  • 1
  • 1,2,3
    with the disadvantage that it would always start on node 1 given this more load but after the initial selection of node 1 it would spread the load even over the rest of the nodes

The solution as it is implemented now only checks if the selected node differs from the node it was currently using, given the following hypothetical behaviour since random is used:

  • 2,1,2,3,1,2,1,2,1,2,1,2,3,2,1,3,1,2,3,2,3,1
  • 1,2,1,3,2,3,1,2,1,3
  • 2,3,1,3,2,3,2,1,3,1,3,1,2,1,3,2,3,1
  • 3
  • 1,3,1
    Not giving a disadvantage to node 1, but not guaranteeing an even spread of the load since the random function in combination with the rule that the node must change could render series like: 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1 not selecting node 2 for a long time. We can expect each node to be selected about the same number of times over a long period but in short selections of the series this not guaranteed.

The solution that I wanted to describe is only selecting the first node using the random function and using +1 after the initial selection would give the following series:

  • 1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3
  • 3,1,2,3,1,2,3,1,2,3
  • 2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1
  • 2
  • 3,1,2
    This prevents node 1 from being over represented in the selection but will guarantee an even spread over the nodes after selecting the first node.

from dotnet-etcd.

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.