当前位置:网站首页>22-05-26 Xi'an interview question (01) preparation
22-05-26 Xi'an interview question (01) preparation
2022-07-03 08:48:00 【£ small feather】
I. Copy of object : Deep copy and light copy
An object exists 2 There are two types of properties , One is basic data type , One is the reference of instance object
Shallow copy refers to : Copy the value of the basic data type and the reference address of the instance object , It will not copy the object pointed to by a reference object , That is, the objects that are copied out , Internal reference attributes refer to objects in the same heap in memory .
Deep copy : Copy the value of the basic data type and the object pointed to by the reference address of the instance object , Both will copy . Deeply copied objects , The internal reference attribute points to an object in the same heap no longer as the object pointed to before copying
II. thread deadlock
Conditions to be satisfied by the lock
- A resource can only be used by one thread at a time
- A thread is blocking waiting for a resource , Do not release occupied resources
- A thread has obtained resources , Before use , Can't be forcibly deprived of
Deadlock is to add a necessary condition to the lock
4. A number of threads form end-to-end loops waiting for resource relationships
How to avoid deadlock in the development process ?
Pay attention to the locking sequence , Ensure that each thread locks in the same order
Pay attention to the locking time limit , Set a timeout for the lock
Pay attention to deadlock checking , It's a preventive mechanism , Ensure that deadlocks are discovered and resolved at the first time
III.redis Eliminate key The algorithm of LRU and LFU difference
LRU Algorithm ( Least recently used ,recently):
Eliminate data that has not been accessed for a long time , Take the latest visit time as a reference
LFU Algorithm ( The least used ,frequently)
Eliminate the data that has been accessed the least in recent time , Take the number of times as a reference
In most cases, we can use LRU Strategy , When there is a large amount of hotspot cache data ,LFU Better .
IV. Why use caching
cache purpose : High performance 、 High concurrency .
High performance : Suppose there are many read requests , Then directly put the results of the query in the cache , Just read the cache directly later !
High concurrency : The concurrency of a single cache is mysql Dozens of times of single machine . Cache is memory driven , Memory naturally supports high concurrency .
V: How to ensure the data consistency between cache and database ?
Serialization ensures that no inconsistencies will occur , But it will also cause the throughput of the system to be greatly reduced .
Cache Aside Pattern
- When reading , Read cache first , If there is no cache , Reading database , Then take out the data and put it into the cache , Return response at the same time .
- When it's updated , Update the database first , Then delete the cache .
VI What is? Redis The avalanche of 、 Penetration and breakdown ?
Cache avalanche and penetration , The two biggest problems in caching , Or it doesn't show up , When it does, it's fatal
Cache avalanche : The cache machine went down unexpectedly . The cache is down , here 1 second 5000 Requests all drop to database , Database can't bear it , It will call the police , And then I hung up
Cache penetration : database id It's from 1 At the beginning , As a result, the request from the hacker id All negative numbers . In this case , Not in cache , Request every time “ View cache in nothing ”, Direct query database . The cache penetration in this malicious attack scenario will directly kill the database .
Cache breakdown : That is to say, some key Very hot , Very frequent visits , Centralized high concurrent access , When this key At the moment of failure , A large number of requests break down the cache , Direct request database , It's like making a hole in a barrier .
边栏推荐
- Concurrent programming (III) detailed explanation of synchronized keyword
- [linear table] basic operation of bidirectional linked list specify node exchange
- PHP function date (), y-m-d h:i:s in English case
- How to place the parameters of the controller in the view after encountering the input textarea tag in the TP framework
- JS non Boolean operation - learning notes
- Unity editor expansion - window, sub window, menu, right-click menu (context menu)
- On the difference and connection between find and select in TP5 framework
- Pit & ADB wireless debugging of vivo real machine debugging
- Downward compatibility and upward compatibility
- 796 · unlock
猜你喜欢

Animation_ IK overview

Try to reprint an article about CSDN reprint

Analysis of Alibaba canal principle

Data analysis exercises

Jupyter remote server configuration and server startup

First Servlet

单调栈-42. 接雨水

数据库原理期末复习

Thymeleaf 404 reports an error: there was unexpected error (type=not found, status=404)

Explain sizeof, strlen, pointer, array and other combination questions in detail
随机推荐
数据库原理期末复习
Deeply understand the underlying data structure of MySQL index
Life cycle of Servlet
Gradle's method of dynamically modifying APK package name
Unity editor expansion - scrolling list
Swagger document configuration
[rust notes] 12 closure
Final review of Database Principles
Simple demo of solving BP neural network by gradient descent method
Redis cluster series 4
Alibaba canal actual combat
[cloud native] introduction and use of feign of microservices
22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制
file_ put_ contents
[concurrent programming] concurrent tool class of thread
796 · 开锁
Cesium for unreal quick start - simple scenario configuration
Notes and bugs generated during the use of h:i:s and y-m-d
How does unity fixedupdate call at a fixed frame rate
【Rust笔记】05-错误处理