Observers: Scaling ZooKeeper Without Hurting Write Performance
文章目錄
Observers: Scaling ZooKeeper Without Hurting Write Performance
How to use Observers
How to use Observer Masters
Example use cases
Observers: Scaling ZooKeeper Without Hurting Write Performance
觀察者: 在不影響寫性能的情況下擴(kuò)展 ZooKeeper
Although ZooKeeper performs very well by having clients connect directly to voting members of the ensemble, this architecture makes it hard to scale out to huge numbers of clients. The problem is that as we add more voting members, the write performance drops. This is due to the fact that a write operation requires the agreement of (in general) at least half the nodes in an ensemble and therefore the cost of a vote can increase significantly as more voters are added.
雖然 ZooKeeper 通過讓客戶直接連接到整體中有投票權(quán)的成員而表現(xiàn)得非常好,但是這種架構(gòu)使得它很難擴(kuò)展到大量的客戶。問題是,隨著我們添加更多的投票成員,寫作性能下降。這是因?yàn)閷懖僮餍枰现兄辽僖话牍?jié)點(diǎn)的同意,因此隨著更多選民的加入,投票成本會顯著增加。
We have introduced a new type of ZooKeeper node called an Observer which helps address this problem and further improves ZooKeeper’s scalability. Observers are non-voting members of an ensemble which only hear the results of votes, not the agreement protocol that leads up to them. Other than this simple distinction, Observers function exactly the same as Followers - clients may connect to them and send read and write requests to them. Observers forward these requests to the Leader like Followers do, but they then simply wait to hear the result of the vote. Because of this, we can increase the number of Observers as much as we like without harming the performance of votes.
我們引入了一種新型的 ZooKeeper 節(jié)點(diǎn),稱為 Observer,它有助于解決這個(gè)問題并進(jìn)一步提高 ZooKeeper 的可伸縮性。觀察員是集體的無表決權(quán)成員,他們只聽取投票結(jié)果,而不聽取達(dá)成協(xié)議的協(xié)議。除了這個(gè)簡單的區(qū)別之外,觀察者的功能與跟隨者完全相同——客戶端可以連接到他們,并向他們發(fā)送讀寫請求。觀察者像追隨者那樣將這些請求轉(zhuǎn)發(fā)給領(lǐng)導(dǎo)者,他們只是等待投票結(jié)果。正因?yàn)槿绱耍覀兛梢噪S心所欲地增加觀察員人數(shù),同時(shí)又不影響投票結(jié)果。
Observers have other advantages. Because they do not vote, they are not a critical part of the ZooKeeper ensemble. Therefore they can fail, or be disconnected from the cluster, without harming the availability of the ZooKeeper service. The benefit to the user is that Observers may connect over less reliable network links than Followers. In fact, Observers may be used to talk to a ZooKeeper server from another data center. Clients of the Observer will see fast reads, as all reads are served locally, and writes result in minimal network traffic as the number of messages required in the absence of the vote protocol is smaller.
Observers 還有其它優(yōu)勢。因?yàn)樗麄儾煌镀保运麄儾皇莿游飯@管理員合唱團(tuán)的重要成員。因此,它們可以失敗,或者斷開與集群的連接,而不會影響 ZooKeeper 服務(wù)的可用性。對用戶的好處是,觀察者可以連接比追隨者更不可靠的網(wǎng)絡(luò)鏈接。事實(shí)上,觀察者可能被用來與另一個(gè)數(shù)據(jù)中心的 ZooKeeper 服務(wù)器進(jìn)行對話。觀察者的客戶端能夠快速讀取,因?yàn)樗械淖x取都是在本地完成的,寫入的結(jié)果是最小的網(wǎng)絡(luò)流量,因?yàn)樵跊]有投票協(xié)議的情況下所需的消息數(shù)量較少。
How to use Observers
Setting up a ZooKeeper ensemble that uses Observers is very simple, and requires just two changes to your config files. Firstly, in the config file of every node that is to be an Observer, you must place this line:
設(shè)置一個(gè)使用 observer 的 ZooKeeper 集成非常簡單,只需要對配置文件做兩處修改。首先,在每個(gè)要成為觀察者的節(jié)點(diǎn)的配置文件中,你必須放置下面這行:
peerType=observer
1
This line tells ZooKeeper that the server is to be an Observer. Secondly, in every server config file, you must add :observer to the server definition line of each Observer. For example:
這一行告訴 ZooKeeper 服務(wù)器是一個(gè)觀察者。其次,在每個(gè)服務(wù)器配置文件中,必須在每個(gè) Observer 的服務(wù)器定義行中添加: Observer。例如:
server.1:localhost:2181:3181:observer
1
This tells every other server that server.1 is an Observer, and that they should not expect it to vote. This is all the configuration you need to do to add an Observer to your ZooKeeper cluster. Now you can connect to it as though it were an ordinary Follower. Try it out, by running:
這告訴每個(gè)其他服務(wù)器,server. 1是一個(gè)觀察者,他們不應(yīng)該期望它投票。這就是在 ZooKeeper 集群中添加 Observer 所需的全部配置。現(xiàn)在你可以連接到它,就像它是一個(gè)普通的追隨者。通過連接客戶端嘗試一下:
$ bin/zkCli.sh -server localhost:2181
1
where localhost:2181 is the hostname and port number of the Observer as specified in every config file. You should see a command line prompt through which you can issue commands like ls to query the ZooKeeper service.
其中 localhost: 2181是在每個(gè)配置文件中指定的 Observer 的主機(jī)名和端口號。您應(yīng)該會看到一個(gè)命令行提示符,可以通過它發(fā)出 ls 之類的命令來查詢 ZooKeeper 服務(wù)。
How to use Observer Masters
Observers function simple as non-voting members of the ensemble, sharing the Learner interface with Followers and holding only a slightly different internal pipeline. Both maintain connections along the quorum port with the Leader by which they learn of all new proposals on the ensemble.
觀察者的功能很簡單,就像集合中沒有投票權(quán)的成員一樣,與追隨者共享學(xué)習(xí)者界面,只有一個(gè)略微不同的內(nèi)部管道。兩者都保持在仲裁端口與領(lǐng)袖的連接,通過他們了解整個(gè)系統(tǒng)的所有新建議。
By default, Observers connect to the Leader of the quorum along its quorum port and this is how they learn of all new proposals on the ensemble. There are benefits to allowing Observers to connect to the Followers instead as a means of plugging into the commit stream in place of connecting to the Leader. It shifts the burden of supporting Observers off the Leader and allow it to focus on coordinating the commit of writes. This means better performance when the Leader is under high load, particularly high network load such as can happen after a leader election when many Learners need to sync. It reduces the total network connections maintained on the Leader when there are a high number of observers. Activating Followers to support Observers allow the overall number of Observers to scale into the hundreds. On the other end, Observer availability is improved since it will take shorter time for a high number of Observers to finish syncing and start serving client traffic.
默認(rèn)情況下,觀察員連接到領(lǐng)導(dǎo)人的仲裁端口,這是他們?nèi)绾瘟私馑行碌奶岚傅姆绞健R苍试S觀察者連接到追隨者,作為一種插入提交流代替連接到領(lǐng)導(dǎo)者的方式,這種方式有很多好處。它將支持觀察者的重?fù)?dān)從領(lǐng)導(dǎo)者身上轉(zhuǎn)移開,并允許它專注于協(xié)調(diào)寫操作的提交。
這意味著當(dāng)領(lǐng)導(dǎo)者處于高負(fù)載時(shí),特別是高網(wǎng)絡(luò)負(fù)載時(shí),比如在領(lǐng)導(dǎo)者選舉后,當(dāng)許多學(xué)習(xí)者需要同步時(shí),性能會更好。它減少了總網(wǎng)絡(luò)連接維護(hù)的領(lǐng)導(dǎo)時(shí),有大量的觀察員。
激活追隨者以支持觀察者,這樣觀察者的總數(shù)就可以擴(kuò)展到數(shù)百人。另一方面,觀察者的可用性得到了提高,因?yàn)榇罅康挠^察者完成同步并開始服務(wù)客戶端流量所需的時(shí)間更短。
This feature can be activated by letting all members of the ensemble know which port will be used by the Followers to listen for Observer connections. The following entry, when added to the server config file, will instruct Observers to connect to peers (Leaders and Followers) on port 2191 and instruct Followers to create an ObserverMaster thread to listen and serve on that port.
這個(gè)特性可以通過讓集合的所有成員知道 Followers 將使用哪個(gè)端口來偵聽 Observer 連接來激活。下面的配置項(xiàng)添加到服務(wù)器配置文件中時(shí),將指示觀察者連接端口2191上的對等點(diǎn)(leader 和 Followers) ,并指示 Followers 創(chuàng)建一個(gè) ObserverMaster 線程來監(jiān)聽和服務(wù)于該端口。
observerMasterPort=2191
1
Example use cases
Two example use cases for Observers are listed below. In fact, wherever you wish to scale the number of clients of your ZooKeeper ensemble, or where you wish to insulate the critical part of an ensemble from the load of dealing with client requests, Observers are a good architectural choice.
下面列出了觀察者的兩個(gè)用例。事實(shí)上,無論你希望擴(kuò)展你的 ZooKeeper 集合的客戶數(shù)量,或者你希望將集合的關(guān)鍵部分從處理客戶請求的負(fù)擔(dān)中隔離開來,觀察者都是一個(gè)很好的架構(gòu)選擇。
As a datacenter bridge: Forming a ZK ensemble between two datacenters is a problematic endeavour as the high variance in latency between the datacenters could lead to false positive failure detection and partitioning. However if the ensemble runs entirely in one datacenter, and the second datacenter runs only Observers, partitions aren’t problematic as the ensemble remains connected. Clients of the Observers may still see and issue proposals.
作為一個(gè)數(shù)據(jù)中心橋: 在兩個(gè)數(shù)據(jù)中心之間形成一個(gè) ZK 集合是一個(gè)有問題的嘗試,因?yàn)閿?shù)據(jù)中心之間的高延遲差異可能導(dǎo)致錯(cuò)誤的故障檢測和分區(qū)。但是,如果集成在一個(gè)數(shù)據(jù)中心中完全運(yùn)行,而第二個(gè)數(shù)據(jù)中心只運(yùn)行觀察者,那么分區(qū)就不會有問題,因?yàn)榧扇匀皇沁B接的。觀察員的客戶仍然可以看到并提出建議
As a link to a message bus: Some companies have expressed an interest in using ZK as a component of a persistent reliable message bus. Observers would give a natural integration point for this work: a plug-in mechanism could be used to attach the stream of proposals an Observer sees to a publish-subscribe system, again without loading the core ensemble.
作為消息總線的鏈接: 一些公司表示有興趣將 ZK 用作持久可靠消息總線的組件。觀察員會給這項(xiàng)工作一個(gè)自然的集成點(diǎn): 可以使用插件機(jī)制將觀察員看到的建議流附加到發(fā)布-訂閱系統(tǒng),同樣不需要加載核心集成。
ZooKeeper
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。