PHP high concurrency and high flow solutions

A high concurrency concept

in the Internet age, concurrent, high concurrency usually refers to concurrent access. That is, at some point in time, the number of simultaneous accesses arrival.


Two high concurrency architecture concepts


1.QPS (queries per second rate): the number of queries per second request or, in the Internet field, refer to respond to requests per second (refer to HTTP requests)

2. the PV (Page View): pageview the amount of that page views or clicks, the number of visitors to a page within 24 hours

- Note: the same person browsing the same page of your site, just remember to do a pv

3. throughput (fetches / sec): unit the number of requests handled within the time (and generally determined by the number of concurrent QPS)

4. response time: the time to receive a response sent from the request takes

5. unique visitors (the UV): within a certain time, the same multiple access site visitor, only count as one unique visitors

6. Bandwidth: Bandwidth is calculated to be concerned about the size of two average index, peak flow and page

7. day bandwidth site: PV / statistical time (converted to seconds) * average page size (kb) * 8


Note that three points:

1. QPS is not equal to the number of concurrent connections (QPS number of HTTP requests per second, the number of concurrent connections is processed simultaneously requesting system)

the number of requests per second peak 2. (QPS) = (total number of PV * 80 % / (Six hours seconds * 20%) [80% of the representative traffic is concentrated in 20% of the time]

3. Stress Test: QPS can withstand the maximum value of the test and test the maximum number of concurrent withstand

4. Common properties testing tools [ab, wrk, httpload, Web Bench , Siege, Apache JMeter ]



four optimization

1. when less than 50 QPS
Optimization: for the average small site, regardless of optimization

2. When the QPS of 100, encountered a bottleneck data query
optimization: caching database layer, database load balancing

3. When QPS 800, bandwidth bottlenecks encountered
optimization: CDN acceleration, load balancing

4. when QPS reaches 1000
optimization: do html static cache

5. when QPS reaches 2000
optimization scheme: separation of doing business, distributed storage


high concurrency solution case:

1. traffic optimization  

security chain processing ( remove malicious requests)


2. front-end optimization
(1) reduce HTTP requests [the css, js merger]
(2) adding an asynchronous request (to not have to show all the data to the user, the user triggers an event, only asynchronous data request )
(3) enable browser caching and file compression
(4) CDN acceleration
(5) establishment of an independent image server (reducing the I / O)

3. server optimization
(1) static pages
(2) concurrent processing
(3) queue processing

4. database optimization
(1) database cache
(2) sub-library sub-table, partition
(3) separating the reader
(4) load balancing

5.web optimization server
(1) Nginx reverse proxy load balancing
(2) implemented LVS load balancing

Guess you like

Origin www.cnblogs.com/aspire18/p/11073204.html