Lock screen interview questions 100 days, adhere to update the interview questions every working day. Lock screen interview questions APP and mini-program have been online now, including all the contents of daily updated interview questions, as well as features such as unlocking screen review interview questions, daily programming questions email push and other functions. This will give you a head start in the interview and give the interviewer a leg up! Here are today’s interview questions:
==== The pros and cons of Redis? Pros: a) Extreme performance — Redis can support over 100K+ read/write rates per second. B) Rich data types — Redis supports Strings, Lists, Hashes, Sets, and Ordered Sets data types for binary cases. C) Atomics — All operations of Redis are atomic, and Redis also supports atomic execution after several operations are combined. D) Rich features – Redis also supports publish/subscribe, notifications, key expiration, etc. Disadvantages: a) As it is a memory database, the amount of data stored on a single machine is related to the memory size of the machine itself. Although Redis has its own key expiration policy, it is still necessary to predict ahead of time and save memory. If memory grows too fast, you need to delete data periodically. B) If complete resynchronization is carried out, it will occupy the CPU of the host and consume the bandwidth of the current network due to the need to generate RDB files and transfer them. In version 2.8, there is partial resynchronization, but full resynchronization is possible. For example, the new online standby. C) Modify the configuration file, restart it and load the data from the hard disk into the memory, which takes a long time. In this process, Redis cannot provide services.
==== What about Redis persistence? RDB persistence: This mechanism generates a point-in-time snapshot of a data set at a specified time interval. AOF Persistence: Log all write commands executed by the server and restore the dataset by reexecuting these commands when the server starts. Commands in the AOF file are stored in the format of the Redis protocol, and new commands are appended to the end of the file. Redis can also rewrite the AOF file in the background so that the AOF file is no bigger than the actual size needed to preserve the state of the dataset. Apply both AOF and RDB: When Redis is restarted, it will use AOF files in preference to restore the dataset, because AOF files usually hold a more complete dataset than RDB files.
==== What are the advantages and disadvantages of RDB persistence versus AOF persistence? Pros and Cons of RDB: The RDB is a very compact file that holds a Redis dataset at a point in time. This type of file is ideal for backups: for example, you can back up an RDB file every hour for the last 24 hours, and on every day of the month, you can also back up an RDB file. That way, you can always revert your dataset to a different version if you run into problems. RDB is great for disaster recovery: it has only one file and its contents are so compact that it can be transferred (after encryption) to another data center or Amazon S3. The RDB maximizes Redis performance: the only thing the parent has to do to save an RDB file is fork a child, which then handles all the subsequent saving, without the parent having to perform any disk I/O. RDB can recover large data sets faster than AOF. Cons: If you need to avoid losing data in the event of a server failure, RDB is not for you. Although Redis allows you to set different save points to control the frequency of saving RDB files, it is not an easy operation because RDB files need to save the state of the entire data set. As a result, you may save your RDB files at least once every 5 minutes. In this case, you could lose several minutes of data in the event of a malfunction. Each time the RDB is saved, Redis forks () out a child process that does the actual persistence. When the data set is large, fork() can be very time consuming, causing the server to stop processing the client within milliseconds; If the data set is very large and the CPU time is very tight, the stop time may even last a full second. Advantages and disadvantages of AOF. 1, Using AOF persistence makes Redis much more durable: you can set different fsync policies, such as no fsync, fsync every second, or fsync every time a written command is executed. AOF’s default policy is fsync once per second, which still allows Redis to perform well and lose at most a second of data in the event of a malfunction (fsync is executed in the background thread, so the main thread can continue to process command requests as hard as it can). An AOF file is an append-only log file, so writes to the AOF file do not need to seek, even if the log contains incomplete commands for some reason (disk full, stop during a write, etc.). The redis-check-aof tool can also easily fix this problem. 2, Redis can automatically rewrite the AOF in the background when the AOF file becomes too large: the new AOF file will contain the minimum set of commands needed to restore the current data set. The entire rewrite is absolutely safe, because Redis will continue to append commands to existing AOF files while creating new AOF files, and the existing AOF files will not be lost even if there is an outage during the rewrite. Once the new AOF file is created, Redis will switch from the old AOF file to the new AOF file and start appending the new AOF file. Disadvantages: AOF files are usually larger than RDB files for the same data set. Depending on the fsync policy used, AOF may be slower than RDB. In general, fsync performance per second is still very high, and turning off fsync allows the AOF to run as fast as the RDB, even under heavy loads. However, when dealing with large write-loads, RDB can provide a more guaranteed latency. AOF has had a bug in the past where, due to some individual command, the AOF file could not restore the data set to the same state as it was saved when it was reloaded. (For example, the blocking command BRPOPLPUSH has caused this bug in the past.) Tests have been added to the test suite for this: they automatically generate random, complex data sets and reload the data to make sure everything works. While this kind of bug is not common in AOF files, by contrast, it is almost impossible for RDB to have this kind of bug.
==== Is Redis single process single thread? Redis is single process and single thread. Redis uses queue technology to change concurrent access into serial access, which eliminates the overhead of traditional database serial control.
==== What is the maximum size of a string value that can be stored in Redis? 512M
==== Redis expired key removal policy? 1, Timed delete: set the expiration time of the key at the same time, create a timer timer. Allow the timer to delete the key as soon as the key’s expiration time comes. 2, lazy delete: let the key expire, but every time you get a key from the key space, check whether the obtained key is expired, if expired, delete the key; If it has not expired, the key is returned. 3, regular deletion: every once in a while the program on the database for a check, delete the expired key inside. It is up to the algorithm to determine how many expired keys to delete and how many databases to check.
==== What are the recycling strategies (elimination strategies) in Redis? Volatile -lru: Eliminates volatile-ttl from the least recently used data set (server.db[I].expires) that has an expiration date set: Expires selects the data set to expire (server.db[I]. Expires) to eliminate volatile-random: Select allKeys-random from a dataset with an expiration date set (server.db[I].expires); select the least recently used data from the dataset (server.db[I].dict); Arbitrary selection of data elimination no-enviction from the data set (server.db[I].dict) : Note that volatile and allkeys specify whether data should be eliminated from a data set with an expiration date or from the entire data set. LRU, TTL, and RANDOM are three different strategies for data elimination. Plus a no-enviction never-recyclable strategy. Use policy rules: 1. If the data presents power-law distribution, that is, some data have high access frequency and some data have low access frequency, then use allKeys-LRU; 2. If the data presents equal distribution, that is, all data have the same access frequency, then use allKeys-random
====Redis synchronization mechanism? Redis can use master-slave synchronization and slave-slave synchronization. During the first synchronization, the master node makes a bgsave and records subsequent modifications to the memory buffer at the same time. Upon completion, the RDB file will be fully synchronized to the replicated node, and the RDB image will be loaded into the memory after the replicated node receives the RDB image. After the loading is completed, the synchronization process is completed by notifying the master node to synchronize the modified operation records to the replicated node for replay.
More interview questions or learning resources can be found on my homepage or in the comments