In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to design a system to support high concurrency and large traffic". 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 "how to design a system to support high concurrency and high traffic".
Concepts related to High concurrency Architecture
What is concurrency?
Concurrency refers to concurrent access, that is, how many visits arrive at the same time at a certain point in time.
Usually, if the daily PV of a system is more than 10 million, it may be a high concurrency system, but it may be a high concurrency system, not necessarily a high concurrency system.
Concurrency and QPS are different concepts. Generally speaking, QPS will say how many concurrent users are under QPS. When the QPS is the same, the larger the number of concurrent users, the better the concurrent processing capacity of the website. When the number of concurrent users is too large, it will cause processes (threads) to switch frequently. Anyway, the real time spent on processing requests becomes less, the number of requests that can be processed per second becomes less, and the request waiting time of users becomes larger. Finding the optimal number of threads can make the web system more stable and efficient.
Number of concurrency = average response time of QPS*
What do you care about high concurrency?
QPS: the number of requests or queries per second, in the Internet world, the number of requests per second of response
Throughput: the number of requests processed per unit time (usually determined by QPS and concurrency)
Response time: the time it takes from sending the request to receiving the response. For example, a system needs 100ms to process a HTTP request, and this 100ms is the response time of the system.
PV: overall page views, that is, page views or clicks, the number of pages visited by a visitor in 24 hours
UV: an independent visitor, that is, multiple visits by the same visitor within a certain period of time can only be counted as a separate visitor.
Bandwidth: calculating the bandwidth size requires attention to two indicators, peak traffic and average page size
The daily website bandwidth can be roughly calculated using the following formula:
Daily website bandwidth = pv/ statistical time (converted to seconds) * average page size (in kB) * 8
The peak is usually a multiple of the average.
QPS is not equal to the number of concurrent connections. QPS is the number of HTTP requests per second, and concurrent connections is the number of requests processed by the system at the same time.
Peak requests per second (QPS) = (total PV * 80%) / (6 hours * 20%)
Stress testing: test the maximum concurrency that the test can withstand and the maximum QPS value that the test can withstand.
Test tool (ab): the target is URL, and multiple access threads can be created to access the same URL (Nginx)
Use of ab: simulate 100 concurrent requests (100 people) for a total of 5000 requests (5000 per person)
Ab-c 100-n 5000 websites to be tested (memory and network no more than 75% of the maximum)
QPS reaches 50: the average server can handle it.
QPS 100: assuming that each request in a relational database is completed in 0.01s (ideal), and that there is only one SQL query on a single page, then 100QPS means that 100 requests are completed in a second, but at this time we cannot guarantee that the database query can be completed 100 times.
Solution: database cache layer, database load balancing
QPS reaches 800: suppose we use 100 megabytes of broadband, which means that the actual bandwidth of the website exit is about 8 megabytes, and that each page has 10k. Under this concurrent condition, the 100 megabytes of bandwidth has been eaten up.
Solution: CDN acceleration, load balancing
QPS reaches 1000: suppose you use Redis to cache database query data, and each page faces a much larger Redis request than a direct DB request.
The pessimistic concurrency of Redis is about 5W, but it is possible that the private network bandwidth has been eaten up before, showing instability.
Solution: static HTML caching
QPS reaches 2000: file system access locks are a disaster
Solution: business separation and distributed storage
High concurrency solution case
Traffic optimization: hotlink protection (shut out some malicious requests)
Front-end optimization: reduce HTTP requests, add asynchronous requests, enable browser caching and file compression, CDN acceleration, set up independent image servers
Server optimization: page static processing, concurrent processing, queue processing
Database optimization: database caching, database partition, partition operation, read-write separation, load balancing
Web server optimization: load balancing
Empirical formula under high concurrency
Calculate the number of deployed servers through QPS and PV
Daily PV calculation on a single server
Formula 1: daily total PV = QPS * 3600 * 6 Formula 2: daily total PV = QPS * 3600 * 8
Server computing
Number of servers = ceil (total PV per day / total PV per server per day)
Peak QPS and machine calculation formula
Principle: 80% of daily visits are concentrated in 20% of the time, which is called peak time
Formula: (total PV * 80%) / (seconds per day * 20%) = requests per second at peak time (QPS)
Machine: peak time per second QPS / QPS of a single machine = needed machine.
Thank you for your reading. the above is the content of "how to design a system to support high concurrency and high traffic". After the study of this article, I believe you have a deeper understanding of how to design a system to support high concurrency and high traffic. Specific use also needs to be verified in 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.