In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to improve the ability of high concurrency in Web development". In daily operation, I believe that many people have doubts about how to improve the ability of high concurrency in Web development. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to improve the ability of high concurrency in Web development". Next, please follow the editor to study!
What are we talking about about high concurrency?
The above definition is obviously not what we usually call concurrency, in the Internet era, the concurrency, high concurrency, usually refers to concurrent access. That is, at some point in time, how many visits arrive at the same time.
I see someone define high concurrency like this:
High concurrency usually means that the system services we provide can process many requests in parallel at the same time.
Let's take a look at this definition, which is first confused with parallelism. See here (https://laike9m.com/blog/huan-zai-yi-huo-bing-fa-he-bing-xing,61/) about the difference between concurrency and parallelism. I won't say much about it, but I'll continue to talk about concurrency.
And then the definition says a lot of requests? What do you mean a lot of requests? As a Chinese, this word makes my imagination get out of hand. All right, pull it back and continue with this article.
High concurrency is not clearly defined on the network. But according to my search, generally speaking, only companies with pv levels above 10 million will be involved in this concept. So I came up with a custom concept: if the daily pv of a system is above 10 million, it may be a highly concurrent system.
Why is it possible? That's because some companies don't take the technical route at all and rely entirely on machine heaps, which is outside the scope of our discussion. In order to avoid pretending, let's focus on concurrency (not talking about high).
What exactly should we care about the concurrency problem?
To tell you the truth, high concurrency is an abstract concept. It is difficult to have a unified measurable standard. Are there any other dimensional metrics to measure the performance of the system? Take out some indicators from previous computer courses to talk to you.
State a few concepts first and don't doze off.
QPS (TPS): the number of request/ transactions per second, in the Internet world, the number of response requests per second (http requests)
Throughput: the number of requests processed per unit time (usually determined by QPS and concurrency)
Response time: the average time it takes the system to respond to a request. For example, the system needs 200ms to process a HTTP request, and this 200ms is the response time of the system (I think only the processing time should be included here, and the network transmission time should be ignored).
We must pay attention to the number of concurrency of QPS ≠ here.
Concurrency refers to how many visits arrive at the same time at a time. QPS is the number of requests that are responded in seconds. Then it would be easy to deduce a formula here:
QPS = number of concurrency / average response time
After our analysis is carried out around this announcement, do not understand the aftertaste.
Now let's assume a scenario: since QPS is the number of http requests processed per second. So 1s = 1000ms. Suppose that 100ms is required for one of our current http request servers to complete processing (that is, the average response time = 100ms). Then it can handle 10 requests in 1 second. In other words, qps = 10. Calculate the number of concurrency = 10
We are often asked questions about high concurrency, but to some extent, they want to ask how to improve the performance of existing programs. Now let's analyze it based on the above hypothesis. Suppose there is a system performance that is our above assumption, it has 3 million pv every day, running on a single machine (of course, often down), according to the above system performance data, give the optimization solution.
Improve concurrency
Through the above analysis, in order to improve the concurrency ability, we need to improve our qps (in fact, this is not entirely true, in order to illustrate the point, let's give up some of the correctness)
The quickest solution is to add machines. Let's make a practical calculation according to the above situation.
Number of visits: 200w pv
QPS:10
According to daily experience, 80% of visitors are concentrated in 20% of the time, so calculate how many qps machines are actually required to meet these 200w pv.
Qps = (200w * 0.8) / (24 * 3600 * 0.3) qps = 61.7
In fact, if we are on a single computer, we are required to process requests more than 61.7 per second, while in fact, the qps of our current system is 10. So how to solve it?
Plan 1: get on the machine
The ability of the individual is limited, and the strength of the team is infinite. Since one machine can't handle it, let's get a few more machines. This involves db master-slave, read-write separation, load balancing and other technologies.
Its principle is to divert the pressure from the previous concentration. The reform plan is quick and flexible, and it is faster to practice.
Plan 2: increase the performance of a single machine
The extent to which the performance of a single machine can be increased depends on your machine configuration and on how complex your service is.
Ps: at this point, I can suddenly understand why there are a lot of requests for high concurrency on the Internet, and there is no specific data, because this is really only for business, 100 concurrency is nothing for static web pages, but for some intensive computing estimates.
So how does a common stand-alone improve performance? For example: increase the cache of infrequent data, turn on php opcache, optimize the code (such as: Number1 problem, multiple nested loops, deep recursion, etc.), db table optimization, and so on.
At this point, the study on "how to improve the ability of high concurrency in Web development" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.