Systematic performance tuning vomiting blood summary sharing: Reprint

Source: Internet
Author: User

Overview

Ø The thinking of performance optimization

The first is a more accurate positioning problem, with the help of the corresponding toolkit, the analysis of the system performance bottlenecks, in accordance with its performance indicators, and the level of decision-making choice of the way to optimize. In the selection of the method of optimization, we can refer to the following sections of the tuning method, the architecture optimization progression, the correct, targeted, step-by-stage optimization. may be found that some of the guiding ideology may be contrary to suspicion, can not be serious, the system optimization process itself is a continuous separation + sharing of the combination of boxing, as to the specific choice of which optimization method, according to the specific needs to set, but the general idea of large-scale application development is constantly separated, in the index (non-database) to correlate,

Remember: optimization must be carefully palpation the system, to find the root cause of performance problems, and not to be blurred, the right remedy, found that the doctor is not better than the surgeon to operate the scalpel level poor. This article has a toolkit chapter, for those who need to do optimization, need to be familiar with, he is our diagnosis of the CT, for example, we found that the memory is high, the first thought is not enough memory, but why the memory is so consumed, and tools to see where the memory consumption, imagine, as in the hospital, the patient told the doctor, his heart , the doctor will change the heart, in that case, everyone can be a doctor if they master the chopper.

Ø Iterative Optimization

Performance optimization is not necessarily one-time can be met, the bottleneck here may disappear, once the system is running fast, and other places to find new performance bottlenecks, so performance optimization is an iterative work. To meet the performance metrics required by the system.

Ø Optimized cost

System performance design or optimization can be a step up, according to the best distributed architecture design and optimization, a single node has been operating and health, in theory, can reach the Comintern, but the actual implementation of the level is not desirable, must be combined with the practical non-functional requirements of the design and optimization, a step to the extreme words, The cost of the system is too high, the cost of performance design and optimization is higher than the value provided by the system itself to the customer, and the cost of research and development costs too much. Two people who seem to be able to structure such a perfect system have not been born yet. So a sentence is also suitable for the architect: there is ideal and not idealized, nonsense less pull: concrete See the law

Optimization of tuning Method database

Many applications, the optimization of the DB is often the most direct, most convenient, the most effective, but not all system performance is in the bottleneck, or DB bottleneck after the solution, may apply layer bottlenecks, Web layer bottlenecks, and even the architecture bottlenecks will come out, so database optimization is very important, But often many people understand that system optimization is a database optimization, is not comprehensive. Optimization roles generally recommend a programmer with deep data knowledge, or a professional DBA, rather than a crud developer

Ø establish the correct primary key, foreign key, and index

Ø separation principle: Read and write separation, separation of business data

A) Sub-Library

b) Partitioning

c) Sub-table

d) Breakdown (large print, infrequently used isolation to his table, query on Demand)

Ø Select Isolation level: Some of the data consistency requirements are not high, can sacrifice partial consistency, reduce lock blocking

Ø ensure that transactions are short and unnecessary locking mechanisms are reduced.

Ø Query Optimization Rules:

e) Avoid related sub-queries within the table;

f) Avoid sorting or sorting as few rows as possible,

g) do a lot of data sorting when relevant data is placed in the temp table

h). Try to pass the query criteria as much as possible to reduce the rows that are not necessarily returned

i). Select only the required fields to reduce the columns that are not necessarily returned

Ø Paging stored procedure: A large list of queries can also be optimized using a paging stored procedure.

Ø maximize the system with database caching, views, temporal tables, etc., and optimize the stored procedures and functions as necessary

Ø if necessary, can be redundant table field, avoid joint query

Ø if necessary, you can also separate large segments of the table into separate tables so that they are queried separately

Ø must be Long Table association, as far as possible to filter the discrepancy table data, reduce the Cartesian product calculation amount

Ø Complex table: such as real-time requirements are not high, as far as possible background task calculation, avoid dynamic query

Application-Level optimization

