Considerations for website Optimization
In useASP. NETWhen developing a website,Performance is always a concern,Performance is not justProgramCodeThe speed of execution involves all aspects.
TakeASP. NETFor a request, from the browser to the serverASP. NETThe website sends a request until the end of the page is displayed in front of us. each step of the request has a different tuning method, and there are many calling methods, it is not just common: caching, multithreading, and Asynchronization.
This seriesArticleI decided to explain Optimization in two major aspects:
Foreground Optimization: Mainly includes how to minimizeHTTPRequest, fromHTTPRequest start, to how to loadJS, CSSAnd how to compress the transmitted data.
Background Optimization: AnalysisASP. NETThe request processing process, and corresponding tuning methods are provided in each step, and optimization methods are provided in terms of code organization, architecture, and database operations.
I remember when I was developing a website, when I mentioned how to improve performance, the easiest and fastest possible thing to think of was caching.Best PracticeSome of the documents are also recommended: layer-by-layer caching(On the data storage layer,Dal, BLL, UIAnd so on.). Then"Cache blossomed everywhere"The last one is indeed unsatisfactory.
Another common optimization is for databases: for example, to minimize the number of subqueries, useJoinJoin; create an index on the fields that are frequently to be queried. Indeed, these are common and good rules.
Another experience is that, when optimizing performance, if you choose to optimize code and database, some database operations are often optimized to bring better results, but unfortunately: in the project(At least in some projects I have developed)The database is just a data storage device, and does not play a powerful role in the database. Therefore, it is recommended that you be familiar with the internal query and storage mechanisms of the database. After all, many developers also serveDBA(Many companies do not have formalDBA).
In addition, when designing databases in projects, especially table fields, we need to consider some issues. Many people suggest that the length of table fields should not be too long. This is also a common recommendation, but why? In fact, we need to understand the internal storage mechanisms of some databases:(SQL Server)When the data is saved"Page"For the smallest unit, each page has8 KIf the data in your table exceeds8 KThe data in this table must be saved on several pages. In this way, cross-page query is required for data query, which consumes performance, if the data is on a page, the speed is certainly faster.
Therefore, to optimize the Website, you must know the performance consumption.
When optimizing a website, it is not blindly generalized. Generally, there are two situations:
1.The website already exists and runs. Now we need to optimize it.
2.A new website is being developed from scratch.
If this is the first case, we should first find out the bottleneck of the website performance, from the front-end request to the back-end request processing, until the presentation of the last page, all of which should be reviewed step by step.
In the second case, the situation may be slightly better, and the website is completely controlled by us now. Many optimization principles can be used in all development and design processes.
Optimization does not necessarily mean code rewriting or making major changes. A little bit of accumulation during optimization is like code refactoring, which is a cumulative effect. For example, loading at the beginning of a pageJSThe script is still loaded at the end of the page.JSScript, sometimes it is just a simple adjustment of the loaded file, or asynchronous loading script, or throughCDNTransmission of scripts and other methods improves the performance. Performance improvement is not costly, and some costs are very small. For example, if you just load the script at the end of the page, the high cost is, for example, buying some server devices, suchContent Delivery Network (CDN)To put static files(JS, CSS, image)To the client. Therefore, optimization requires a balance strategy.
I don't know if you have had this experience: When you look at the system performance you have developed, you are very confident. On the contrary, if the system is slow, sometimes I really don't want to say that this system is self-built.
Link: http://www.cnblogs.com/yanyangtian/archive/2011/02/11/1951055.html