With the advent of the Internet era, there are more and more network users. It is increasingly important to optimize websites to improve performance and improve user experience. This poses new challenges to developers. So how do developers determine the performance of a website and whether they need to be optimized? If optimization is required, what are the bottlenecks of the website? Where to optimize? At this time, an excellent Web performance analysis tool is particularly important. It can be said that the Web performance analysis tool is an essential tool for optimizing the website performance. There are currently many excellent Web performance testing tools, such as WebPageTest, YSlow, HttpWatch, Page Speed, YCSB, and HttpAnalyzer. This article mainly introduces the Web Front-end performance analysis tool YSlow and common cloud performance analysis tool YCSB in detail.
YSlow
YSlow is a well-known Web page performance analysis, testing, and debugging tool. It is a browser plug-in developed by Yahoo Based on Web page performance analysis. YSlow initially only supports Firebug installation in Firefox. With Yahoo's continuous development and maintenance of YSlow, many versions of YSlow are available, supports FireFox, chrome, oupeng browser, oupeng mobile edition, and many other browsers. Currently, YSlow has become one of the industry's evaluation criteria.
YSlow provides the following functions:
Scores pages based on three predefined rule sets or custom rule sets.
Suggestions for page Performance Improvement
Summary Page Components
Display page statistics
Auxiliary Tools for Performance Analysis
Website rating and optimization suggestions
Yahoo once proposed 34 well-known guidelines for website speed: Best Practices for Speeding UpYour Web Site. Now 34 are simplified to 23 more intuitive ones, and ~ A's score and the final total score. Now we can see 23 website performance optimization suggestions on the homepage of YSlow's official website. After using YSlow, you will be given a score and suggestions for improvement on the control panel. This makes it very convenient for developers to evaluate the website page performance. In addition, YSlow also allows you to choose a set of custom optimization criteria, with high flexibility. The following are Yahoo's 23 classic optimization principles:
1. Minimize the number of HTTP requests
2. Use CDN
3. Avoid empty src and href labels
4. Add Expires or Cache-Control Header
5. Use Gzip for compression
6. Place a style sheet on the top of the html file
7. Place the JavaScript script at the bottom of the html file
8. Avoid using CSS expressions
9. Use external JavaScript and CSS external files
10. Reduce the number of DNS searches
11. Simplified JavaScript and CSS
12. Avoid redirection
13. Remove duplicate scripts
14. Configure ETag
15. cache AJAX
16. Use GET to complete AJAX requests
17. Reduce the number of DOM elements
18. Avoid 404
19. Reduce Cookie size
20. Use a non-Cookie domain
21. Avoid using Filters
22. Do not scale the image in HTML
23. Use a small favicon. ico file and make it available for caching
Baidu homepage is evaluated using 23 classic YSlow entries, as shown in figure 1. The left side shows the score based on each criterion. Click each label on the left side to see the suggestions for optimizing the content. The Baidu homepage shows that the score for reducing HTTP request rules is relatively low. The suggestion is to merge additional JS and CSS.
Figure 1 Baidu homepage of YSlow Evaluation
Component Information
You can see the space occupied by each element on the webpage by viewing the Components summarized on the page provided by YSlow. Developers can find possible optimization methods based on the size of each element.
Display page statistics
YSlow also makes statistics on the page information and displays it visually. Figure 2 shows the page statistics of Baidu homepage evaluation.
Figure 2YSlow: Baidu homepage statistics
Auxiliary performance analysis tools
YSlow also provides many auxiliary tools for analyzing front-end Web pages, such as JSLint, all js, and ALL Smush. it, All JS Beautified, All JSMinified, and many other JS and CSS analysis optimization tools. Provides more convenient tools for developers to optimize pages.
According to the main functions provided by YSlow, YSlow only requires the webpage URL to be tested and the Rule Set applied during website evaluation. YSlow has few parameters, which is easy to use and does not require too much background knowledge. At the same time, YSlow automatically provides optimization suggestions for developers, saving a lot of developers' own analysis work. Therefore, YSlow is simple, practical, and easy to use.
YCSB
YCSB (Yahoo! Cloud Serving Benchmark) is a common performance testing tool open-source by Yahoo. It is mainly used for performance evaluation and analysis on the Cloud or server. YCSB uses a general load framework to evaluate the performance of different key-value pairs in storage and cloud storage.
Figure 3 YCSB Structure
Figure 3 shows the structure of YCSB, which can be viewed as a database client. The module with dark colors can be replaced. The Workload Executor generates application load. The DBInterface Layer converts the API of a specific database to the API of YCSB. You can customize the load and database. Currently, YCSB comes with six types of loads (under the workloads/directory), five of which are shown in table 1. Users can customize the proportion of operations (read, update, insert, and scan), and select the distribution of operation target records: Uniform (random select record with equal probability), Zipfian (random select record, there are hot records) and Latest (recently written records are hot records ).
Table 1 workloads in core package
With this tool, we can test the performance of various NoSQL products. For example, we are familiar with HBase, cassandra, mongodb, and redis. Testing with YCSB allows you to know some metrics of the database during concurrent writing, reading, and updating, such as throughput and IO latency. YCSB can test a variety of NoSQL databases. Here we use YCSB to test HBase to discuss its advantages and disadvantages.
Compared with the performance testing tool (PerformanceEvaluation) provided by HBase, YCSB has the following advantages:
Extension: the client for performance testing is not only a HBase product, but also a different HBase version.
Flexible: When performing performance tests, you can choose the testing method: read + write, read + scan, and so on. You can also choose the frequency of different operations and the Key selection method.
Monitoring:
When performing a performance test, you can display the progress of the test in Real Time:
1340 sec: 751515 operations; 537.74 current ops/sec; [INSERT AverageLatency (MS) = 1.77]
1350 sec: 755945 operations; 442.82 current ops/sec; [INSERT AverageLatency (MS) = 2.18]
After the test is completed, the overall test status is displayed:
[OVERALL], RunTime (MS), 1762019.0
[OVERALL], Throughput (ops/sec), 567.5307700995279
[INSERT], Operations, 1000000
[INSERT], AverageLatency (MS), 1.698302
[INSERT], MinLatency (MS), 0
[INSERT], MaxLatency (MS), 14048
[INSERT], 95 thPercentileLatency (MS), 2
[INSERT], 99 thPercentileLatency (MS), 3
[INSERT], Return = 0, 1000000
[INSERT], 0, 29
[INSERT], 1,433925
YCSB has the following shortcomings:
The built-in workload model is still too simple and does not provide MR for testing. Therefore, it is troublesome to enable multithreading during testing. For example, to enable multithreading during import, you can only start multiple import processes, and then specify the "Start Key value" in different startup parameters ". During the Transaction test, multiple threads can only be enabled on multiple machines.
The main parameters of YCSB include the load volume, operation type and proportion, and the distribution of operation target records. The parameters of YCSB can be manually configured as needed, making it easy to apply.
Conclusion
Good Web performance analysis tools are crucial to Web page optimization. It saves a lot of manual testing effort, making optimization more efficient. YSlow and YCSB are currently mainstream performance optimization tools for Web Front-end and cloud servers. Both tools are simple, convenient, and flexible. They are a good choice for beginners and senior Web optimization professionals.
References
[1] Cooper B F, Silberstein A, Tam E, et al. benchmarking cloud serving systems with YCSB [C] // Proceedings of the 1st ACMsymposium on Cloud computing. ACM, 2010: 143-154.
Blog http://lusongsong.com/reed/362.html
[3] YCSB github website https://github.com/brianfrankcooper/YCSB
[4] yahoo! YSlow official website http://developer.yahoo.com/yslow/
Open source China blog http://my.oschina.net/fomy/blog/167659
Blog http://www.cnblogs.com/gpcuster/archive/2011/08/16/2141430.html