Voyeur PHP compilation cache_php tutorial

Source: Internet
Author: User

The load product neck is generally mainly in the following four aspects:
1 database

2 Server CPU

3 hard disk I/O

4 Network bandwidth

Except for these four ghosts. What else is worth optimizing for? PHP is really strong. Today, the PHP script level to adjust the performance of PHP.
If you want to improve PHP performance on a single server. We can use "compile cache". Compiling the cache not only improves performance but also increases the performance of the server as the capacity and code complexity of the PHP program increases. What is the compile cache? I'll tell you what. Let's start by saying two steps for PHP to compile the script file:

1 PHP engine reads script files, interprets scripts and generates executable intermediate code in the Zend engine

2 ZEND start execution of intermediate code for the second time

We have to pay attention. The first step is to repeat every time the php script file is requested. And this process will repeat the first step recursively, because the script includes include () require () eval (). It is conceivable how much it consumes. Special PHP files are very large at the time. So why is it recommended to write PHP files when the number of rows is not supported.
When it comes to this, everyone understands. Actually, we can do some articles in the first step. If we take the first step to explain the file there, the interpreted code is cached in the shared memory. If you have a second request for this script, you can skip the first step and go directly to the second step. Because the first step is already in the memory of the cache.
Let's look at the chart and compare

Look first if you don't use the compile cache

One more use of the compile cache.

All right, I'll see. Right. With the compilation cache less go a lot of detours. Especially in your code there are a lot of include AH require AH is particularly effective.

Now we introduce three compiled caches:
1 The Ioncube Accelerator not open source said.
2 Thezendaccelerator asked for money. I'm poor!
3 APC This one I like best because no money. The effect is pretty good, huh?
Let's just say APC.
Installation is probably the case. Install via Pear
#pear Install APC
Modify the next php.ini plus extension
Extension =/path/to/apc.so

OK, that's so easy. But when you run PHP again. This APC is already in effect. The code is compiled and the cache is in share memory. That's cool. It's better than a woman doing a woman.

If it's window, look for this. this extension http://pecl4win.php.net/list.php

After the APC is installed we also need to adjust the parameters of the APC in all aspects. This of course adjusts according to your own project environment.

APC has several parameters. Own Baidu to go.

Finished.

It's not finished yet. Please pay attention to my blog www.laoniphp.com

http://www.bkjia.com/PHPjc/508320.html www.bkjia.com true http://www.bkjia.com/PHPjc/508320.html techarticle The load product neck is generally mainly in the following four aspects: 1 Database 2 server CPU 3 hard disk I/O 4 network bandwidth except for these four ghosts. What else is worth optimizing for? PHP is really strong ...

  • 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.