Summary of java interview questions (9) - redis interview questions

Original link

 

Programmers are not only under pressure at work, but also under pressure during the New Year. Classmates are most afraid of being asked about their salary. . . I went for an interview before the Spring Festival was over, but I met...

The interviewer asked this life-threatening series of 12 questions, who can stand it?Image

Interviewer: Classmates, I think you use Redis in every project. Can you tell me how you use Redis?

 

Classmate A: Mainly used for caching, distributed session, reading/like count statistics

 

Interviewer: Okay, how does Redis do persistence? 

 

Classmate A: bgsave does full persistence to RDB binary files, aof does incremental persistence, and stores text protocol data.  

 

Interviewer: What are their advantages and disadvantages?

 

Student A: Rdb binary files can start and load faster, and aof needs to replay commands, so the speed is slower

 

Image

 

Interviewer: During Redis persistence, can the main process still provide external services?

 

Classmate A: Yes

 

Interviewer: How does Redis handle newly written data? Will this data be directly persisted? 

 

Classmate A:. . . This is possible!     

 

Interviewer: Reids can set the maximum memory size. If the data reaches the maximum memory limit, how does Redis handle it?

 

Student A: You can configure the elimination strategy LRU or LFU elimination strategy.

 

Interviewer: Can you talk about the implementation principle of Redis's LRU algorithm?

 

Student A: This is not so clear.

 

Image

 

Interviewer: What are the core data types of Redis?

 

Classmate A: string, hash, list, set, zset.

 

Interviewer: How do you choose string type and hash type to store data?

 

Classmate A: string To obtain a certain data in a large number of field objects, it is necessary to obtain the overall data, and complete the deserialization on the client side, and hash can obtain the specified field to obtain the data. So choose according to the access needs.

 

Interviewer: Are there any other considerations? 

 

Classmate A: No

 

Interviewer: Have you understood the underlying implementation principle of zset?

 

Student A: It seems to be realized by jumping the watch!

 

Interviewer: Can you talk about its implementation principle and time complexity analysis?

 

Student A: This is not so clear. 

 

Image

 

Interviewer: Can you talk about cache penetration?

 

Student A: The data to be queried does not exist in the cache and directly hits the database. If there are many such requests, all of them penetrate the database, which will cause the database to crash.

 

Interviewer: What about the solution?

 

Student A: You can use a Bloom filter to block it.

 

Interviewer: What is the realization principle of Bloom filter? Can you tell me something?

 

Student A: This is not so clear.

 

Interviewer: Okay, thank you for participating in our company’s interview, let’s get here first today

 

Image

Why do I always encounter Redis problems in interviews? Redis has a clear understanding of the underlying design principles, but can't I just say it? What can I do if I encounter these Redis interview questions in the future? Just think about it!

Redis high concurrency architecture design and source code analysis course content:

Section 1: Double Eleven Seckill System Backend Redis High Concurrency Architecture Actual Combat

1. Reproduce the actual combat of oversold bugs in high-concurrency scenarios

2. Practical JVM-level locks and distributed locks in the spike scenario

3. The actual combat of the Redisson framework of distributed locks

4. Analyze Lua from Redisson source code to solve the atomicity problem of locks

5. Redis master-slave architecture lock failure problem and Redlock detailed explanation

6. How to increase the performance of distributed locks by 100 times during the Double Eleven Promotion

7. Use the Redis cache cluster architecture to resist the double eleven major traffic peaks

8. Analyze the similarities and differences of Redis&Zookeeper lock architecture from the perspective of CAP

9. The ultimate solution to the inconsistency between Redis cache and database double write

 

Section 2: 100 million traffic Sina Weibo and WeChat Redis architecture combat

1. Redis core data storage structure

2. Detailed explanation of Redis underlying string encoding int&embstr&raw

3. Detailed explanation of Redis bottom compression list & jump table & hash table

4. How to choose the compressed list and jump table implemented by the ZSet at the bottom of Redis

5. Implementation of Weibo and WeChat message flow Redis

6. WeChat likes, collections and tags are implemented based on Redis

7. Weibo and WeChat friends follow model based on Redis implementation

8. People near Weibo are based on Redis

9. How to implement e-commerce shopping cart with Redis

10. How to implement e-commerce recommendation system with Redis

 

Section 3: Go deep into the underlying C source code to explain Redis high-performance data structure

1. Introducing the core data structure of Redis

2. Daily live statistics of billion-level users BitMap actual combat

3. Analysis of the underlying implementation principle of Redis blocking queue

4. How to implement a high-performance delay queue

5. Find nearby people based on Geohash

6. In-depth analysis of C source code analysis of ZSet bottom jump table implementation

7. In-depth C source code analysis of Redis core data structure design

8, Redis 6.0 multi-threaded compared to single-threaded optimization

 

 

Guess you like

Origin blog.csdn.net/lsx2017/article/details/114040015