Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

Redis is a key-value storage system. Similar to Memcached, it supports more stored value types, including string (string), list (linked list), set (collection) and zset (ordered collection). These data types all support push/pop, add/remove, intersection, union and difference, and richer operations, and these operations are all atomic. On this basis, redis supports a variety of different ways of sorting. Like memcached, in order to ensure efficiency, data is cached in memory. The difference is that redis periodically writes updated data to disk or writes modification operations to additional record files, and on this basis, it realizes master-slave (master-slave) synchronization.

Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

 

With the development of redis in caching, redis is generally a must-tested knowledge point in interviews for large companies. Today, I will analyze a real interview question from Tencent: How to ensure the high concurrency and high availability of redis?

The real interview questions give a detailed analysis of the questions and the interviewer's psychology. In addition to the real questions related to redis, the editor also compiled the real interview questions and analysis that are often prepared by large companies such as jvm+spring+mybatis+springboot.

How to ensure the high concurrency and high availability of redis? Can you introduce the principle of redis master-slave replication? Can you introduce the principle of redis sentry?

Psychological analysis of interviewers:

In fact, to ask this question, it is mainly to test you, how high concurrency can a single machine of redis carry? How to expand the capacity to carry more concurrency if the single machine cannot handle it? Will redis hang? Since redis will hang, how to ensure that redis is highly available?

In fact, it is all about some issues that you must consider in the project. If you haven't considered it, then you really think too little about the issues in the production system.

Analysis of interview questions:

If you use redis caching technology, you must consider how to use redis to add multiple machines to ensure that redis is highly concurrent, and how to make redis ensure that it does not die immediately after it hangs, that is, redis is highly available.

Since this section contains a lot of content, it will be divided into two sections for explanation. -redis master-slave architecture-redis based on sentinel to achieve high availability

Redis achieves high concurrency mainly relying on a master-slave architecture , one master with multiple slaves. Generally speaking, many projects are actually enough. A single master is used to write data, a single machine is tens of thousands of QPS, and multiple slaves are used to query data, and multiple slave instances Can provide 10w per second QPS.

If you want to accommodate a large amount of data while achieving high concurrency, you need a redis cluster. After using the redis cluster, you can provide hundreds of thousands of read and write concurrency per second.

Redis is highly available. If it is a master-slave deployment, then a sentinel can be added, and it can be realized. Any instance is down and the master-slave switch can be performed.

Redis learning summary

 

Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

 

The Ten Seasons of Gold, Nine and Silver (Dachang Interview Questions)

It’s the golden, nine, and silver ten interview seasons. I have sorted out some real interview questions asked by Dachang. Due to the length of the article, only some of the questions are shown to you, which need analysis and answers.

Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

 

Performance optimization:

Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

 

Microservices:

Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

 

Concurrent programming:

Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

 

Open source framework:

Two sides of Tencent java R&D post: How to ensure the high concurrency and high availability of redis?

Guess you like

Origin blog.csdn.net/Sqdmn/article/details/108631874