我应该打开redis发行锁的守望狗吗
我正在通过使用redis 设置(如果不存在)
命令来实现分布锁定,现在面临某些分发锁任务花费超过时间的问题。这将导致一些问题,我读到Redisson提供了一种称为观看Dog
的解决方案。如果任务在到期的时间内未完成,那么Redisson可能会启动线程续订锁定时间。我的问题是:
- 使用看守狗是一个好习惯吗?因为手表狗线将使服务器付费资源成为服务器付费资源,所以它将通过分布锁的数量增加重新汇编。
I am implementing the distribution lock by using redis set if Not exists
command, now facing a issue that some distribution lock task spent more than expire time. This would cause some issue, and I read that redisson give a solution that called watch dog
. the redisson may start a thread to renew the lock expire time if the task not finished in the expire time. My question is:
- is it a good practice to use the watch dog? because the watch dog thread will make the server pay resource, it will increase the resouce requrement by the number of distribution lock.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会说这取决于。通常我们不需要看门狗。因为在大多数情况下,我们可以通过一些指标来估算代码的执行时间。我们可以将到期时间设置为比任务执行时间大一点。但是,如果任务的执行时间不稳定,我们无法估计它,那么我认为需要看守狗。由于锁定案例可能会更加逐渐发生。
I would say it depends. Normally we don't need a watch dog. Because in most cases, we can estimate the execution time of our code by some kink of metrics. And we can set the expire time a little larger than the task execution time. But if the execution time of the task is not stable, and we can not estimate it, then I think the watch dog is needed. Since lock-expire cases can occure more offenly.