High concurrency large flow of topics --- 1 high concurrent high-volume solutions summary
A summary
Sentence summary:
The optimization method may be determined front and rear ends and a database sequence number of QPS
1, how to solve the problem PHP website traffic with large high concurrency?
Traffic Optimization + front-end optimization: for example, anti-theft chain process, reduce HTTP requests, add an asynchronous request, CDN to accelerate the establishment of an independent image server, enabled browser caching and file compression, etc.
Server optimization + Web server optimized: for example, static pages, concurrent processing, queue processing, load balancing, etc.
Database optimization: such as database cache sub-library sub-table, partitioning, separate read and write, load balancing, etc.
2, what we are talking about high concurrency that?
Not the operating system concurrency: the operating system, refers to a time period has started several programs are in the running to run between finished and these programs are running on the same processor, but either the point in time only one program running on the processor.
The amount of concurrent access to a certain point in time: the above definition is clearly not our usual said concurrency in the Internet age, talking about concurrency, high concurrency, usually it refers to concurrent access. That is, at some point in time, the number of simultaneous accesses arrival.
Japanese PV million or more in the dry: If the day is usually a PV system in a dry million or more, there may be a highly concurrent systems
3, high concurrency solution?
Technology: Various optimizations, caching, load balancing technology
Machine heap: Some companies do not fully take the technical route, thanks to the machine heap, wealthy, self-willed
4, high concurrency problems, it is necessary to understand some of the terminology?
qps, throughput, response time, pv, uv, bandwidth Day website bandwidth and peak
QPS: in response to requests per second (HTTP request means): the number of queries or requests per second, in the Internet field, refers to the response requests per second (refer to HTTP requests);
Throughput: number of requests processed per unit time (typically QPS determined concurrent with) the
response time: sending time to receive a response takes from the request. For example, the system needs to handle a HTTP request 100ms, 100ms is the response time of the system
PV: pageviews (Page View), ie, page views or clicks, the number of visitors to a page within 24 hours; the same person browsing your Web site on the same page, just make a note of the PV
UV: unique visitors (UniQue visitor), which is the same site visitors multiple visits within a certain time frame, only count as one unique visitors
Bandwidth: Bandwidth is calculated to be concerned about the size of two indicators, peak flow the average size of the page and
date bandwidth site = PV / statistical time (converted to seconds) * average page size (KB) * 8
peak is generally a multiple of the average, based on the actual situation to be
the peak number of requests per second (QPS) = (total PV * 80%) / (6 hours * 20% seconds)
5, how to calculate the bandwidth Day website?
Bandwidth: Bandwidth is calculated to be concerned about the size of two indicators, the average peak flow and page size
Day website Bandwidth = PV / Statistical Time (converted to seconds) * average page size (in KB) * 8
Peak is a multiple of the average general, according to the actual situation by
6, QPS equal to the number of concurrent connections it?
Is not equal to: QPS number of HTTP requests per second, the number of concurrent connections is processed simultaneously requesting system: a connection there may be multiple http requests
7, the peak number of requests (QPS) how to calculate per second?
Peak requests (QPS) = (total number of PV * 80%) per second / (6 hours * 20% seconds)
80% of the traffic concentrated in 20% of the time
8. What stress tests?
Maximum number of concurrent: test server cluster (or single) can withstand the maximum concurrency
QPS values: QPS value test server cluster (or single) bear the greatest
General understanding of a single server is how much can withstand QPS
9, common performance testing tools?
ab、wrk.http load、Web Bench、Siege、Apache JMeter
ab: full name is apache benchmark, it is the official launch of apache tool
ab principle: create multiple concurrent threads access simulate multiple visitors simultaneously access a URL address. Its goal is to test based on the URL, so that both can be used to load stress testing apache can also test nginx, pressure lighthttp, tomcat, IIS and other Web servers.
10, ab (apache benchmark) is the official launch of apache tool, it is possible to test nginx it?
Energy: it is based on objective test the URL: ab creates multiple concurrent threads access simulate multiple visitors simultaneously access a URL address. Its goal is to test based on the URL, so that both can be used to load stress testing apache can also test nginx, pressure lighthttp, tomcat, IIS and other Web servers.
11, ab use (such as analog concurrent requests 100 times for a total request for 5000)?
Run the ab command: ab -c 100 -n 5000 to be tested website
12, ab test considerations?
Test machine and the machine to be tested separately
Do not do stress tests for online services
Does not exceed the maximum limit of 75%: To observe the testing tool where the ab machine, and a front-end test machine's CPU, memory, network, etc. does not exceed the maximum limit of 75%
13, how to install and use ab test?
Independent installation: yum -y install httpd-tools
General installation will automatically install apache ab
Use ab: ab -c 100 -n 5000 http://192.168.52.6/index
[root@localhost ~]# ab -c 100 -n 5000 http://192.168.52.6/index This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.52.6 (be patient) Completed 500 requests Completed 1000 requests Completed 1500 requests Completed 2000 requests Completed 2500 requests Completed 3000 requests Completed 3500 requests Completed 4000 requests Completed 4500 requests Completed 5000 requests Finished 5000 requests Server Software: Apache Server Hostname: 192.168.52.6 Server Port: 80 Document Path: /index Document Length: 1917 bytes Concurrency Level: 100 Time taken for tests: 22.049 seconds Complete requests: 5000 Failed requests: 3 (Connect: 0, Receive: 0, Length: 3, Exceptions: 0) Write errors: 0 Total transferred: 11438133 bytes HTML transferred: 9579249 bytes Requests per second: 226.77 [#/sec] (mean) Time per request: 440.972 [ms] (mean) Time per request: 4.410 [ms] (mean, across all concurrent requests) Transfer rate: 506.61 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 9.0 0 125 Processing: 1 419 1614.8 68 17425 Waiting: 0 412 1601.8 68 17425 Total: 1 420 1614.8 72 17427 Percentage of the requests served within a certain time (ms) 50% 72 66% 125 75% 163 80% 193 90% 399 95% 987 98% 7019 99% 9085 100% 17427 (longest request)
14, different QPS, optimization related to what?
Hardware conditions
Network bandwidth
With the growth of QPS, each stage needs to be optimized according to actual situation, the optimal solution is also closely related to hardware conditions, the network bandwidth.
15, optimization under different QPS?
QPS100: database cache layer, the database load balancing
QPS800: CDN acceleration, load balancing
QPS1000: static HTML cache
QPS2000: doing business separate, distributed storage
16, QPS 50 need to optimize it?
May not be required; call it small sites, the general server can cope
17, QPS 100 How to optimize?
|||-begin
Suppose relational database in 0.01 seconds to complete each request;
Assuming that only a single SQL query page, then 100QPS means 1 second to complete 100 requests, but at this time we can not guarantee that the database query to complete 100 times
|||-end
Database caching layer, load balancing of database
18, QPS 800 How to optimize?
|||-begin
Suppose we use hundreds of megabytes of bandwidth, which means the site is about export of actual bandwidth 8M
Assuming that each page is only 10K, under the concurrent conditions, hundreds of megabytes of bandwidth has been finished
|||-end
CDN acceleration, load balancing
19, QPS up to 1000 how to optimize?
|||-begin
Assuming Memcache cache database query data, each page is much larger than the direct request of the request of the DB Memcache
Pessimistic concurrency Memcache is about 2w, but there may be network bandwidth is eaten during the previous exhibit unstable
|||-end
Static HTML cache
20, QPS up to 2000 how to optimize?
|||-begin
Under this level, file system access locks are catastrophic.
|||-end
Separation of doing business, distributed storage
21, high concurrency optimization What direction?
Traffic Optimization + front-end optimization: for example, anti-theft chain process, reduce HTTP requests, add an asynchronous request, CDN to accelerate the establishment of an independent image server, enabled browser caching and file compression, etc.
Server optimization + Web server optimized: for example, static pages, concurrent processing, queue processing, load balancing, etc.
Database optimization: such as database cache sub-library sub-table, partitioning, separate read and write, load balancing, etc.
Traffic Optimization
anti-hotlinking processing
front-end optimization methods
to reduce HTTP requests
to add asynchronous request: for example, ajax
enabled browser caching and file compression
CDN to accelerate the
establishment of an independent image server
server optimization method
static page
concurrent processing
queue processing
database optimization
database cache
sub-libraries points table partitioning
separate read and write
load balancing
Web server optimization
load balancing
22, traffic optimization method?
Anti-theft chain process
23, front end optimization?
Reduce HTTP requests
Adding asynchronous request: for example, ajax
Enable browser caching and file compression
CDN to accelerate the establishment of an independent image server +
24, server optimization?
Static pages
Concurrent processing
Queue processing
25, database optimization?
Database Cache
Sub-library sub-table, partitioning
Separate read and write
Load Balancing
26, Web server optimization?
Load Balancing
27 to see how the response time of the page?
chrome browser -> network-> lower right corner in red: such as Load: 1.65s
95 requests I 409 KB transferred I 718 KB resources l Finish:3.06s l DOMContentloaded:910 ms I Load:1.65s
Second, content in summary
Reproduced in: https: //www.cnblogs.com/Renyi-Fan/p/11045520.html