当前位置:网站首页>Common interview questions of redis factory
Common interview questions of redis factory
2022-07-05 22:01:00 【The sea of waves】
Redis Common interview questions in large factories
Redis Application scenarios of
- buffer
- Ranking List
- Counter
- Distributed session
- Distributed lock
- Social networks
- Latest list
- The messaging system
See in detail Redis Of 8 Big application scenarios
Redis Consistency between buffer and database
Some time , Multiple system instances update a key. Can be based on Zookeeper Implement distributed locks . Each system passes Zookeeper Acquire distributed lock , Ensure the same time , Only one system instance can operate on one Key, No one else is allowed to read or write .
Data you want to write to the cache , from MySQL It was found in the , You have to write MySQL in , write in MySQL A time stamp must be saved in , from MySQL When we find out , Time stamps are also found .
Every time before you write , Let's first judge the current one Value Is the timestamp of the Value The time stamp of should be new . If so , Then you can write , otherwise , You can't overwrite new data with old data .
See in detail Redis, Double write consistency 、 Concurrent competition 、 Threading model
Redis Distributed lock and its principle
It is realized by the following four commands :
- setnx
- getset
- expire
- del
See in detail redis Principle and implementation of distributed lock
Redis Solve client session Share Information ?
in consideration of session Medium data similar map Structure , use redis in hash Storage session The data is appropriate , If you use a single value Storage session data , Without a lock , There will be session The problem of coverage , Therefore use hash Storage session, Save only this change at a time session Attribute data , Lock handling is avoided , Better performance .
If I change each one session Property to trigger the store , There is a lot of change session Property will be triggered multiple times redis Write operations , There is also an impact on performance , We are at the end of each request , Do it once session Writing , And it writes the changed property .
If you didn't do it this time session Change of , I can't do it redis Written in , Only if there is no change session Exceeding a time threshold ( Constant change session Refreshes the threshold for the expiration time ), It will trigger session preservation , In order to session Can extend the validity period .
See in detail In a few minutes redis Storage session share —— Design implementation
Redis What problems do distributed locks solve ?
1.1 Locks need to be unique
1.2 The lock needs to have a timeout , Prevent deadlock
1.3 Lock creation and lock timeout setting need to be atomic
1.4 Lock timeout problem
1.5 Reentrant problem of lock
1.6 The problem of distributed locks under clusters
See in detail Redis Problems and solutions faced by distributed locks
Redis Why can distributed locks be supported ? How to use it ?
Redis Single process single thread mode , Using queue mode to change concurrent access into serial access , And multi client pairs Redis There's no competition for the connection .
See in detail Why? redis Can do distributed lock
Redis Of Buffer avalanche , Buffer penetration , Buffer breakdown , And Solutions
See in detail Cache avalanche 、 breakdown 、 through ( With answers )
Redis Persistence mechanism of , Elimination strategy
Redis Master slave copy
Redis Sentinel mechanism
The three questions above , See in detail Redis, sentry 、 Persistence 、 Master-slave 、 Tear your hands LRU, I've got it all sorted out
Zset Underlying data structure , as well as ziplist and skiplist
zset The underlying storage structure includes ziplist or skiplist, Use when both of the following conditions are met ziplist, Other times skiplist, The two conditions are as follows :
- The ordered set holds less elements than 128 individual
- The length of all elements saved in an ordered set is less than 64 byte
When ziplist As zset The underlying storage structure of , Each collection element uses two packed list nodes next to each other to hold , The first node holds the members of the element , The second element holds the score of the element .
When skiplist As zset The underlying storage structure , Use skiplist Save elements and scores in order , Use dict To save the mapping relationship between elements and scores .
See in detail redis zset Underlying data structure
边栏推荐
- 华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
- Did you brush the real title of the blue bridge cup over the years? Come here and teach you to counter attack!
- Dbeaver executes multiple insert into error processing at the same time
- 华为快游戏调用登录接口失败,返回错误码 -1
- crm创建基于fetch自己的自定义报告
- PIP install beatifulsoup4 installation failed
- The American Championship is about to start. Are you ready?
- Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
- Shell script, awk uses if, for process control
- Huawei fast game failed to call the login interface, and returned error code -1
猜你喜欢
Huawei fast game failed to call the login interface, and returned error code -1
深信服X计划-网络协议基础 DNS
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
Analysis and test of ModbusRTU communication protocol
元宇宙中的三大“派系”
Deeply convinced plan X - network protocol basic DNS
Cold violence -- another perspective of objective function setting
Installation of VMware Workstation
Shell script, awk condition judgment and logic comparison &||
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
随机推荐
How can Huawei online match improve the success rate of player matching
Livelocks and deadlocks of concurrency control
Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
Two stage locking protocol for concurrency control
Exercise 1 simple training of R language drawing
K210 learning notes (IV) k210 runs multiple models at the same time
Robot operation mechanism
华为联机对战如何提升玩家匹配成功几率
Net small and medium-sized enterprise project development framework series (one)
Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~
Robot framework setting variables
Regular expressions and re Libraries
Learning of mall permission module
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
EBS Oracle 11g 克隆步骤(单节点)
数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
Environment configuration problem record
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
Pointer parameter passing vs reference parameter passing vs value parameter passing
【愚公系列】2022年7月 Go教学课程 004-Go代码注释