Remember these collections of Java interview questions, is it still a problem to enter Ali? 2020 latest Java collection of common interview questions + detailed answers (13)

2020 latest Java collection of common interview questions + detailed answers (13)

Continue to update Java related materials. Recently, I have spent a few days consulting the latest interview news of the big bosses, trying to collect more comprehensive interview information. If you want to see the first few collections, you can go to my homepage to find them.

Some of the answers are summarized by myself, and some are collected on the Internet. Don't panic after watching these interviews! If you have more experience, you can share it in the comments. If you have any mistakes, you are welcome to point out. Please feel free to enlighten me, thank you

Kafka

130. Can Kafka be used separately from zookeeper? why?

Kafka cannot be used alone without zookeeper, because kafka uses zookeeper to manage and coordinate kafka's node servers.

131. How many data retention strategies does Kafka have?

Kafka has two data storage strategies: retention according to expiration time and retention according to stored message size.

132. Kafka has set 7 days and 10G to clear data at the same time. By the fifth day, the message reached 10G. How will Kafka handle this?

At this time, Kafka will perform data clearing work, and the data will be cleared regardless of the time and size that meet the conditions.

133. What conditions will cause Kafka to run slower?

  • CPU performance bottleneck

  • Disk read and write bottlenecks

  • Network bottleneck

134. What should I pay attention to when using kafka cluster?

  • The number of clusters is not as large as possible, and it is better not to exceed 7, because the more nodes, the longer the message replication takes, and the lower the throughput of the entire group.

  • The number of clusters is best to be singular, because more than half of the failed clusters cannot be used, and the singular fault tolerance rate is higher.

Zookeeper

135. What is zookeeper?

zookeeper is a distributed, open source distributed application coordination service, an open source implementation of google chubby, and an important component of hadoop and hbase. It is a software that provides consistent services for distributed applications. The functions provided include: configuration maintenance, domain name services, distributed synchronization, group services, etc.

136. What are the functions of zookeeper?

  • Cluster management: monitor the survival status of nodes, operation requests, etc.

  • Primary node election: After the primary node hangs up, a new round of primary election can be started from the standby node. The primary node election refers to this election process, and zookeeper can assist in completing this process.

  • Distributed locks: zookeeper provides two types of locks: exclusive locks and shared locks. Exclusive lock means that only one thread can use the resource at a time. Shared lock means read lock sharing and read-write mutual exclusion. That is, multiple threads can read the same resource at the same time. If a write lock is to be used, only one thread can use it. Zookeeper can control distributed locks.

  • Naming service: In a distributed system, by using a naming service, client applications can obtain resource or service address, provider and other information based on the specified name.

137. How many deployment modes does zookeeper have?

There are three deployment modes for zookeeper:

 

  • Single machine deployment: running on a cluster;

  • Cluster deployment: multiple clusters running;

  • Pseudo cluster deployment: A cluster starts multiple zookeeper instances to run.

138. How does zookeeper ensure the synchronization of the master and slave nodes?

The core of zookeeper is atomic broadcasting. This mechanism ensures synchronization between various servers. The protocol that implements this mechanism is called the zab protocol. The zab protocol has two modes, recovery mode (primary selection) and broadcast mode (synchronization). When the service is started or after the leader crashes, zab enters the recovery mode. When the leader is elected and most of the servers have completed synchronization with the leader's state, the recovery mode ends. State synchronization ensures that the leader and server have the same system state.

139. Why is there a master node in the cluster?

In a distributed environment, some business logic only needs to be executed by a machine in the cluster, and other machines can share this result, which can greatly reduce repeated calculations and improve performance, so a master node is required.

140. There are 3 servers in the cluster, and one of the nodes is down. Can zookeeper still be used at this time?

It can continue to be used, and the singular server can continue to be used as long as no more than half of the servers are down.

141. Tell me about the notification mechanism of zookeeper?

The client will create a watcher event for a znode. When the znode changes, these clients will receive zookeeper notifications, and then the client can make business changes based on the znode changes.

At last

The content of the interview questions is over here, there will be more updates in the follow-up, I hope it will be helpful to everyone.

Finally, I want to say something to you. I have worked for so many years and have interviewed some people for others. Whether it is from the perspective of the interviewer or the leader, in addition to interview skills and experience, great technology and project experience are also their trump cards and confidence. Core technology sharing of first-tier manufacturers

 It took me a long time to sort out some learning materials. What I posted above is the tip of the iceberg in the materials. I hope I can help you! Click to learn the secret code together: csdn

                         

  I will share more pure dry goods articles in the follow-up, and hope to really help you. Your support is my biggest motivation! Welcome to follow and like!

                                                       

Guess you like

Origin blog.csdn.net/weixin_50333534/article/details/108987491