Zookeeper is used in many middleware, such as Kafka, Hadoop and HBase, a group of small partners related to big data. Zookeeper is used by many companies as a distributed collaborative management plug-in. Another must-learn technique, here are 36 knowledge points or interview questions that you can add to your collection.

1. CAP theory?

  • C: Consistency: whether data is consistent across multiple copies.

  • System services must always be available and always return results on each request at A specified time.

  • Fault tolerance: Provides consistency and availability in the event of a Partition network failure.


Only two of the three requirements can be met.

2. The BASE theory?

It’s short for Basically Available, Soft state, and Eventuanlly consistent.

  • Basic availability: Allows partial loss of availability in the event of unpredictable system failures.
  • Weak (soft) state: the intermediate state of the data, and the existence of the modified state does not allow for the overall availability of the system and the delay in the synchronization process of data copies of different nodes.
  • Final consistency: All data copies in the system can be synchronized to a consistent state after a period of time.
3. What is ZooKeeper?

ZooKeeper is an open source distributed collaborative service system. The design goal of ZooKeeper is to encapsulate the complex and error-prone distributed consistent services into an efficient and usable primitive set, and provide a series of simple interfaces for users to use.

4. What functions does ZooKeeper provide?

  • Data publish/subscribe
  • Load balancing
  • The naming service
  • Distributed coordination/notification
  • Cluster management
  • Master the election
  • A distributed lock
  • Distributed queue

5. What distributed consistency features can ZooKeeper guarantee?

  • Sequential consistency
  • atomic
  • A single view
  • reliability
  • The real time

6. Data model of ZooKeeper?

A shared tree structure consisting of a series of ZNode data nodes, similar to a file system (directories cannot store data). ZNode stores data information such as version numbers and so on. The hierarchy between ZNodes is like a directory structure in a file system. And it stores data in memory, which improves throughput and reduces latency.

7. How do I identify the order of requests?

ZooKeeper assigns a globally unique increasing number (ZXID) to each update request. The number indicates the order of transaction operations.

Why is it called ZooKeeper?

Ha ha, this interview is not necessary to ask, but after knowing it may feel more intimate. ZooKeeper originated from yahoo research institute, a research team at the beginning of the project, to find that many of the project is to use the names of animals, chief scientist thought can’t continue the animal’s name, it was named zoo keeper, it just the characteristics of distributed collaborative services are consistent, so they are born.

9.A is the root node. How to express B node under A child node?

/A/B

10. Cluster roles?

Leader, Follower, Observer

11. Type of ZNode?

Persistent nodes: Once created, they remain in ZooKeeper until they are removed.

Temporary node: The life cycle is bound to the client session, the session becomes invalid, and the associated temporary node is removed.

Persistent sequential: Sequential at the same time.

Temporary sequentiality: sequential at the same time.

12. What version-related data does Stat record?

Version: indicates the current ZNode version

Cversion: indicates the version of a ZNode child node

Uncomfortable: The ACL version of the current ZNode

12. Permission control?

Access Control Lists,ACL. Permission control similar to UNIX file systems.

14. How many permissions does ZooKeeper define?

  • CREATE
  • READ
  • WRITE
  • DELETE
  • ADMIN

15. What is an atomic broadcast protocol specifically designed by Zookeeper to support crash recovery?

ZAB

16. What are the two basic modes of ZAB?

Crash recovery: It runs very well under normal conditions. Once the Leader crashes or loses contact with half of the followers due to network problems, the Leader server enters crash recovery mode. In order to run the program correctly, a new Leader needs to be elected after the whole recovery process. Therefore, an efficient and reliable election method is needed to quickly elect a Leader.

Message broadcast: Similar to a two-stage submission process, the Leader server will generate the corresponding transaction Proposal for the transaction request of the client and send it to all the other machines in the cluster, then collect their votes respectively, and finally conduct the transaction submission.

17. What circumstances will cause ZAB to enter recovery mode and select a new Leader?

Network interruption, crash, exit, or restart occurs during the startup process or on the Leader.

After a new Leader is elected and more than half of the machines in the cluster have state synchronized with the Leader,ZAB exits recovery mode.

18. Default port of Zookeeper?

2181

19. How to create a ZNode?

create /app

– e temporary

– s order

20. How many deployment modes?

Single machine, pseudo cluster, cluster

21. How do I view child nodes?

ls path [watch]

Path: indicates the path of a node

[zk: localhost:2181(CONNECTED) 5] ls /app
[book]
Copy the code

22. Obtain information about the specified node.

get path [watch]

[zk: localhost:2181(CONNECTED) 1] get /app
123
Copy the code

23. Update information about the specified node.

set path data [version]

[zk: localhost:2181(CONNECTED) 6] set /app 222
[zk: localhost:2181(CONNECTED) 7] get /app
222
Copy the code

24. Delete the specified node? Pay attention to?

delete path [version]

[zk: localhost:2181(CONNECTED) 8] delete /app
Node not empty: /app
Copy the code

If there are no child nodes, the deletion succeeds. If yes, this object is not empty.

25. What is a Session?

It refers to the client session. When the client is started, it will suggest TCP connection with the server. After the connection is successful, the client life cycle begins.

26. Is the session within sessionTimeout still valid when the server is under heavy pressure, the network is faulty, or the client disconnects?

Effective.

27.Watcher event listener?

ZooKeeper allows users to register Watcher on a specified node. When a specific event is triggered, the ZooKeeper server notifies corresponding clients of the event, which is an important feature of ZooKeeper.

28.Quorum?

Normal message propagation occurs when half-up processes in a cluster constitute a subset of processes, called Quorum.

29. What are the two features of communication with the two-process message network of a process group?

  • Integrity: If process A receives a MSG from process B, then process B must have sent the MSG.
  • Preposition: If MSg1 is a pre-message for MSG2, the current process must receive MSg1 before accepting MSG2.

30. Three stages of ZAB?

  • Found (Discovery)
  • Synchronization (Synchronization)
  • Radio (Broadcast)

31. Found?

The Follower sends its final Proposal (CEPOCH(F.p) for accepting a transaction to the Leader.

After receiving a message from half of the followers, the Leader generates a NEWEPOCH(e’) for the half of the followers.

tips: e’ = Max((CEPOCH(F.p)) + 1

If the value of the Follower is less than E ‘after receiving the message, the Follower synchronizes the value of E’ and sends an Ack message to the Leader.

32. Three roles for the server?

Leader role:

Followers role:

The Observer role:

33. Data publish/subscribe?

Publishers publish data to one or more ZooKeeper nodes, and subscribers subscribe data to dynamically obtain data. In this way, centralized configuration information management and dynamic data update are implemented.

34. Two design patterns for publish and subscribe?

Push: A server actively pushes data to all scheduled clients.

Pull: The client initiates a request to retrieve the latest data.

35.ZooKeeper uses push/pull mode?

Push-pull combination

36. How does the client obtain configuration information?

Initiatively pull information to the server at startup, and at the same time, register Watcher listening at the setup node. The server notifies all clients that subscribe to it in real time of any configuration changes.

Reference:

Principles and Practices of Distributed Consistency from Paxos to Zookeeper

ZooKeeper Distributed Process Collaboration


Continuously updated… If you want to see anything, you can leave a message or send me a private message.