<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>分布式系统 on XGUGENG</title>
		<link>https://xgugeng.github.io/zh/categories/%E5%88%86%E5%B8%83%E5%BC%8F%E7%B3%BB%E7%BB%9F/</link>
		<description>Recent content in 分布式系统 on XGUGENG</description>
		<generator>Hugo</generator>
		<language>zh-CN</language>
		
		
		
		
			<lastBuildDate>Wed, 24 Jul 2019 14:24:00 +0800</lastBuildDate>
		
			<atom:link href="https://xgugeng.github.io/zh/categories/%E5%88%86%E5%B8%83%E5%BC%8F%E7%B3%BB%E7%BB%9F/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Are you ok - 分布式系统的租约和心跳</title>
				<link>https://xgugeng.github.io/zh/post/are-you-ok/</link>
				<pubDate>Wed, 24 Jul 2019 14:24:00 +0800</pubDate>
				<guid>https://xgugeng.github.io/zh/post/are-you-ok/</guid>
				<description>&lt;p&gt;故障检测主要有两种机制：心跳和租约。&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;心跳：假设总控机 A 需要确认工作机 B 是否发生故障，那么总控机 A 每隔一段时间，比如 1 秒，向工作机 B 发送一个心跳包。&lt;/li&gt;&#xA;&lt;li&gt;租约：租约在一定期限内给予持有者特定权力的协议。&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;租约的协议决定了其用途，它能做的事情远不止故障检测。&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;如果协议内容是服务器确认客户端还存活，那么这个租约的功能就相当于&lt;em&gt;心跳&lt;/em&gt;；&lt;/li&gt;&#xA;&lt;li&gt;如果协议内容是服务器保证内容不会被修改，那么这个 租约就相当于&lt;em&gt;读锁&lt;/em&gt;；&lt;/li&gt;&#xA;&lt;li&gt;如果协议内容是服务器保证内容只能被这个客户端修改，那么这个租约就相当于&lt;em&gt;写锁&lt;/em&gt;。&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;那么在判断客户端是否存活的问题上，心跳和租约有什么区别呢？&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
