1. High performance of application systems
The high performance of the application system is similar to how to keep a person healthy and not go to the doctor. We all know the ways to stay healthy, such as eating a balanced diet, taking regular breaks, exercising, etc. For an application, there are usually hardware, operating system (OS), median price, application itself, etc.
2. Basic design principles
2.1 Divide and conquer
In a word: “divide”
- The points of the business
- According to the level of points
- According to the read/write points
- Ann action points
- By traffic (Load Balancing)
- By time (asynchronous)
2.2 Stability Principle
After the completion of “points”, the overall stability of the system should be ensured:
- Honor and disaster preparedness
- monitoring
- plan
- Current limiting
- demotion
3. Optimize Web front-end performance
3.1 Browser Access Optimization
- Reducing HTTP requests
HTTP is a stateless application layer protocol, which means that each HTTP request needs to establish a communication link for data transmission. On the server side, each HTTP request needs to start an independent thread to process. These communications and services are expensive, and reducing the number of HTTP requests can significantly improve access performance.
The main ways to reduce HTTP are to merge CSS, JavaScript, and images. Combine the JavaScript and CSS that the browser needs to access once into a single file, so the browser only needs to request it once.
- Using browser caching
Static resource files such as CSS, JavaScript, logos, and ICONS are updated infrequently on a website, and these files are required for almost every HTTP request. Caching these files in a browser can greatly improve performance. By setting cache-Control and Expires attributes in the HTTP header, you can set the browser Cache, which can last for days or even months.
In particular, when updating static resources, it is not appropriate to update all static resources at the same time. Instead, it should be updated gradually one file at a time, with a certain interval, so as to avoid a sudden failure of a large number of cache in the user’s browser and centralized update of cache, resulting in a sudden increase in server load and network congestion.
- Enable compression
File compression on the server and decompression on the browser can effectively reduce the amount of data transmitted
- CSS is placed at the top of the page and JavaScript at the bottom
Browsers do not render the entire page until the entire CSS has been downloaded, so it is best to put the CSS at the top of the page and let the browser download the CSS as soon as possible. JavaScript, on the other hand, is best placed at the bottom of the page because browsers execute JavaScript immediately after loading it, which can block the entire page and slow the display of the page.
- Reduce Reduces Cookie transmission
On the one hand, cookies are included in each request and response. Too large cookies will seriously affect data transmission. Therefore, it is necessary to carefully consider which data needs to be written into cookies and minimize the amount of data transmitted in cookies. On the other hand, for the access to some static resources, such as CSS and Script, it is meaningless to send cookies. You can use independent domain names to access static resources to avoid sending cookies when requesting static resources and reduce the number of Cookie transmission.
3.2 the CDN to accelerate
The full name of CDN is Content Delivery Network. Its purpose is to add a new layer of CACHE(CACHE) layer in the existing Internet, the content of the website will be published to the nearest user’s network “edge” node, users can get the content needed nearby, improve the response speed of users to visit the website. From the technical comprehensive solution because of the network bandwidth is small, the user visit is large, the network distribution is not equal, improve the user access to the website response speed.
In simple terms, the working principle of CDN is the resource cache will stand you source into a world of CDN node, when the user requests resources, returned to the nearest node cache resources, without the need for each user’s request to return to your source all stand for, to avoid network congestion, reduce the pressure on the source station, speed and experience to ensure users to access resources
3.3 Reverse Proxy
In Reverse Proxy mode, a Proxy server receives Internet connection requests, forwards the requests to the Intranet server, and returns the results to the Internet client. In this case, the proxy server acts as a reverse proxy server.
Through placed throughout the network reverse proxy server nodes of a layer of intelligence on the basis of the existing Internet virtual network, CDN system can in real time according to the network traffic and each node connections, load condition and to the user’s distance and comprehensive information such as response time will the user’s request to guide users closest service node
4. Optimize application server performance
4.1 Distributed Cache
Distributed caching is designed to solve the bottleneck between database server and Web server. If a website traffic is very large, the bottleneck will be very obvious, each database query time is not optimistic, it can be solved by distributed cache system, such as Redis, MemCache and so on.
4.2 asynchronous
Asynchrony can be set up using thread pools, message queues, etc. The use of thread pool must pay attention to the setting of core parameters, you can monitor tools to observe the actual number of created, active, idle threads, combined with CPU, memory usage to do thread pool tuning; The other is to use the NIP to implement asynchronization.
4.3 Service Cluster
The basic principle of servitization is to split services based on services to avoid cross-service interaction and split data and services simultaneously.
The same service can be split by computing /IO intensive services, core/non-core services, and high-frequency services deployed separately.
4.4 Optimization of code logic
Code logic tuning is often overlooked, but the effect is more obvious than database tuning, JVM tuning, and so on. Take 12306 Spring Festival Transport snatching train tickets as an example. There are a lot of users, so the query may be slow. Users habitually click the query multiple times, which increases the load of the back-end system. In this case, we can disable the button after the user clicks on the query, or control how many requests can be submitted once in a second through JS, etc.
4.5 Hardware Optimization
Hardware optimization need not say more, conditions allow, hardware performance directly full! Solid-state drives, for example, are definitely better than mechanical drives.
5. Database performance optimization
-
The index optimization
-
Eliminate big data table joins
-
The paradigm
-
Cache Cache
-
Split into multiple queries
-
Avoid complex SQL
-
SQL Performance Optimization