It might appear that this recipe creates a herd effect: when there is a large group of clients waiting for a read lock, and all getting notified more or less simultaneously when the "write-" node with the lowest sequence number is deleted. In fact. that's valid behavior: as all those waiting reader clients should be released since they have the lock. The herd effect refers to releasing a "herd" when in fact only a single or a small number of machines can proceed.
你说的对。
因为 ZK 锁有羊群效应问题本来就是中文互联网上自己瞎扯淡的产物,英文界你都找不着相关的讨论。
事实上 ZK 自己的官方文档上专门提到了这个问题:https://zookeeper.apache.org/...
可以看 Shared Locks 小节的 Notes 备注部分:
注意加粗的部分。大意就是“看起来会产生羊群效应,实际上这是合理的做法。”
说实话,我真没见过哪个 ZK 集群因为这个导致所谓的羊群效应,最后崩了的 ———— 同时有大量的锁等待,其本身造成的性能问题比这个要严重的多了;而你所谓的羊群效应,其前提就是得有大量锁等待。