Introduction to optimizing performance in the Web
Web optimization is a war that prevents HTTP requests from eventually accessing the database.
The way to optimize is 加缓存
to cache each node.
Process and node for Web requests
Be familiar with processes and nodes in order to locate performance issues. and the order of optimization is generally optimized by the requested process. The process here is simply a summary and does not represent comprehensiveness.
The entire process is the fastest way to let users see the results
How to locate
The idea is: 把看不见的http,具体化、可视化
.
Positioning is the precondition of optimization. Without accurate positioning, the problem cannot be solved effectively.
Browser
- Look at the time of the whole request
- Look at the time the entire page was loaded
- Look at the size of the page loaded data
- Look at the number of page requests
For example:
Locating results
- Background request is slow
- Is the front load slow (document,js,image,request number, etc.)
Server monitoring
- Look at the time of the whole request
- Look at the SQL time (this can also be done in the database via slow log)
For example:
Locating results
- Which URLs are slow
- Which URLs are most commonly used
- Which SQL is slow
Monitoring of the Code
- To locate through System.out.print or break points.
Add an AOP to each method to monitor the execution time of the period
For example:
Long begin = System.currenttimemillis ();
Execution of the method or code
Long end = System.currenttimemillis ();
System.out.print ("Total Execution Time:" + (End-begin));
Locating results
- Which method or code has slow performance
Monitoring of the database
- Slow log
Locating results
- Which SQL is slow.
Solution Solutions
Idea: The nodes that are targeted for HTTP requests are sorted out in order. For the time being, do not consider starting 分布式
with 群集
the solution and optimization.
Optimization Agent
- Plus gzip (reduce the amount of HTTP request data)
- Caching of static resources
- Nginx Cache Integrated URL-level caching
- Static and dynamic separation
Optimizing the Web Container
- Optimized burst protocol
Optimized applications
- Add cache
- Reduce IO (reduce the cycle of Io, get in bulk, then process at the code level, optimize the algorithm, and turn the tree complexity into level complexity)
Optimizing the Database
- Add index
- Add redundant data
- Modify table structure design (this is important, sometimes because the table design is unreasonable, can be solved by adjusting the design)
- Add cache
Other Notes
The optimization aspect is not limited to the method above. Some do not have one by one to repeat. For example, adding memory is also a good solution for optimization. There are also operating system level, IO Read and write, network requests and other issues.
Original link http://www.cnblogs.com/ansn001/p/5301134.html
Optimize performance in the Web