<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Distributed Lock on Zhuifeng Notes</title><link>https://4f0a9a3b.wangpeng.pages.dev/en/tags/distributed-lock/</link><description>Recent content in Distributed Lock on Zhuifeng Notes</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 25 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://4f0a9a3b.wangpeng.pages.dev/en/tags/distributed-lock/index.xml" rel="self" type="application/rss+xml"/><item><title>Distributed Coordination in Practice</title><link>https://4f0a9a3b.wangpeng.pages.dev/en/tech/zookeeper/coordination/</link><pubDate>Tue, 25 Aug 2026 00:00:00 +0000</pubDate><guid>https://4f0a9a3b.wangpeng.pages.dev/en/tech/zookeeper/coordination/</guid><description>&lt;p&gt;ZooKeeper offers primitive-level coordination; almost every distributed coordination need can be built from the combination of &amp;ldquo;ephemeral node + sequential node + Watcher&amp;rdquo;.&lt;/p&gt;&#10;&lt;h2 id="leader-election"&gt;Leader Election&#10;&lt;/h2&gt;&#10;&lt;p&gt;Each candidate creates an ephemeral sequential node under &lt;code&gt;/election&lt;/code&gt;; the one with the smallest sequence becomes Master. Non-smallest nodes watch their predecessor; when the predecessor disappears they re-evaluate whether they are now smallest, achieving automatic failover:&lt;/p&gt;&#10;&lt;div class="td-code td-code--untitled" id="td-code-889a3404-fence-0" data-td-code data-td-code-auto-id&#10; data-td-language="text" data-td-line-count="4"&gt;&#10; &lt;div class="td-code__viewport" id="td-code-889a3404-fence-0-viewport" data-td-code-viewport&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/election&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├── /n_0000000001 (master)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├── /n_0000000002 (watches 001)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; └── /n_0000000003 (watches 002)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;h2 id="configuration-center"&gt;Configuration Center&#10;&lt;/h2&gt;&#10;&lt;p&gt;Write configuration into a persistent node; clients read it and register a Watcher. On configuration change the client receives a notification and hot-reloads without restarting the app. Keep config nodes small to avoid oversized single pushes.&lt;/p&gt;</description></item></channel></rss>