The common knowledge Summary of Apache stress testing and Web performance optimization _linux

Source: Internet
Author: User
Tags memcached server port

What is bandwidth?

Misunderstanding: "The speed of data in the line", "Data transmission speed"

We call the bandwidth refers to the data transmission speed, such as the Hundred Gigabit Network card, refers to the maximum transmission speed is 100Mbps, that is, the network card in one second can send 100Mb of data; related factors:

The ability of a data transmitting device to transmit a binary signal to a line, also known as the signal transmission frequency, and the ability of a data receiving device on the other end to receive a binary signal, including the degree to which the line supports the transmission frequency;
The degree of parallelism of data transmission medium is equivalent to the concept of computer system bus width;

Habits and conventions

B: bit unit bit;

B: Byte unit byte;

1KB = 1024B;

1KB = 1000b;

The conversion of M and K is above;

What is the throughput rate?

Throughput rate (throughput) refers to the number of requests processed in the Web server unit time, in units: reqs/s;

Generally more concerned about the server concurrent processing capacity of the upper limit, that is, the maximum throughput rate;

About Stress Testing

Based on several prerequisites of throughput pressure test:

Number of concurrent users; (the number of users who are sending requests to the server at the same time)
Total number of requests;
Request Resource Description;

Several important indicators:

Request Wait Time

Average user request Wait time (the main measure of the server in the case of a certain number of concurrent users, the quality of service for individual users)
Server average requester Care time (measure server overall service quality)
Stress testing Tools: AB, LoadRunner, Jmeter with Apache

Server System Load

$ cat/proc/loadavg 
0.58 1.19 0.64 1/92 8306

Here 0.58 1.19 0.64 of these 3 digits indicate: The system load is calculated by the system in the last 1 minutes, 5 minutes, 15 minutes respectively;

1 represents the number of processes in the current run queue, 92 indicates the total number of processes at this time, and 8306 represents the last process ID created so far;

Introduction to the use of Apache AB

In the "Build High-performance Web Site" in a number of references to the Apache with the pressure test tool AB for server performance testing, search the relevant knowledge, sorted as follows:

The full name of AB is Apachebench, a gadget that comes with Apache, dedicated to the benchmark testing of HTTP Server, that can simulate multiple concurrent requests at the same time. Here is a practical example to introduce the use of AB:

[Xiekeli@localhost ~]$ ab-n 1000-c http://www.abc.com/a.php        

 //produces 1000 HTTP requests per concurrent number of users: 50

This is Apachebench, Version 2.0.40-dev <; $Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology LTD, Http://www.zeustech.net/Copyright 2006 the Apache Software Foundation, http://www.apache.org/Benchmarking Www.ab C.com (Be patient) Completed requests Completed requests Completed requests Completed-requests Completed 5 Requests Completed requests Completed M requests Completed requests Completed 900 requests finished 1000 requ ESTs Server Software:apache//tested Platform Apache Server Hostname:www.abc.com//server Host                       Name Server port:80 Document Path:/a.php document length:231 Bytes//Document size concurrency level:50 Concurrent number of hours taken for tests:12.818547 seconds Complete requests:1000//Completion requests Faile                  D requests:0//failed requests Write errors:0 non-2xx responses:1001 total transferred:438438 bytes Network transmission throughout the sceneAmount of HTML transferred:231231 bytes//html content transfer in the entire scene Requests per second:78.01 [#/sec] (mean)//throughput rate, That is, the number of requests processed per second (the mean in parentheses below indicates that this is an average) time of request:640.927 [MS] (mean)///per Request response times (mean in parentheses below indicate that this is an average value time PE R request:12.819 [MS] (mean, across all concurrent requests)//Response time per request (as indicated in parentheses, is the average of all concurrent numbers) Transfer rate:33.3 9 [Kbytes/sec] Received//The average traffic on the network per second, can help to eliminate the existence of excessive network traffic caused response time to prolong the problem Connection times (MS)//network consumption of time decomposition, the specific data of the algorithm It's not clear. Min MEAN[+/-SD] Median max connect:186 307 598.1 212 9188 processing:188 271 289.6 214 1923 waiting:188 245 21 9.9 213 1416 total:376 579 660.2 427 9380//The response of all requests in the entire scene. There is a response time for each request in the scene, where 50% of the user response time is less than 1093 milliseconds, 60% of the user response time is less than 1247 milliseconds, and the maximum response time is less than 7785 milliseconds, because the CPU is not actually processed concurrently for concurrent requests,  Instead, the time slices are processed on a per-request basis, so basically the first time is approximately equal to the second time of the request times multiplied by the number of concurrent requests percentage of the requests served within A certain time (ms) 50% 427 66% 430 75% 431 80% 433 90% 451 1630 98% 3382 99% 3429 100% 9380 (longest Request

 

