search
HomeSystem TutorialLINUXzetcd solves how to remove the dependence of applications on ZooKeeper

zetcd solves how to remove the dependence of applications on ZooKeeper

Mar 27, 2024 pm 10:50 PM
linuxlinux tutorialRed Hatlinux systemSecondary developmentlinux commandkey value pairlinux certificationred hat linuxlinux video

Distributed systems usually rely on an arbitration system to work together. Generally, such systems use arbitration to ensure the accurate transmission of information to avoid split-brain. Such systems sacrifice versatility in exchange for ample design leeway, a practice that has clearly been exemplified by the proliferation of implementations. There are many such systems, such as: chubby, ZooKeeper, etcd and consul, etc. Although the concepts and protocols of these systems are different, they all provide similar key-value based distributed arbitration. As part of the plan to make etcd the most high-profile basic component of distributed systems, the etcd team has developed a new agent, zetcd, which allows the etcd cluster to consume ZooKeeper service requests without any changes.

ZooKeeper was the first open source implementation of arbitration software, which prompted it to become the preferred backend for many distributed systems. In theory, these systems should be compatible with etcd, but due to historical reasons, this is not the case; etcd clusters cannot replace ZooKeeper, and their data models and client protocols are incompatible with ZooKeeper applications; and vice versa. If the system is already in production, there is little incentive to plug it into a new backend and introduce new complexity.

Fortunately, the etcd v3 API is preparing to implement simulation support for the ZooKeeper data model through a standard proxy zetcd. zetcd is a new open source project developed by the etcd team. Today the first beta version of zetcd, v0, was released. 0.1, the goal is to manage and deploy the zetcd system in production systems.

zetcd The agent is deployed in front of the etcd cluster and serves a simulated ZooKeeper client port, allowing the ZooKeeper application to call etcd natively in the upper layer. Generally speaking, zetcd accepts ZooKeeper client requests, converts them into etcd's data model and API, forwards the requests to etcd, and then forwards the return information back in a way that the client can understand. The performance of zetcd is comparable to ZooKeeper, and it simplifies the management and operation complexity between ZooKeeper cluster and etcd. This article will reveal how to use zetcd, how zetcd works, and performance benchmarks.

Getting started with zetcd

What zetcd needs to run is a go compiler, source code obtained from the Internet, and a system that can run etcd. The following example shows how to obtain the zetcd source code and run the ZooKeeper command on zetcd. Since both etcd and zetcd are built based on the development branch, it is not recommended to do this in a production environment. This is just a simple example to explain how to use it.

First, obtain etcd and zetcd source code and compile it into binary code:

go get github.com/coreos/etcd/cmd/etcd 
go get github.com/coreos/zetcd/cmd/zetcd

Secondly, run etcd and connect zetcd to etcd client server:

#etcd uses localhost:2379 by default 
etcd & 
zetcd -zkaddr localhost:2181 -endpoints localhost:2379 &

Try zetd by adding a subscription and creating a key:

go install github.com/coreos/zetcd/cmd/zkctl 
zkctl watch / & 
zkctl create /abc "foo"

Conceptually, the above example completes adding a layer of zetcd to a single etcd instance.
zetcd solves how to remove the dependence of applications on ZooKeeper

Support for ZooKeeper in etcd3

In depth, zetcd will translate ZooKeeper's data model into an adapted etcd API. For key lookups, zetcd converts the ZooKeeper hierarchical directory into etcd's flat binary keyspace. To manage metadata, when writing to the etcd backend, zetcd utilizes memory-level transactions to securely and atomically update the information to ZooKeeper znode information.

