1. General hardware upgrade rules: For PHP scripts, the main bottleneck is CPU, and for static pages, the bottleneck is memory and network. The Static Page downloaded by a 400 MHz ordinary Pentium machine can make the T3 leased line (45 Mbps) saturated.
2. Apache processes PHP scripts 2-10 times slower than static pages, so try to use more static pages and fewer scripts.
3. If PHP scripts are not buffered, compilation is required for each call. Therefore, installing a PHP buffer product can improve the performance by 25-100%.
4. Switch a file-based session to a shared memory-based session. Use the -- with-mm option to compile PHP and set it in PHP. ini.SetSession. save_handler = mm. This simple modification can reduce the session management time by half.
5. Another Buffer technology is to use PHP pages that are not frequently modifiedHtmlBuffer output.
6. If you use a Linux system, we recommend that you upgrade the kernel to 2.6.0 or later (the latest version is 2.6.10) and enable preemptible Kernel support, because the static page is provided by the kernel service.
7. Use the latest version of Apache, compile PHP, or use the DSO mode. Do not use CGI.
8. Use the output buffer (see ob_start). If yourCodeThere are many print and echo statements, which can be increased by 5-15%.
9. Do not run X-Windows on the Web server. disable unnecessary processes. If X-Windows is installed, use init 3 to exit.
10. If you can use text, do not use images. Minimize the image size.
11. Distribute the load and put the database server on another machine. Images andHtmlPage. If all static pages are processed on another server, you can set keepalives in httpd. conf to off to reduce the disconnection time.
12. Using hdparm to optimize disks generally improves the read/write performance of IDE disks by 200%, but it does not work on SCSI hard disks.
13. Modify httpd. conf:
# Disable DNS lookups. The PHP script only takes the IP address.
Hostnamelookups off
# Disable htaccess Detection
AllowOverride none
Enable followsymlinks and disable symlinksifownermatch to prevent lstat () system calls:
Options followsymlinks
# Options symlinksifownermatch
There are also many adjustments to the httpd. conf parameter.
14. The Kurt is concise and completeApache tuning tips.
15. If you prefer to modify the Apache source code, you can installLinadh. After pages are generated and sent, every Apache process will waste some time on the customer connection. lincept can take over the work, allowing Apache to quickly serve the next customer request.
16. If the network is crowded and the CPU resources are insufficient, use the PHPHtmlCompression function:
Output_handler = ob_gzhandler
Do not use PHP 4.0.4 or earlier versions because of Memory leakage.
17. Modify the sendbuffersize in httpd. conf to set the size of your maximum page file. Increase the TCP/IP of the kernelWrite buffer size.
18. Another articleArticle:Tuning Apache Web ServersForSpeedA 97-year-old article.
19. When using persistent database connections, do not set maxrequestsperchild too large.
20,Caching tutorialForWeb authorsAndWebmastersShows you how to implement browser buffering.
21. If you are brave enough, you can also useAccelerated ApachePatch. This project can make Apache 1.3 faster than 10 times, and Apache 2.0 faster than 4 times.
22. FromProfessional ApacheSkills.
23. OfficialPerformance TuningDocumentation, good information, but very tedious.
24. The following parameters are recommended for compiling PHP:
-- Enable-inline-optimization -- disable-Debug
25. Install page compression software such as mod_gzip (apache1.3) or mod_deflate (apache2.0) to reduce server congestion. Optimize your HTML and PHP files as much as possible.
26. Optimized Linux, more Linux, and Solaris.
27. If the System Bottleneck lies in MySQL DATA operations, you can consider splitting MySQL into multiple ports or even multiple servers and optimizing my. CNF, which is much faster than using a single port.
26. All the above methods are for standalone servers. If you think the system is not fast enough, you can use the cluster, Server Load balancer, and buffering technologies. Use squid as the buffer and configure squid.