-N: The number of tests represented, many places translated into "the number of requests to send", so it is easy to create ambiguity, should be called: "HTTP request number" is appropriate; this represents 1000 HTTP requests;
-C: Indicates the number of requests per request,-C 50 indicates that 50 HTTP requests are launched at once, and 50 requests are received, sending 50 HTTP requests again until 1000 times.

Other relevant knowledge points for Web optimization:
the difference between cache and buffer (buffer):

Cache caching: The purpose of caching is to save the results of expensive calculations, and to remove them directly at a later time, to avoid duplication of calculations.

Buffering (buffer): The aim is to improve the various parts of the problem caused by the different speed. Play the role of smooth interface between fast equipment and slow speed equipment.

Page caching (pages cache)

Page caching is to cache the results of dynamic computation, to avoid unnecessary repetitive computation of dynamic content, mainly for dynamically generated HTML pages and dynamic images or dynamic XML data.

Cache Persistence and search

If the cache file is very many, the cache directory will be crowded with a large number of files, if the cached file read and write frequency is relatively high, the impact on the CPU is very large;

Solution to the solution:

1, use Support directory hash accelerated directory traversal of the file system to alleviate this situation, such as: XFS and ReiserFS;

2, Cache directory rating

Expiration check

    • Cache Expiration Time
    • Cache Expiration Length

Put the cache in memory

If you put the cached data in a disk file, each cache load and expiration check is in the cost of disk I/O, and if the disk is running an I/O-intensive application such as a database, then there will be a delay in I/O to the cached file.

The author mentions two PHP cache frames here: APC and XCache.

Caching servers

The HTML cache in a separate cache server, with memcached, it is easy to store the cache in other servers via TCP, memcached also save cached data in memory space, can reduce unnecessary I/O. Memcached maintains an expiration time for each key and automatically deletes the key once it expires.

Local No cache

Local no caching allows you to specify a piece of HTML code in the page that contains dynamic data, each time the dynamic data needs to be computed in real time, and then combined with the rest of the cache as the final page.

Static content

In dynamic content caching, every time a user's request is sent to a dynamic program, the dynamic program decides whether to output the cache according to the expiration date of the cache. So the cost of this control is also more expensive.

Take the dynamic page xxx.php cache from the cache directory, put it in the same directory: xxx.html, directly through the browser to access the corresponding static page.

Of course, static page is also required dynamic program to achieve, the general static page management is through the CMS (Content management System) to manage.

To statically update a page's policy:

1, in the data update, regenerate static content;

2, periodically regenerate static content;

Local static

Static pages enable the independent updating of individual local pages through SSI (server-side included) technology.

SSI technology can find the appropriate modules in any of the major Web servers, such as Apache Mod_include and Lighttpd's Mod_ssi.

Noun Explanation: PV

PV (Page view), or the number of clicks, is usually the main indicator of a network news channel or website or even a network news.

Definition: A visitor in 24 hours (0 to 24 o'clock) to see exactly how many pages of your site. Note: The same person browsing your site on the same page, do not repeat the calculation of PV. PV is a visitor opens a few pages of your site.

PV calculation: When a visitor to visit, record the page he visited and the corresponding IP, and then determine that the IP access today this page does not. If your site to 23 points, the simple IP has 600,000, each visitor visited the average of 3 pages, then the PV table records must have 1.8 million.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.