Lock screen interview questions 100 days, adhere to update the interview questions every working day. Lock screen interview questions app, small program has been launched, website address: https://www.demosoftware.cc/#/introductionPage. It has included all the contents of the interview questions updated daily, as well as features such as unlocking screen review interview questions, daily programming questions email push, etc. This will give you a head start in the interview and give the interviewer a leg up! Here are today’s interview questions:
==== What are some ways to reduce Redis memory usage? If you’re using 32-bit Redis instances, make good use of the Hash,list,sorted,set, and other aggregated types of data, because usually a lot of small key-values can be sorted together in a more compact way.
==== What happens when Redis runs out of memory? Redis write commands will return an error message if the upper limit is reached (but read commands will return normally). Or you can use Redis as a cache to configure a culling mechanism that will flush out the old content when the Redis reaches its memory limit.
==== How many keys can a Redis instance hold? List, Set, SortedSet How many elements can they hold at most? Theoretically, Redis can handle up to 2^32 keys, and it has been tested in practice with at least 250 million keys stored in each instance. We are testing some larger values. Any list, set, and sorted set can have 2^32 elements. In other words, the storage limit for Redis is the value of available memory in the system.
==== There is 2000W data in MySQL, but only 20W data in Redis. How to ensure that all the data in Redis are hot data? When the size of the Redis memory dataset increases to a certain size, a data cull policy is implemented. The interviewer will probably ask about the elimination strategy later…
==== Suppose there are 100 million keys in Redis and 10W of them start with some fixed known prefix. What if we find all of them? Use the Keys directive to scan out the list of keys for the specified schema. What’s the problem with using the KEYS directive if the Redis is serving an online business? At this point you need to answer one of the key features of Redis: Redis is single-threaded. The Keys instruction causes the thread to block for a period of time, and the online service to stop until the instruction is completed. At this time, you can use the SCAN instruction. The SCAN instruction can extract the key list of the specified mode without blocking, but there will be a certain probability of repetition. It is enough to do a reduplication in the client, but the overall time will be longer than the direct use of the KEYS instruction.
==== If there are a large number of keys that need to be set to expire at the same time, what should we pay attention to in general? If a large number of key expiration times are set too centrally, Redis may experience short stalling at the expiration point. It is generally necessary to add a random value to the time to spread out the expiration time.
==== Have you ever used Redis for an asynchronous queue and how do you use it? A list structure is generally used as a queue, with RPUSH producing messages and LPOP consuming messages. When there is no message from LPOP, sleep for a while and then try again. If the other side asks, can not use sleep? The list also has an instruction called blpop, which blocks until a message arrives in the absence of a message. And if they ask, can we produce and consume more than once? Using the Pub/Sub Subject Subscriber pattern, a 1:N message queue can be implemented. What are the disadvantages of pub/sub? In the case of a consumer going offline, the produced messages are lost and professional message queues such as RabbitMQ are used. If the other side asks Redis how to implement delayed queue? I’m guessing you’d like to beat the interviewer to death right now if you have a baseball bat in your hand. But you are very restrained, and then answer with an air of composure: use SortedSet, take the timestamp as the score, the message content as the key to call Zadd to produce the message, and the consumer uses the ZRangeByScore command to get the data polling before N seconds for processing. At this point, the interviewer has secretly given you the thumbs up. But what he doesn’t know is that now you’re holding up your middle finger, behind the chair.
More interview questions or learning resources can be found on my homepage or in the comments