Giter VIP home page Giter VIP logo

consistenthash's Introduction

一致性hash

一致性hash一种根据关键字做负载均衡的算法 代码

一致性hash优点

节点丢失,或者加入的时候,影响的是一小段空间而不是全局数据

一致性hash缺陷

一致性hash很难做到完全的负载均衡,都有数据小幅度倾斜
假设有一种算法,可以把节点关键字尽可能的打散均匀的映射到hash空间中,这时候可以完全解决数据倾斜的问题
系统启动的时候负载是做到了均衡,但是当节点丢失,或者新增加节点的时候,一致性hash肯定会再次出现数据倾斜的问题

降低数据倾斜方法

加虚拟节点(只能降低不能完全解决问题----可以使用上面类似反证法证明)

加虚拟节点必要性

  • 节点丢失的时候,该节点的数据不会完全顺延到下一个节点(使得下一个节点的压力翻倍),可以做到分摊到多个节点上
  • 新增加节点的时候,可以分摊多个节点的压力
  • 一般多台服务器的处理能力可能不一样,做负载均衡都是会根据处理能力加权的,可以通过控制虚拟节点的个数,来做加权

consistenthash's People

Contributors

quanjcq avatar

Stargazers

 avatar

Watchers

 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.