Ali Architect 8 asks Redis, how many can you answer?

Redis claims to support 110,000 concurrent read operations and 80,000 concurrent write operations. Because of its excellent performance and convenient operation, Redis is very popular in major domestic companies, such as Ali, Tencent, ByteDance, Baidu, Meituan, Xiaomi, etc.

How many can you answer these 8 classic interview questions about Redis?

1. Why doesn't Redis officially provide a Windows version? <Linux has something to say>

Because the current Linux version is quite stable, and the epoll-related functions that come with the Linux operating system are generally better than the windows select function in high concurrency situations, for the sake of high performance, the Redis official website does not provide the windows version.

Ali Architect 8 asks Redis, how many can you answer?

 

2. What are the disadvantages of using Redis?

  • Cache and database double write consistency problem
  • Cache avalanche problem
  • Cache breakdown problem
  • Cache concurrency competition problem

3.Is Redis single-threaded or multi-threaded?

Answer: The main thread is single-threaded, but the thread mechanism has been adjusted before and after 6.0. Just read the picture below (it doesn't matter if you don't understand it, I will talk about it later)

Ali Architect 8 asks Redis, how many can you answer?

 

4. There are 2000w data in MySQL, and only 20w data in redis. How to ensure that the data in redis are all hot data?

Very simple, when the size of the Redis memory data set rises to a certain size, the data elimination strategy will be implemented.

5. Redis expiration strategy and memory elimination mechanism?

Positive solution: Redis uses a regular deletion + lazy deletion strategy.

6. How is the persistence bottom layer of Redis implemented? What are the advantages and disadvantages?

RDB: Synchronize the snapshots generated by redis data to disks and other media at different points in time): Snapshots from the memory to the hard disk, updated regularly.

Disadvantages: time-consuming, performance-consuming (fork+io operation), easy to lose data.

AOF: Record all the instructions executed by redis. When redis restarts next time, only need to execute the instructions): Write log.

Disadvantages: large size and slow recovery speed.

After Redis4.0 has the function of hybrid persistence, the full amount of bgsave and the increment of aof are fused, which not only ensures the efficiency of recovery but also takes into account the security of the data.

7. What is cache penetration? How to solve the problem of cache penetration?

Cache penetration refers to querying a data that must not exist. If the data cannot be found from the storage layer, it will not be written to the cache. This will cause the non-existent data to be queried in the DB every time it is requested, which may cause the DB to hang .

The penetration solution is as follows:

1. If the data returned by the query is empty, the empty result will still be cached, but the expiration time will be relatively short;

2. Bloom filter: Hash all possible data into a bitmap that is large enough. A data that must not exist will be intercepted by this bitmap, thereby avoiding querying the DB.

8. Redis common performance problems and solutions

Can you answer this one?

Friends who want to know the answer,

You can go to station B to search: Xiangxue Class Online,

Private chat up host, join the technical exchange group~

You can also get the interview information for free~

Guess you like

Origin blog.csdn.net/EnjoyEDU/article/details/108230644