Technology nerd guy: See what the interviewer asked (Java series)

Hello. First of all, let me make a simple self-introduction, hello interviewer, I am... ok. So in your 6 years of work experience, you have accumulated a lot of technical experience, and the most familiar technologies are Redis and Spring. Let's start the conversation with the technology you are good at.

The sentinel mechanism of Radis implements cluster monitoring and distributed high-availability solutions, and is mainly used to monitor the status of Leader and Follower. If the Leader fails, it will select a Leader from the Followers, and then pass the change to Radis. If the sentinel is also down, it will trigger the automatic election of the sentinel, which realizes the high availability of Radis composition replication. The Nacos registration center used in Spring Cloud also has similar elections, and in the message queue, the typical composition election in Kafka. ZooKeeper also has a Leader election process, they are all for solving some distributed system solutions.

In the e-commerce scene, the seckill scene is a scene that everyone is very familiar with. If you were to develop this flash sale scenario, you might encounter many challenges. First of all, at the traffic entrance, there may be a large number of user requests arriving at the server at the same time. On the server side, limited resources are used to process requests, and concurrent and fast responses to these user requests are required. Therefore, after the traffic enters the ingress, we may need to perform operations such as traffic limitation, rights protection, logging, and monitoring. After the traffic enters the ingress, we still need to solve some problems such as traffic crossover, resource isolation, service area optimization, etc., and also need to use some classic load balancing and dynamic ingress. When the traffic enters the entrance and is received, we may also need to perform some operations such as service degradation, service throttling, and request rejection. Later, when the request penetrates to this part, we may also need to use the cache for processing, and may trigger some concurrency model scenarios, such as distributed lock synchronization or not, inventory deduction, etc.

In Java development, most developers use frameworks for development. In fact, it is not so much developed in Java as it is developed in Spring. According to your introduction, Redis is also a technology you are more familiar with. When using Redis, the most common entry point is wearable VC. So please briefly describe in your own language, how does Redis manage data through the hash algorithm?

Before understanding this, we must first understand a concept, what is a hash. Hashing is actually converting an input of arbitrary length into a fixed-length output through a hash algorithm. This is also one of its advantages, because it uses pure data, so its implementation complexity is O(1). Then, it is the underlying data structure of Map, which stores data in the form of an array plus a list. The form of data plus list is actually to solve the problem of hash collision. For the same value, it concatenates using lists, then fills each list with data. In the case of any length, we can hash the key and use the hash algorithm to get a fixed output value. We can then use it to do modulo. After taking the modulus, because our data structure is an array plus a list, we will get an array subscript, and then store it in the list. The list is actually a Key-Value structure of a No node that inherits a security node. It stores a hash of a No node, a Key-Value, and a pointer to the next single table. When you make a query, we get the sum of the numbers through its algorithm, and then if the array is empty, insert it directly. If it is not empty, we have to loop through the list to find out whether the Key is equal, if it is equal, modify its value, if not, add the Key-Value at the end of the list and so on.

Hello. First of all, let me make a simple self-introduction, hello interviewer, I am... ok. So in your 6 years of work experience, you have accumulated a lot of technical experience, and the most familiar technologies are Redis and Spring. Let's start the conversation with the technology you are good at.

The sentinel mechanism of Radis implements cluster monitoring and distributed high-availability solutions, and is mainly used to monitor the status of Leader and Follower. If the Leader fails, it will select a Leader from the Followers, and then pass the change to Radis. If the sentinel is also down, it will trigger the automatic election of the sentinel, which realizes the high availability of Radis composition replication. The Nacos registration center used in Spring Cloud also has similar elections, and in the message queue, the typical composition election in Kafka. ZooKeeper also has a Leader election process, they are all for solving some distributed system solutions.

In the e-commerce scene, the seckill scene is a scene that everyone is very familiar with. If you were to develop this flash sale scenario, you might encounter many challenges. First of all, at the traffic entrance, there may be a large number of user requests arriving at the server at the same time. On the server side, limited resources are used to process requests, and concurrent and fast responses to these user requests are required. Therefore, after the traffic enters the ingress, we may need to perform operations such as traffic limitation, rights protection, logging, and monitoring. After the traffic enters the ingress, we still need to solve some problems such as traffic crossover, resource isolation, service area optimization, etc., and also need to use some classic load balancing and dynamic ingress. When the traffic enters the entrance and is received, we may also need to perform some operations such as service degradation, service throttling, and request rejection. Later, when the request penetrates to this part, we may also need to use the cache for processing, and may trigger some concurrency model scenarios, such as distributed lock synchronization or not, inventory deduction, etc.

In Java development, most developers use frameworks for development. In fact, it is not so much developed in Java as it is developed in Spring. According to your introduction, Redis is also a technology you are more familiar with. When using Redis, the most common entry point is wearable VC. So please briefly describe in your own language, how does Redis manage data through the hash algorithm?

Before understanding this, we must first understand a concept, what is a hash. Hashing is actually converting an input of arbitrary length into a fixed-length output through a hash algorithm. This is also one of its advantages, because it uses pure data, so its implementation complexity is O(1). Then, it is the underlying data structure of Map, which stores data in the form of an array plus a list. The form of data plus list is actually to solve the problem of hash collision. For the same value, it concatenates using lists, then fills each list with data. In the case of any length, we can hash the key and use the hash algorithm to get a fixed output value. We can then use it to do modulo. After taking the modulus, because our data structure is an array plus a list, we will get an array subscript, and then store it in the list. The list is actually a Key-Value structure of a No node that inherits a security node. It stores a hash of a No node, a Key-Value, and a pointer to the next single table. When you make a query, we get the sum of the numbers through its algorithm, and then if the array is empty, insert it directly. If it is not empty, we have to loop through the list to find out whether the Key is equal, if it is equal, modify its value, if not, add the Key-Value at the end of the list and so on.

Besides Redis, which distributed technologies are you familiar with? In distributed systems, one of the most commonly used technologies is distributed locks. Can you introduce the implementation principles of distributed locks for us?

Guess you like

Origin blog.csdn.net/2301_76992670/article/details/129906602