5 simple methods for optimizing LAMP

Source: Internet
Author: User
Tags apc
Article Title: five simple methods for optimizing LAMP. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Wikipedia, Facebook, and Yahoo! And other major web properties use the LAMP architecture to provide services for millions of requests per day, web application software such as Wordpress, Joomla, Drupal, and SugarCRM use its architecture to make it easy for organizations to deploy web-based applications.
The advantage of this architecture lies in its simplicity. And. NET stacks and Java? Technology may use a large number of hardware, expensive software stacks, and complex Performance Tuning. LAMP stacks can run on commodity hardware and use open source software stacks. Since the software stack is a loose component set rather than a whole stack, performance tuning is a major challenge because each component needs to be analyzed and tuned.
However, there are several simple performance tasks that will have a huge impact on the performance of any scale of websites. In this article, we will explore five of these tasks to optimize the performance of the LAMP application. These projects should rarely require architectural changes to your applications, making them a safe and convenient choice to maximize the responsiveness and hardware requirements required by your web applications.
Use operation code Cache
The simplest way to improve the performance of any PHP application (of course, the "P" in LAMP) is to use an operational code cache. For any website I use, it is a content that I ensure exists, because the performance has a great impact (many times with the operation code cache, the response time can be reduced by half ). But one of the biggest questions most people are not familiar with PHP is why the improvements are so great. The answer is how PHP processes web requests. Figure 1 provides an overview of the PHP request process.

 
Figure 1. PHP request
Since PHP is an interpreted language, rather than a C or Java compiling language, the entire process of "Resolution-compilation-execution" is executed for each request. You can see why this is time-consuming and resource-consuming, especially when the script rarely changes between requests. After parsing and compiling the script, the script is in the machine-resolvable state as a series of operation codes. This is where the operation code cache is used. It caches these compilation scripts as a series of operation codes to avoid parsing and compiling each request step. You will see in Figure 2 how such a workflow works.

 
Figure 2. PHP request using the opcode Cache
Therefore, when the cache operation code of the PHP script exists, we can skip the parsing and compilation steps of the PHP request process, directly execute the cache operation code and output the result. Check that the algorithm is responsible for processing the changes you may have made to the script file. Therefore, after the first request of the changed script, the operation code is automatically re-compiled and cached for subsequent requests, replace the cached script.
The opcode cache has been popular with PHP for a long time. Some of the earliest operations should be traced back to the full-lifecycle PHP V4. Currently, some popular options are being developed and used:
· Replacing PHP cache (APC) may be the most popular PHP operation code cache. It was developed by several core PHP developers and has made great contributions, Facebook and Yahoo! The engineers granted the speed and stability. It also supports several other speed improvements for processing PHP requests, including a user cache component, which will be discussed later in this article.
· Is Wincache mainly composed of Microsoft? Internet Information Services (IIS) team is actively developing an operation code cache for Windows? . The main motivation for developing it is to make PHP a first-class development platform on the Windows-IIS-PHP stack, because it is known that APC is not operating well on the stack. It functions very similar to APC and supports a user cache component and a built-in session handler to use Wincache directly as a session handler.
· EAccelerator is a derivative of Turck MMCache, one of the original PHP caches. Unlike APC and Wincache, it is only an operator code cache and optimizer, so it does not contain user cache components. It is in UNIX? It is fully compatible with Windows stacks and is popular for sites that do not intend to use other features provided by APC or Wincache. If you want to use solutions such as memcache to provide a separate user Cache Server for multiple web server environments, this is common.
Undoubtedly, an operation code cache is the first step to accelerate PHP by eliminating the need to parse and compile scripts after each request. After completing step 1, you should see improvements in response time and server load. However, we will discuss more about optimizing PHP.

[1] [2] [3] Next page

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.