Application-Layer optimization focuses on the application layer's own logic optimization, algorithm optimization, code optimization, etc., the role of optimization can be familiar with the application of the programmer

Ø optimization algorithm, select the appropriate and efficient algorithm, reduce unnecessary recursion, cyclic, multi-layer loop nesting and other calculations

Ø avoid excessive application of unnecessary memory overhead

Ø reduced memory leaks (using,dispose, weak references, Finalize)

Ø use of large files with low frequency, large objects, large arrays, etc. after use, timely release

Ø use high-frequency large files, large objects, large arrays as far as possible cache

Ø Consider multithreading technology

Ø choose the appropriate means of communication: long connection, short connection, socket, Remoting, Web Services (Rest,soap), WCF, Named Pipes in the following ways

Ø reduce the number of communication between applications, example user authentication service, Workflow service, database service

Ø reduce the amount of data transmitted between applications, do not have to transmit, less transmission

Cache mechanism: Cache is commonly used, not easy to change, occasionally change, you can consider the cache dependency mechanism

Ø support asynchronous computation, reduce wait time

Ø consider lazy loading, or two ways to load ahead of time

Ø Separation principle: Separation of business modules, such as separation of large I/O modules, separation of high-consumption memory modules, separation of high-consumption broadband modules

Ø consider distributed applications, distributed storage, as above all still uncertain

Web optimization

Web optimization in favor of a technician familiar with front-end development

Ø Reduce HTTP Requests

Ø Avoid 404 errors

Ø Add cache tag to HTML page header

Øgzip compressing Web pages

Ø Reduce Cookie Volume

Ø use external JS and CSS

Ø subtractive js and CSS

Ø Compression JS

Ø using CSS Sprites technology, a lot of pictures are synthesized together, through CSS slicing, reduce the frequency and the amount of data transmitted by the picture

Ø you can use static Web pages, avoid using Dynamic Web pages

Architecture optimization Progression

In order to show the difference with the application layer optimization, this article on the structure of the description of more emphasis on the physical level, again, involved in the change of architecture, need our application has good extensibility, test our architect's usual foundation, how to meet demand and business increment within two or three years, but not the more powerful architecture, the more flexible , the more configurable, the easier the level of expansion is the better, the first consideration of the application of input-output ratio, in other words, whether it is worthwhile to invest so many architectural design costs, the other architecture design is also a certain timeliness, it speed is too fast, today's good things may not be tomorrow's good things, young beautiful girl, There's always going to be an old woman. Then, the more flexible the architecture means there are more configuration items, from one aspect, instead of increasing the complexity of the system, and finally, a lot of large, mature applications, not overnight, but through continuous adjustment optimization, constantly change the architecture. The Saints are not born, but are constantly summed up, refined, optimized, reconstructed

Ø High-performance small and medium-sized machines and storage devices are used in hardware. Use Excellent network bandwidth

Ø physical separation of Web server and DB server or other services such as: User authentication Service

Ø Cache

ü Data caching mechanism

ü Page Caching mechanism

Ø Physical Separation Business module, single service deployment of one server

Ø Deploy multiple Web servers

Øweb Load Balancing-f5

Ø data read/write separation

Ø Synchronous/asynchronous computation between various applications using Message Queuing

Ø Select the appropriate communication mode between applications, communication protocol

Øweb distributed, distributed application, distributed data

Ø distributed nodes using high-performance servers, small fleet, supplemented by high-speed network bandwidth, etc.

Tool Pack

Ø process Manager, CPU, memory, I/O

Ø log: IIS log, Windows log, system itself log

Ø use Dottrace, tracking method execution time, find out the method of slow speed, targeted optimization

ØSQL Profile tracking SQL time-consuming, targeted optimization

Øhttpwatch tracking requests take time, and the amount of data sent and received

Øperformance count, using counters, statistics related performance indicators

Øclrprofiler Memory Leak Detection Tool

Øloadrunner, stress testing, detection of performance bottlenecks

Other supplements

Systematic performance tuning vomiting blood summary sharing: Reprint

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.