Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议将Duration放到可配置项中 #8

Closed
forz opened this issue Mar 31, 2020 · 5 comments
Closed

建议将Duration放到可配置项中 #8

forz opened this issue Mar 31, 2020 · 5 comments

Comments

@forz
Copy link

forz commented Mar 31, 2020

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

@libi
Copy link
Owner

libi commented Apr 4, 2020

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

@libi libi closed this as completed Jun 1, 2020
@van-scott
Copy link

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 时,重新注册一下,不然如果设置值超过一秒,就容易导致节点不执行任务

@van-scott
Copy link

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

@libi
Copy link
Owner

libi commented Nov 17, 2020

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

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

@libi
Copy link
Owner

libi commented Nov 17, 2020

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

ec1c2e3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants