当前位置:网站首页>Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed

Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed

2022-07-06 07:24:00 Java enthusiast

Preface

As the baldhead of this time code , Yes Redis It must be no stranger , If even Redis It's not used , I'm sorry to go out for an interview , I'm not sure how many times I've been beaten by the interviewer . After all, now Internet companies and some start-ups have to use Redis, Like Amazon 、 Google 、 Ali 、 Tencent should use , We can see that we are proficient in Redis It's really necessary to use . For myself, I hung up on the interview with ALI last year redis On the issue of , I'm not familiar with myself redis The second is that Ali's interview question is too difficult , Just give me a few words , See if you can answer :

  • redis Why key,value Of , Why not support SQL Of ?
  • redis Multi thread or single thread ?( Answer the single thread, please go back , Why do you come back , Please look down )
  • redis The persistence of RDB and AOF How does the restart service load ?(10 personal 9 A wrong answer )
  • redis How to plan a cluster ?AKF/CAP How to implement and Design ?
  • 10 Ten thousand users a year 365 How to use the login status of days redis Storage , And quickly retrieve the active users in any time window ?
  • redis Of 5 Kind of Value Type you've used several , Can you give me an example ?
  • 100 Million concurrent 4G data ,10 Million concurrent 400G data , How to design Redis storage ?

As excellent as I was, I was pressed hard on the ground and rubbed , In order to solve this problem, I specially got a copy from Tencent cloud's good brother, which was coded by Tencent cloud God himself “redis In depth notes ”, Let's share it for free today , There is no nonsense in the notes , The whole article looks at the essence !

Due to space limitations, only screenshots can be shown below , Need full version pdf My friend, please like, pay attention and support , Follow me and send a private message “redis” You can get this information for free

PART1:Redis In depth notes begin

1.Redis What can you do with it ?

  • from Redis What I think of in the interview
  • Redis What can be done ?

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

2.Redis Infrastructure

  • Redis install
  • Redis Basic data structure
  • General rules of container data structure
  • About Redis Some thoughts on using

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

PART2:Redis Summary of the application of

1. Distributed lock

  • Distributed lock
  • Timeout problem
  • Reentrancy

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

2. Delay queue

  • Asynchronous message queuing ?
  • What to do if the queue is empty ?
  • Queue delay
  • The idle connection is automatically disconnected
  • Lock conflict handling
  • The implementation of delay queue
  • Further optimization

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

3. Bitmap

  • Basic use
  • Statistics and search
  • Magic command bitfield

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

4.HyperLogLog

  • Usage method
  • pfadd This pf What does that mean? ?
  • pfmerge Suitable for what field ?
  • matters needing attention
  • HyperLogLog Realization principle
  • pf Why is the memory usage of 12k?

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

5. The bloon filter

  • What is a bloon filter ?
  • Redis Bloom filter in
  • Basic use of Bloom filter
  • matters needing attention
  • The principle of Bloom filter
  • Space occupancy estimates
  • When the actual element exceeds , How the miscalculation rate will change ?
  • It will not be on Redis4.0 What do I do ?
  • Other applications of Blum filter

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

6. Simple current limiting

  • How to use Redis To implement a simple current limiting strategy ?

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

7. Funnel restriction

  • Redis-Cell
  • Some thoughts

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

8.GeoHash

  • Use the database to count people in the neighborhood
  • GeoHash Algorithm
  • Redis Of Geo The command basically uses

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

9.Scan

  • scan Based on using
  • Structure of dictionary
  • scan traversal order
  • Dictionary expansion
  • Compare the traversal order before and after capacity expansion
  • Progressive type rehash
  • added scan Instructions
  • Big Key scanning

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

PART3:Redis Principle

1. Threads IO Model

  • Non blocking IO
  • Event polling ( Multiplexing )
  • Command queue
  • Response queue
  • Timing task

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

2. Communication protocol

  • RESP(Redis Serialization Protocol)
  • client -> Server side
  • Server side -> client

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

3. Persistence

  • Snapshot principle
  • fork( Multi process )
  • AOF principle
  • AOF rewrite
  • fsync
  • Operation and maintenance
  • Redis4.0 Mix persistence

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

Due to space limitations, only screenshots can show this information , Need full version pdf My friend, please like, pay attention and support , Follow me and send a private message “redis” You can get this information for free

4. The Conduit

  • Redis Message interaction
  • Pipeline pressure test
  • In depth understanding of the nature of the pipeline

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

