Received offer, Infrastructure direction - Distributed storage - Block storage / file store .

<> Byte skipping side (55min)

Talk about the relationship between processes ?
I talked about various ways of process communication , The relationship between father and son process .
Database index ?
I mentioned clustered and nonclustered indexes , He said that just talking about clustered index
I mentioned that leaf nodes store data , Offset of non page node storing leaf node
Why do you want to use double linked list instead of single linked list between leaf nodes ?
I don't know , But I think it's common , A leaf node found , The data on this page is incomplete , You also need to look forward and backward to see if there is any data that meets the conditions .
Mainly related to some time queries ( I don't quite understand )
You just said offset , How to understand offset ?
I was a little confused at that time , Now think about it , Is a pointer to a child node , It's a physical address , Make complaints about what to ask .
Redis What are the data types of ?
5 Basic data types , As key Only String, They don't know much about their internal implementation except for the jump table , Everything else .
Redis Of RDB You know what ?

I : I Know RDB You can key-value Key value pair persisted to disk , adopt SAVE and BGSAVE Start persistence ,SAVE Will block the main process ,BGSAVE Meeting fork A subprocess ,BGSAVE During execution SAVE Will be blocked , This is to prevent two subprocesses from calling at the same time rdbSave, Generate conditional competition .
he :SAVE Why is it blocked ?
I :Redis It's a single threaded design .
he : Let yourself do it BGSAVE How do you do it? ?
I : in limine , Copy all the data in memory , Then persist this copy to disk , The other will continue to be updated .
he : If the amount of data in memory is large ? How long does it take you to make a copy , And the memory space is wasted .

I : That is to persist the data of the main process to the local directly in the sub process ( Data sharing due to parent-child process ), In the process , Main process faces new modification , First, save the changes , Wait until the subprocess finishes persistence , Send a signal to the parent process , Make new changes in the callback function of the parent process , insert , Delete overwrite old data .
given 1 Year data , The data record contains ( login time , Logout time , user id), Enter a time stamp , Find out the number of online users at this time .( Can't figure out how to do it , Ask for directions )
I said scan the watch , Then judge each record , So the time complexity is O(n).
he : You don't have to think about algorithms , Is there any other way , I don't want you to get into a dead end .

I : I thought about it , I can give an approximate solution , The average user will not log in for a long time , One week ahead and one week back , So after indexing time , First, filter out the records of the previous week and the next week of the input time point according to the time , The time complexity of this screening process is O(lgn), This is by the database B+ Tree search time complexity determines , And then in the filtered data , Scan once , So the amount of data has been greatly reduced . therefore , The overall time complexity can be achieved with even data distribution O(lgn).
he : Think of another way , Don't think about it algorithmically
I : I still want to think about it from the perspective of space for time .
Algorithmic questions : Maximum palindrome string

<> Byte beat two sides (50min)

process , thread , The difference and connection of cooperation process
Redis in RDB and AOF The difference between
AOF If there are many commands in a period of time , Some commands are redundant , This will take up a lot of space , Do you know how he solved the problem ?
AOF Rewriting mechanism of , The principle is to traverse the key in memory , Construct a command corresponding to it , And then store it .
The detail is that the main process executes the new command , And write the command AOF Buffer and AOF Rewrite buffer , Subprocess complete AOF rewrite ( Traversing the shared data of parent-child processes )
Redis,Memcache,Mysql,Mongo Do you know the difference between these databases ?
How to RabbitMQ Implement a synchronous communication framework ?
After thinking, it gives a general direction and thinking
RabbitMQ Some of them exchange Do you know anything ?
I said what I read on my resume , It's really just understanding , Not this , Please don't ask RabbitMQ Principle
InnoDB and MyISAM The difference between
balabala, Row lock and table lock are not mentioned
he : You feel InnoDB and MyISAM Whose performance is better ?
I : Thinking
he : Here's a hint , Analysis from the perspective of lock .
I : Oh, oh ,InnoDB Row level lock combined with table level lock ,MyISAM It's a watch lock , therefore InnoDB Better efficiency
he : Then you talk about the database lock mechanism
Yes S lock ,X lock , Design principle of intention lock , And their compatibility
Some problems brought by lock , Several isolation levels are mentioned ,MVCC, as well as MVCC Problems solved
Scene questions , A user opens a record , And then another user opened the record , They see the same data , At this time A Modified record ,B The record has also been modified ,A Modified by B Covered , What should I do? ?
I : In fact, the database has been able to ensure that the loss of updates will not occur , But this problem is actually the loss and update in the logical sense , There are two solutions :
1. user A Read data plus write lock of select …. for update.
2. Implementation without lock , use CAS His thoughts described him .
Algorithmic questions : Judge whether it is a mirror binary tree
It wasn't the best solution at the beginning , First, we construct a binary image tree by traversing ourselves , Then traverse and compare whether the two trees are the same .
he : You so , Wasted O(n) Space of , And one more scan
I changed the code , End of one scan .

<> Byte beat three sides (50min)

Chat items
How to realize read-write lock ?
Two variables are used to realize , Let's talk about the following ideas
How can two variables achieve atomicity
Add the modification of these two variables sychronized
synchronized It's too heavy
Can't think of it , Remind me to use 1 Two numbers are represented by digits , So there's no need for an atomic guarantee for these two numbers .
The algorithm problem is the maximum subtree sum ( First, it must contain leaf nodes )
Fast work , The post order traversal writing of binary trees is familiar
Changed the question , Not including leaf nodes .
Let's talk about the following ideas , It's over .
There is still a lot of time , Let's do another algorithm problem , Just talk about your ideas ,10 Billion url Find frequency topK large ?
I gave a complete answer to a thought , Another way of thinking, I think of prefix trees , Gave the answer at the interviewer's suggestion .

Technology
©2019-2020 Toolsou All rights reserved,
html Writing about cherry trees , Writing about cherry trees It's unexpected Python Cherry tree (turtle The gorgeous style of Library ) Browser kernel ( understand )HashMap Explain in detail java Four functional interfaces ( a key , simple )os Simple use of module Some East 14 Pay change 16 salary , Sincerity or routine ?