分布式系统上的互斥

发布于 2024-10-29 20:05:50 字数 86 浏览 2 评论 0原文

事实是,人们应该使用分布式互斥算法(例如前川算法)而不是简单互斥。在什么情况下,简单的互斥锁无法在分布式系统上提供互斥或良好的性能?谁能给我一个具体的例子吗?

what is the fact that one should use distributed mutex algorithm (e.g. Maekawa's algorithm) over simple mutex. What is a situation that simple mutex locking would lack to provide mutual exclusion or good performance on distributed system? Can anyone give me a specific example?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小ぇ时光︴ 2024-11-05 20:05:50

简单互斥体是指在多线程编程中使用的普通互斥体吗?普通的互斥体仅在一台计算机上可见,因此无法防止远程计算机上的作业之间的竞争条件。这使它成为一个不可能的开始。

也就是说,不使用分布式互斥体可以获得更好的平均性能。因此,您可以使用主控选举来确定谁负责一组互斥体,然后让所选的主控器提供短期互斥体。如果互斥体的持有时间永远不会超过确定主控器已关闭并选举新主控器的时间段,那么这是安全的。

然而,该策略将导致互斥锁获取在整个主选举过程中被阻止。主设备预计会花费很少的时间停机,但当它停机时,会对延迟产生重大影响。如果您更关心最大延迟而不是平均资源使用和平均延迟,那么这可能是不可接受的,并且您每次都需要使用分布式互斥锁。

By a simple mutex do you mean a normal mutex that you use in multi-threaded programming? A normal mutex is only visible on one machine, and therefore would do nothing to prevent race conditions between jobs on remote machines. That makes it a non-starter.

That said, you get better average performance by not using a distributed mutex. Therefore you can use master election to figure out who is responsible for a set of mutexes, and then have the chosen master serve short-lived mutexes. If the mutexes are never held for longer than the time period to decide that the master is down and elect a new master, this is safe.

However that strategy will cause mutex acquisition to be blocked on the whole master election process. The master is expected to spend very little time down, but when it is down that has a major impact on latency. If you care about maximum latency more than average resource use and average latency, this may be unacceptable, and you'll need to use the distributed mutex every time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文