5. Business

  • Redis Basic use of transactions
  • Atomicity
  • discard( discarded )
  • Optimize
  • Watch

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

6.PubSub

  • Message multicast
  • PubSub
  • Mode subscription
  • Message structure
  • PubSub shortcoming

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

Due to space limitations, only screenshots can be shown below , Need full version pdf My friend, please like, pay attention and support , I put the free access method in the comment area

7. Small object compression

  • 32bit vs 64bit
  • Small object compression storage (ziplist)
  • Memory recovery mechanism
  • Memory allocation algorithm

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

8. Master slave synchronization

  • CAP principle
  • Final agreement
  • Master slave synchronization
  • The incremental synchronization
  • Snapshot synchronization
  • Add slave
  • Copy without disk
  • Wait Instructions

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

PART4:Redis colony

1.Sentinel

  • Lost message
  • Sentinel Basic use

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

2.Codis

  • Codis Fragmentation principle
  • Different Codis How to synchronize the slot relationship between instances ?
  • Capacity expansion
  • Automatic equalization
  • Codis The price of
  • Codis The advantages of
  • MGET The operation of the command
  • Structural change
  • Codis Embarrassment
  • Codis Back office management

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

3.Cluster

  • Slot location algorithm
  • Jump
  • transfer
  • Fault tolerance
  • The network jitter
  • Maybe offline (PFAIL-Possibly Fail) And confirm offline (Fail)
  • Cluster Basic use
  • Slot migration perception
  • Cluster change awareness

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

PART5:Redis expand

1.Stream

  • news ID
  • The message content
  • Additions and deletions
  • Independent consumption
  • Create a consumption group
  • consumption
  • Stream What to do if there is too much news ?
  • If the news is forgotten ACK What will happen ?
  • PEL How to avoid message loss ?
  • Stream High availability
  • Partition Partition

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

2.Info Instructions

  • Redis How many instructions are executed per second ?
  • Redis How many clients are connected ?
  • Redisn How much memory is used ?
  • How large is the copy backlog cache ?

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

Due to space limitations, only screenshots can show this information , Need full version pdf My friend, please like, pay attention and support , Follow me and send a private message “redis” You can get this information for free

3. Let's talk about distributed locks

  • Redlock Algorithm
  • Redlock Use scenarios

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

4. Expiration strategy

  • overdue key aggregate
  • Timing scan strategy
  • Expiration policy of slave Library

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

5.LRU

  • LRU Algorithm
  • The approximate LRU Algorithm

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

6. Lazy delete

  • Redis Why lazy delete (lazy free)?
  • flush
  • Asynchronous queues
  • AOF Sync Very slow, too
  • More asynchronous delete points

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

7. Use... Gracefully Jedis

  • retry

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

8. Protect Redis

  • Command security
  • Port security
  • Lua Script security
  • SSL agent

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

9.Redis Secure communications

  • spiped principle
  • spiped Getting started

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

PART6: Source code

1. Explore the internal structure of strings

  • embstr vs raw
  • Expansion strategy

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

2. Explore the inside of the dictionary

  • dict internal structure
  • Progressive type rehash
  • Lookup process
  • hash function
  • hash attack
  • Capacity expansion condition
  • Reduction conditions
  • set Structure

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

3. Explore the inside of the compressed list

  • Add elements
  • update cascade
  • IntSet Set of small integers

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

4. Explore the quick list inside

  • Every ziplist How many elements are there ?
  • Compression depth

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

5. Explore the internal structure of the jump list

  • The basic structure
  • Lookup process
  • Random number of layers
  • Insertion process
  • Delete process
  • The update process
  • If score It's all the same ?
  • How is the element ranking calculated ?

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

6. Explore the inside of the compact list

  • update cascade
  • replace ziplist

 Tencent cloud God Pro code “redis In depth notes ”, No nonsense , It's all cream

summary

Last , What I want to say is , Learning is not difficult , And it's about persistence , Especially after we got involved in the work , It's even harder to keep learning . But for programmers , Learning is the foundation of a career , If you give up learning , It's a matter of time before we are eliminated by the market . therefore , Learning more new knowledge is a bigger investment for yourself .

above , To this end .

Due to space limitations, only part of the content can be displayed. If you need this information, please praise, pay attention and support , Follow me and send a private message “redis” You can get this information for free

原网站

版权声明
本文为[Java enthusiast]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131924510784.html