In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the key points of how to design a high concurrency system". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn the key points of how to design a high concurrency system.
First, why is there high concurrency?
Now more and more people use the Internet, many app, websites, systems are carrying high concurrent requests, may be thousands of concurrent requests per second, it is normal. Especially for e-commerce App, if it is Singles' Day, it is possible to have tens of thousands of concurrency per second. The problem brought by high concurrency access is that the system and database cannot bear it and are prone to downtime. You should know that when the database is supported to two or three thousand concurrency per second, it is almost over. If the database is instantly loaded with 5000 million per second, or even tens of thousands of concurrency, it will definitely be down. For example, mysql simply can not bear such a high concurrency.
So with such a high concurrency and such a complex business, how to design a system that can support high concurrency access is mainly considered from the following points:
System split
Use cach
Introduction of MQ
Sub-database sub-table
Separation of reading and writing
Second, the key points of designing high concurrency system
2.1. System split
A large system is divided into multiple subsystems based on micro-service architecture, and the technology chooses to use SpringCloud to do it, and then each subsystem is connected with a database, so that there is already a library, but now there are multiple databases, which can also carry high concurrency.
2.2. Use caching
Cache, be sure to use cache. In most high concurrency scenarios, there are more reads and less writes. We can write a copy in both the database and cache, and then read a large number of caches. We can introduce Redis as the technical solution of distributed cache. Redis supports tens of thousands of concurrency per second on a stand-alone machine, and hundreds of thousands of concurrency per second in the cluster case. So we have to consider the read scenarios that carry the main requests in the project, how to use cache to resist high concurrency, and at the same time deal with the problems such as cache avalanche, cache penetration and cache breakdown.
2.3. introduce MQ
MQ, be sure to use MQ. Because there will still be scenarios of high concurrent writes in the system, for example, in a business operation, the database will be frequently done dozens of times, adding, deleting, adding, deleting, and deleting, and in the case of high concurrent access, you can definitely hang the database. At this time, you can consider using MQ to trim the peak, pour a large number of write requests into MQ first, queue up and play slowly, and then write slowly after consumption, which is controlled within the bearing range of the database. So we need to consider how to use MQ to write asynchronously and improve concurrency in scenarios that carry complex writing business logic. MQ can handle tens of thousands of concurrency on a single machine. The technology selection of MQ can choose to use rabbitMq or Kafka. Of course, after the introduction of MQ, the availability of the whole system will be reduced, and the complexity of the system will be increased. The more external dependencies the system introduces, the easier it will be to fail. Therefore, after the introduction of MQ, it is necessary to consider [how to ensure the high availability of message queues], [how to ensure that messages are not consumed repeatedly], [how to deal with message loss], [how to ensure the sequence of message delivery] and other issues. MQ has many advantages, but it also has to do a variety of additional technical solutions and architectures to avoid it.
2.4. Sub-database and sub-table
At the final database level, it may be inevitable to resist high concurrency at the database level, so split a database into multiple databases to carry higher concurrency, and then split a table into multiple tables to keep the data volume of each table within a certain range to improve the performance of sql running. It is recommended to use ShardingSphere as the technical solution of sub-database and sub-table.
2.5. Read-write separation
Read-write separation, that is to say, most of the time, the database may also read more and write less, so it is not necessary to concentrate all requests on one library. You can set up a master-slave architecture, write to the master library, read from the library, and make a read-write separation. When there is too much read traffic, you can add more slave libraries.
Thank you for your reading. the above is the content of "the key points of how to design a high concurrency system". After the study of this article, I believe you have a deeper understanding of the key points of how to design a high concurrency system. The specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.