Lamp Optimization Techniques

Source: Internet
Author: User
Tags html page mysql php script mysql database linux

[Lamp Platform]

Lamp is the combination of linux+apache+mysql+php, lamp is the origin of the word first began in the German magazine "C ' t Magazine", Michael Kunze in 1990, the first combination of these projects together to create lamp abbreviations. These components are not designed to be used together, but they can be readily available and available free of charge. This leads to the common use of these components. In the past few years, the compatibility of these components has been perfected, and the application situation has become very universal. Some extension features have been created to improve collaboration between different components. Currently, the "LAMP stack" product is included by default in almost all Linux distributions. These products form a powerful Web application platform

The LAMP platform is composed of four components and is layered. Each layer provides a key part of the entire software stack:

The Linux:linux is at the lowest level and provides the operating system. Each of the other components actually runs on Linux as well. However, it is not necessarily limited to Linux, and other components can be run on microsoft®windows®, Mac OS X, or UNIX® if necessary.

Apache: The lower level is Apache, which is a WEB server. Apache provides a mechanism for users to get a Web page. Apache is a stable, mission-critical server that is used as a Web server by more than 65% of Web sites on the Internet. PHP components are actually in Apache, and dynamic pages can be created via Apache and PHP.

The mysql:mysql provides the data storage side of the LAMP system. With MySQL, you get a very powerful database for running large, complex sites. In a WEB application, all data, products, accounts, and other types of information are stored in this database, and can be easily queried in SQL language.

Php:php is a simple and effective programming language, like a binder that can glue all the other components of the LAMP system together. You can use PHP to write dynamic content that accesses the data in the MySQL database and some of the features that Linux provides.

[Detection Tool]

In order to get complete debugging results, it is recommended that you adopt apachebench or Httperf software. If you are interested in server testing for a non-LAMP architecture, it is recommended that you adopt Microsoft's freeware: Web application Stress Tool (NT or 2000 required). (Other server test tools)

Detects Apache, using top D 1 to show the CPU and memory of all processes. In addition, the APACHECTL status command is also used

[Hardware optimization]

1, upgrade the general rules of hardware: For PHP script, the main bottleneck is the CPU, for static pages, the bottleneck is memory and network. A static page downloaded by a normal Pentium machine at Mhz can saturate the T3 line (45Mbps).

2, the use of hdparm to optimize the disk, can generally improve the IDE disk read and write performance 200%, but the SCSI hard drive also has effect. (different type of hard drive contrast)

[Policy optimization]

3, the Apache processing PHP script is slower than the static page 2-10 times, so try to adopt more static pages, less script.

4, PHP script if do not buffer, each call needs to compile, therefore, install a PHP buffer product can improve the performance of 25-100%.

5, if you adopt a Linux system, it is recommended to upgrade the kernel to 2.4, because the static page is serviced by the kernel.

6, another buffer technology is the less frequently modified PHP page with HTML buffer output.

7, do not run X-windows on the WEB server, turn off the process that is not necessary to run.

8, if you can use the text do not use the image, as far as possible to reduce the size of the picture.

9, spread the load, put the database server on the other machine up. Using another low-end machine service picture and HTML page, if all static pages are processed on another server, you can set the keepalives in httpd.conf to off to reduce the time to disconnect.

10, all of the above methods are for stand-alone, if you think the system is still not fast enough, you can use clustering, load balancing, buffering technology. Squid is used as a buffer to configure Squid method.

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.