ZooKeeper lists keys in directory mode (getChildren), while etcd uses interval (Range) mode. The following figure explains how zetcd encodes keys under etcd to effectively support listing in directory form. All zetcd keys in etcd have a prefix that includes the full directory name (for example: "/" and "/abc" represent depths of 0 and 1 respectively). To list a directory, zetcd issues a prefixed range request (for example, ["/zk/key/002/abc/", "/zk/key/002/abc0") to list the directories that satisfy the directory depth and path. All keys under /abc/. The depth limit only applies to the directory itself; if zetcd only uses the path but not the depth, etcd will return all keys in this directory, and zetcd will discard the result, otherwise only the keys in this directory will be returned.

zetcd solves how to remove the dependence of applications on ZooKeeper

Each ZooKeeper key has some metadata in the ZNode, that is, key adjustment, version and permissions, etc. Although etcd also has metadata for each key, it is much simpler than ZNode. For example, because there is no directory, there is no subversion, because etcd uses a role-based authentication mechanism, there is no ACL, and because the actual clock is out of scope, There is no timestamp. These additional metadata will be mapped to corresponding keys to describe a complete ZNode. When modifying metadata, zetcd uses memory-level soft transactions to automatically update a subset of keys, ensuring that ZNodes can remain consistent without expensive locking mechanisms.

In addition, zetcd can perform dynamic verification with an authorized ZooKeeper server. For comparison, zetcd can connect to both etcd and an external ZooKeeper server. When the client initiates a request to zetcd in this mode, the request will be forwarded to both zetcd and the ZooKeeper server. If the data responded by the two servers is inconsistent, zetcd will flag a warning for this response.

Performance Benchmark

由于数据的转换以及额外的网络开销,也许很容易觉得这样的模拟不切实际。尽管对于ZooKeeper或者etcd集群来说,zetcd有额外的花销,但是它仍然有一个优势,即某些etcd应用安装完毕后仍然需要ZooKeeper来协调的场景。例如,早期用户报告称在zetcd里通过etcd的TLS加密流量比一个类似的经典ZooKeeper配置更简单。在这些场景中,支持同一种ZooKeeper协议所带来的简单可靠性比性能更重要一些。 跟etcd性能工具的接口及报告形式类似,zetcd命令行工具zkboom可以用来判断一个zetcd的性能基准是否满足要求。其它ZooKeeper性能工具应该也可以用在zetcd;zkboom为用户提供了便利,我们不妨试试用它来做下创建key的测试:

go get github.com/coreos/zetcd/cmd/zkboom 
zkboom --conns=50 --total=10000 --endpoints=localhost:2181 create

zetcd应当可以为小负载提供充分的性能保障。一个简单两节点配置的延迟基准表明zetcd是可以承受大量请求的。具体配置为两台Linux服务器通过一个千兆交换机互联,其中一台设备在RAID磁盘配置上运行代理和和服务端,另外一台设备用于产生客户请求。zkbook通过创建一个空的key存储,然后从中读取128Kbytes的键值对来进行测量。用户请求被限制在每秒2500个请求,然后逐渐增加并发客户端数量。ZooKeeper 3.4.10和etcd结果对比见下图。

下图揭示了zetcd客户端并发数与创建key的平均延迟之间的关系。由于etcd在延迟上比ZooKeeper要有5-35ms的优势,zetcd有足够余地处理由于额外负载和网络跳转造成的延迟。比起ZooKeeper,zetcd代理始终还是存在20ms左右的差距,但是从处理2500请求的吞吐量数据来看,并没有出现队列堵塞。一种对zetcd写比较慢的解释是,与读不一样,由于数据模型上存在差异,所以在每个ZooKeeper key写时需要写多个key。

zetcd solves how to remove the dependence of applications on ZooKeeper

下图揭示了zetcd客户端并发数与key取值的平均延迟之间的关系。由于ZooKeeper的取值延迟比etcd要快那么2ms左右,想要zetcd提供数据的速度快过ZooKeeper的话恐怕还得依赖于etcd本身性能的进一步提升。然而,尽管zetcd需要从etcd请求额外的key来模拟Zookeeper znode的元数据,zetcd的命中延迟在等待etcd key提取数据方面只增加了大概1.5ms。zetcd在key的数据提取操作方面仅需一次往返,因为读请求会被打包到一个etcd事务中。

zetcd solves how to remove the dependence of applications on ZooKeeper
zetcd承诺上述性能基准测试的结果是合理的,在可接受的延迟情况下,可以轻松支撑每秒上千个操作。以上模拟对于Mesos,Kafka和Drill替代ZooKeeper提供了一个替代选择。但是对于zetcd本身来说性能方面仍有不少的提升空间。与此同时测试更多的ZooKeeper应用也会进一步推动zetcd成为ZooKeeper服务器的替代品。

zetcd从去年十月开始在开源社区发行,最近刚发布第一个版本:zetcd v0.0.1。尽管是第一个beta发行版,但是已经为未来生产系统提供稳定管理和部署。如果跟etcd配合起来使用,运行zetcd的系统将会一套自驱动的“ZooKeeper”集群,它可以自动后台升级,备份和TLS管理。

深入浅出学习etcd

etcd为分布式系统提供可靠、高效的配置管理服务,在Docker、Kubernetes、Mesos等平台中扮演了越来越重要的角色。作为2013年开始的项目,它还很年轻,官方文档中缺乏实现上全面、系统的介绍,本课程深入浅出地介绍了etcd的实现,并为运维和二次开发提供了系统的指导和建议。

The above is the detailed content of zetcd solves how to remove the dependence of applications on ZooKeeper. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:Linux就该这么学. If there is any infringement, please contact admin@php.cn delete
What are the differences in virtualization support between Linux and Windows?What are the differences in virtualization support between Linux and Windows?Apr 22, 2025 pm 06:09 PM

The main differences between Linux and Windows in virtualization support are: 1) Linux provides KVM and Xen, with outstanding performance and flexibility, suitable for high customization environments; 2) Windows supports virtualization through Hyper-V, with a friendly interface, and is closely integrated with the Microsoft ecosystem, suitable for enterprises that rely on Microsoft software.

What are the main tasks of a Linux system administrator?What are the main tasks of a Linux system administrator?Apr 19, 2025 am 12:23 AM

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Is it hard to learn Linux?Is it hard to learn Linux?Apr 18, 2025 am 12:23 AM

Learning Linux is not difficult. 1.Linux is an open source operating system based on Unix and is widely used in servers, embedded systems and personal computers. 2. Understanding file system and permission management is the key. The file system is hierarchical, and permissions include reading, writing and execution. 3. Package management systems such as apt and dnf make software management convenient. 4. Process management is implemented through ps and top commands. 5. Start learning from basic commands such as mkdir, cd, touch and nano, and then try advanced usage such as shell scripts and text processing. 6. Common errors such as permission problems can be solved through sudo and chmod. 7. Performance optimization suggestions include using htop to monitor resources, cleaning unnecessary files, and using sy

What is the salary of Linux administrator?What is the salary of Linux administrator?Apr 17, 2025 am 12:24 AM

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

What is the main purpose of Linux?What is the main purpose of Linux?Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Does the internet run on Linux?Does the internet run on Linux?Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations?What are Linux operations?Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Boost Productivity with Custom Command Shortcuts Using Linux AliasesBoost Productivity with Custom Command Shortcuts Using Linux AliasesApr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Atom editor mac version download

Atom editor mac version download

The most popular open source editor