High concurrency and large traffic solution

远方*
Release: 2022-04-12 09:04:09
Original
301 people have browsed it

1. Related concepts of high concurrency architecture

The concept of high concurrency: concurrency, high concurrency, usually refers to concurrent access. That is, at a certain point in time, how many visits come at the same time.

2. What should we collectively be concerned about when it comes to high concurrency?

qps: The number of requests or queries per second. In the Internet field, it refers to 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 time it takes from sending a request to receiving a response, for example, it takes 100ms for the system to process an http request. This 100ms hormone hi system response time pv: page views, that is, page views or clicks, one visitor The number of pages visited within 24 hours. The same person browsing the same page of your website is only counted once. pvuv: independent visitor, that is, the same visitor browses the website multiple times within a certain time range, and is only counted as 1 independent visitor bandwidth. : Calculating bandwidth requires attention to two indicators, peak traffic and average page size. Daily website bandwidth = pv/statistical time (converted to seconds) * average page size (unit kb) * 8qps is not equal to the number of concurrent connections. Qps is per second. The number of http requests and the number of concurrent connections are the number of requests processed by the system at the same time. The peak number of requests per second (qps) = (80% of the total number of PVs) / (20% of the number of seconds in 6 hours) Stress test: the maximum number of concurrencies that the test can withstand , test the maximum qps value testing tools: ab, wrk, http_loadab: can create multiple concurrent threads to simulate multiple visitors accessing a certain URL address at the same time. Its test target is based on URL, so it can be used to test the load pressure of apache, and it can be tested

3. Precautions when using the ab tool

Test machine and The machines being tested should be separated and do not perform stress tests on online services. Observe that the CPU, memory, network, etc. of the machine where the test tool ab is located and the front-end machine being tested do not exceed 75% of the maximum limit

4 , Solutions under different qps

Optimization examples:

a, qps reaches 100

Assume that each request of the relational database is completed within 0.01 seconds
Assumption There is only one sql query on a single page, so 1000ps means that 100 requests are completed within 1 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

Assume we use 100M bandwidth, which means the actual bandwidth of the website exit is about 8M
Assume that each page is only 10k, under this concurrency condition, the 100M bandwidth has been used up
Plan: cdn acceleration, load balancing

qps reaches 1000

Static html cache
qps reaches 2000
at this level. File system access locks have become a disaster,
plan: business separation, distributed storage

5, high concurrency solution case

Traffic optimization: anti-leeching processing
Front-end optimization: reduce http requests, add asynchronous requests, enable browser caching, file compression, CDN acceleration, establish an independent image server
Server-side optimization: page staticization, concurrent processing, queue processing
Database optimization: database Caching, sub-library and sub-table, partition operation (can be completed using tools), read-write separation, load balancing
Web server optimization: load balancing (using reverse proxy, lvs to achieve load balancing)

The above is the detailed content of High concurrency and large traffic solution. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
1
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!