Apache + PHP + MySQL + Tomcat performance optimization skills (original)

Source: Internet
Author: User

Apache + PHP + MySQL + Tomcat performance optimization skills (original)

Author: Yu Chao EMail: yuchao86@gmail.com

1. Apache performance optimization skills
(1) The flat configuration uses the independent cache disk mod_disk_cache to set the cache for frequently accessed data instead of mod_mem_cache.
(2) Proper Expires, Etag, and Cache-Control Headers Configuration
(3) Use mod_gzip/mod_deflate
(4) Disable safe_mode for php without using threaded mpm with mod_php
(5) do not set KeepAliveTimeout to be too high and allow symlinks

2. PHP performance optimization skills:
(1) PHP caches compiled static pages and reduces script compilation to Improve the Performance by 25-100%;
(2) When compiling PHP, use the following parameters:-enable-inline-optimization -- disable-debug to reduce script execution overhead;
(3) Use PHP internal functions as much as possible, and do not copy variables at will;
(4) The variables not used in the script should be deleted. PHP will check whether the global variables are defined to reduce the efficiency. For the global variables, unset () should be used up;
(5) If possible, the longest cycle should be placed on the inner layer, and the shortest cycle should be placed on the outer layer, which can reduce the number of times the cpu switches across the cycle layer, to optimize program performance.

3. MYSQL performance optimization skills:
(1) Optimize Select SQL statements and perform Insert and Update operations as little as possible;
(2) run the show variables like '% slow %' command to analyze slow query logs and remove the slow query logs;
(3) EXPLAIN your SELECT query to optimize your query for the index Cache
(4) Select the Correct storage engine based on the actual application, and use MyISAM for re-query speed without transactions, and InnoDB for re-transactions and security;
(5) tables with a fixed length are faster, and smaller columns are faster. Suitable Fields use suitable types. For example, it is more efficient to store a fixed number of values using ENUM than VARCHAR.

4. TOMCAT performance optimization tips:
(1) modify the web configuration file of the server. several parameters in xml: development, whether to set the environment as the development environment; genStringAsCharArray, whether to generate a more effective character array; modificationTestInterval, check whether the jsp file has updated the frequency (in seconds); trimSpaces, whether to remove the space of the response content, these values are set to false, true, 1800 (you can set it yourself), true.
(2) Use Loadrunner or Jmeter to test the interface efficiency, identify the interface bottleneck, and correct it;
(3) pre-compile jsp to speed up jsp compilation and adjust the number of threads;
(4) JVM parameter-Xms <size> optimizes and disables DNS queries.
(5) analyze the test results or the test process, determine the minimum performance standard, and quantify the load balancing.

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.