Giter VIP home page Giter VIP logo

Comments (5)

libi avatar libi commented on August 17, 2024

这里的Duration和节点心跳/节点信息有效期有直接关系,如果设置时间过长,当部分节点宕机时其他节点没有及时刷新节点列表可能会导致任务丢失。
另外redis的性能完全足够支撑n个节点(Duration为1的话,并发则为n)的并发请求。
如果节点数量级过大,可以尝试实现etcd driver来满足需求。

from dcron.

van-scott avatar van-scott commented on August 17, 2024

func (rd *RedisDriver) heartBear(nodeID string) {

//每间隔timeout/2设置一次key的超时时间为timeout
key := nodeID
tickers := time.NewTicker(rd.timeout / 2)
for range tickers.C {
	aa, err := rd.do("EXPIRE", key, int(rd.timeout*10/time.Second))
	fmt.Println(aa)
	if err != nil {
		panic(err)
	}
}

}

建议这段代码进行延长有效期的时候,如果返回值为0 时,重新注册一下,不然如果设置值超过一秒,就容易导致节点不执行任务

from dcron.

van-scott avatar van-scott commented on August 17, 2024

这个时间建议可以设置,但是可以注明后果是什么,因为5-10秒应该有些人还是能接收的

from dcron.

libi avatar libi commented on August 17, 2024

这个时间建议可以设置,但是可以注明后果是什么,因为5-10秒应该有些人还是能接收的

感谢建议,已经添加可选项

from dcron.

libi avatar libi commented on August 17, 2024

建议将Duration放到可配置项中,不然
func (np *NodePool) tickerUpdatePool() { tickers := time.NewTicker(time.Second * defaultDuration) for range tickers.C { if np.dcron.isRun { np.updatePool() } } }
直接for循环扫描redis,对性能有影响.

ec1c2e3

from dcron.

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.