Common performance optimization methods for Java Web systems

Source: Internet
Author: User

In many enterprises, some Web applications, in the early days of operation due to the small number of users, system pressure, the system is operating in good condition. With the passage of time, may be due to a system changes in the enterprise, so that the original is not popular system, has become a daily need to use, due to the proliferation of users, the original system design and implementation of the shortcomings of a large number of exposure, and the most intolerable is that the system response time is longer, This can become unbearable even when users are centrally accessed at a certain time. This often leads to a lot of pressure on the relevant business units and the technicians responsible for system operations. This article will describe how to optimize and improve these systems, even if there is no relevant system needs optimization, but also in the system design and development phase to avoid the corresponding problems.

The optimization of web systems can be started in three ways: pages, databases, and applications.

Page optimization

We can analyze the statistics by Firebug, HttpWatch and other pages, analyze the main pages, see the pictures, CSS styles, JavaScript scripts that the pages need to load, how much time it takes to load them, and whether there are any failed or invalid scripts, styles, and pictures.

For the analysis results, the corresponding optimization, such as: To remove the invalid image, CSS style, JavaScript script, according to the tool to display the access time, to find out the loading of long pictures, to determine whether the picture is too large. Can be optimized for pictures, such as image compression technology. This can effectively reduce the page load time. Another way to optimize is to combine multiple styles of pictures on a large image, and the style of the page is displayed using a mask that does not pass through the same picture.

You can also do this by statically processing the main page. Many website class system, the home page undertakes the information publication, the user login and the related link display and so on many kinds of functions, when the visit quantity is big, some system homepage loading all need very long time, directly to the user to cause the poor experience. Solving this problem simply using AJAX lazy loading does not solve the problem. It is recommended to use a web crawler, the first page and other main pages to generate static pages regularly. The HTTP server will be the static page in the system proxy, the user does not need to request the application server can directly access the homepage, and login and other related operations, the first page of the static operation will greatly reduce the pressure of the back office system.

Database optimization

The optimization of database is mainly based on the optimization of SQL query statement. This work is more difficult than the optimization of the page, need good SQL skills and knowledge of the system business, but some of the bottleneck of the system exists in the database. In the system design stage, we need to plan the database tables reasonably, in the way of avoiding a business need to query multiple database tables design. From the point of view of system optimization, we need to check whether there are multiple layers of nested subqueries inside the system, or a large number of commands that use in and like as conditional matching. Inefficient query statements consume the CPU resources of the server, resulting in a slow system response. Often occurs in a query operation, will cause the business request can not be responded to, when the query operation is completed, the system response to normal, if the system is running in a certain amount of users, the response time is slow, it is very likely due to the database cause. You can query the most time-consuming SQL statements by command, and then optimize the SQL in your system based on the fetch results.

Now the Internet companies in the implementation of the system will reduce the reliance on the database, many early design of the system will be based on database scripts for batch processing, now the design of the system is mostly based on the application of processing, using some NoSQL database part to replace the relational database, Only the more transactional data is stored in the relational database. Applications are now much more extensible than relational databases.

Application optimization

Most programmers have heard the phrase: "Use space for Time", which is reflected in programming is the application of the cache, "space" refers to the memory, the same is to obtain data, read from local memory time is much less than the time required to get from the database, network and hard disk. At present, most of the caches in the program are based on memory as storage carrier. You can store some of the values in your program that are seldom changed in the cache. Mainstream caches often use key-value pairs to store data, including: Memcache, Redis, and so on.

Some large-scale e-commerce sites, in the face of large-scale promotional activities, in order to improve the system processing capacity, in Redis to achieve the synchronization of commodity inventory operation, the use of a large number of memory operations to replace the database operation, can avoid the system again large traffic environment of the database bottleneck. At present, the Internet company's system is mostly deployed on the PC server, compared to minicomputer, PC server in the configuration and processing capacity is not inferior, but the probability of machine failure is higher than minicomputer. The way to solve this problem is to "win the volume", the data and applications deployed on multiple PC servers, the PC server is the master, even if one of the problems, there are other machines responsible for providing services, the problem of the machine's data and applications will soon be migrated to other machines , and then provide the service. The maturity of virtual machine technology in recent years has further reduced the deployment cost of PC server cluster. In contrast, extending Java virtual machines is less expensive than extending the database (especially Oracle)

Common performance optimization methods for Java Web systems

Related Article

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.