search
HomeBackend DevelopmentPHP TutorialAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial

About PHP acceleration eAccelerator, The interview question asked how many PHP accelerators/About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorials do you know? I was stunned because the PHP5.2.x I knew only used Zend Optimizer, and encrypted PHP programs can only run under Zend Optimizer. However, Zend Optimizer cannot support php5.3.x or above, let alone eAccelerator, XAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial, and APC. Zend guard loader can support php5.3.x or above, and the latest php5.5.x version, the official website says that Zend guard is built-in, so phper should not pay attention to the accelerator. Now that I have encountered such a problem, I have summarized things from the Internet. Netizens can just read it and there is no need to test it.

Which one to install? What impact will it have on performance? Have time to test it out.

Viewed from elsewhere.

When the program environment does not require Zend Optimizer, pecl-APC is preferred (it is not compatible with Zend Optimizer).

Summary:

1. pecl-APC is the first choice for PHP buffering (acceleration), with excellent compatibility and performance.

2. If your PHP environment requires Zend Optimizer, install eAccelerator and adjust the compression level of Zend Optimizer to 0.

zend optimizer is a code optimization module that can tune PHP code. The principle of implementation is to optimize the code generated by the run-time compiler (Run-Time Compiler) before being finally executed. Code performance can be improved by 40% to 100%. From this point of view, it should not have a strong caching function. I have not read the source code, so I don’t know whether there is a About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial and what the About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial quality is.

eAccelerator is a module that About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorials compiled PHP code in shared memory. By accessing shared memory, the compiled code can be obtained and executed directly to improve efficiency. This greatly improves the execution efficiency of PHP. At the same time, eAccelerator can also About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial data into files. Since this part is an operation on files, I think that for most file About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorials, the principles are similar and the performance is similar.


APC is similar to eAccelerator in principle, so there is not much difference. Without detailed testing by modifying the parameters, the advantages and disadvantages of the two cannot be seen. So just pick one.


Comparison of three free PHP accelerators: APC, eAccelerator and XCache

1. Introduction to PHP accelerator

PHP accelerator is a tool that About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorials PHP opcodes to improve PHP execution efficiency, so that PHP does not need to be parsed and converted later when executed. PHP opcodes can be directly called, which improves the speed a lot.

The request and response execution process using mod_php in Apache:

1. Apache receives the request.

2. Apache passes the request to mod_php.

3. mod_php locates the disk file and loads it into memory.

4. mod_php compiles the source code into an opcode tree.
5. mod_php executes the opcode tree.

The PHP accelerator corresponds to the fourth step. Its purpose is to prevent PHP from repeatedly compiling PHP code for every request, because on high-traffic websites, a large number of compilations are often not executed as fast? So there is a bottleneck here, which is that repeated compilation of PHP affects both speed and server load. In order to solve this problem, the PHP accelerator was born.

2. PHP accelerator installation and configuration

 1. Install and configure APC

The full name of APC is Alternative PHP Cache. The official translation is called "Optional PHP Cache". It is an extension in PHP PECL. It seems that Facebook is using it. Start the installation below (ubuntu environment): $wget http ://pecl.php.net/get/APC-3.0.19.tgz

$tar xvzf APC-3.0.19.tgz

$cd APC-3.0.19/APC-3.0.19
$/usr/local/php/bin/phpize
$./configure –enable-apc –enable-apc-mmap –with-php-config=/usr/local/php/bin/php-config
$make
$sudo make install

Next we configure APC. Because my PECL extension path has changed, I have to move the compiled file:
$sudo mv /usr/local/php/lib/php/extensions/no-debug -non-zts-20060613/apc.so /usr/local/php/lib/php/extensions/PECL

Then we edit the php.ini file for configuration. Please add the following code to php.ini:
extension_dir = "/usr/local/php/lib/php/extensions/PECL"

extension = apc.so

; APC
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64
apc.optimization = 1
apc.num_files_hint = 0
apc.ttl = 0
apc.gc_ttl = 3600
apc.About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial_by_default = on

In this way, restarting apache will be displayed in the phpinfo() information.

2. Install and configure eAccelerator

The predecessor of eAccelerator is actually truck-mmAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial. Because the person who developed truk-mmAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial was recruited by Zend, the person who developed eAccelerator inherited some features of truk-mmAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial and designed the eAccelerator accelerator. Install as follows:
$wget http://jaist.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5.tar.bz2
$tar -jxf eaccelerator-0.9.5.tar.bz2
$cd eaccelerator-0.9.5
$/usr/local/php/bin/phpize
$./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/ bin/php-config
$make
$sudo make install
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so / usr/local/php/lib/php/extensions/PECL

Add the following code to the php.ini file
extension = eaccelerator.so
; eAccelerator
eaccelerator.shm_size = "16"
eaccelerator.About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial_dir = "/tmp/eaccelerator"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.check_mtime = "1"
eaccelerator.debug = "0"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "0"
eaccelerator.prune_period = "0"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"

Create About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial directory and restart apache

$sudo mkdir /tmp/eaccelerator
$sudo chmod 777 /tmp/eaccelerator
$sudo /usr/local/apache/apachectl restart

Check whether the installation is successful in phpinfo().

3. Install and configure XCache

XCache is something developed by Chinese people. Even as a newbie, I am proud of it. Moreover, XCache does a good job in terms of speed and performance. Let’s taste it now!

$wget http://xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.lighttpd.net/pub/Releases/1.2.2/xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial-1.2.2.tar.gz
$tar xvzf xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial-1.2.2.tar.gz
$cd xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial-1.2.2
$/usr/local/php/bin/phpize
$./configure –enable-xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial –enable-xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial-coverager –with-php-config=/usr/local/ php/php-config
$make
$sudo make install
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.so / usr/local/php/lib/php/extensions/PECL

Add configuration information in php.ini:

extension = xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.so
; xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.admin.user = "admin"
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.admin.pass = "(execute) echo '(your password)'|md5sum( ciphertext)"
;
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.size = 24M
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.shm_scheme = "mmap"
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.count = 2
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.slots = 8k
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.ttl = 0
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.gc_interval = 0

xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.var_size = 8M
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.var_count = 1
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.var_slots = 8k
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.var_ttl = 0
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.var_maxttl = 0
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.var_gc_interval = 300
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.test = Off
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.readonly_protection = On
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.mmap_path = "/tmp/xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial"
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.coredump_directory = ""
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorialr = On
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.stat = On
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.optimizer = Off
;
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.coverager = On
xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.coveragedump_directory = ""

Create About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial directory and restart apache

$sudo mkdir /tmp/xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial
$sudo chmod 777 /tmp/xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial
$sudo /usr/local/apache/bin/apachectl restart

Go and check the phpinfo() information!

3. PHP accelerator test

1. Test environment

Hardware: AMD Athlon 64 X2 Dual Core Processor 4400+ @ 2.2GHz CPU, 2GB RAM. 160GB SATA hard drive

Software: Linux Ubuntu server Gutsy 7.10, Apache 2.2.4, MySQL 5.0.45 and PHP 5.2.3

Test command: ab -c5 -n3000 http://example.com/ (We are using the Apache Benchmark (ab) tool, the concurrent connection is 5, 3000 requests)

2. Test results

No accelerator:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 288.255212 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 10.41 [#/sec] (mean)
Time per request: 480.425 [ms] (mean)
Time per request: 96.085 [ms] (mean, across all concurrent requests)
Transfer rate: 226.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 19
Processing: 181 479 186.0 444 1822
Waiting: 166 461 184.7 427 1708
Total: 181 479 186.0 444 1822
Percentage of the requests served within a certain time (ms)
50% 444
66% 525
75% 577
80% 619
90% 732
95% 819
98% 946
99% 1012
100% 1822 (longest request)

APC Accelerator:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 98.530068 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 30.45 [#/sec] (mean)
Time per request: 164.217 [ms] (mean)
Time per request: 32.843 [ms] (mean, across all concurrent requests)
Transfer rate: 661.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 58 163 71.2 155 2452
Waiting: 53 158 69.6 150 2329
Total: 58 163 71.2 155 2452
Percentage of the requests served within a certain time (ms)
50% 155
66% 178
75% 193
80% 204
90% 235
95% 258
98% 285
99% 302
100% 2452 (longest request)

eAccelerator加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 95.983986 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 31.26 [#/sec] (mean)
Time per request: 159.973 [ms] (mean)
Time per request: 31.995 [ms] (mean, across all concurrent requests)
Transfer rate: 679.39 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 3
Processing: 57 159 91.3 148 3830
Waiting: 50 152 89.8 142 3704
Total: 57 159 91.3 148 3830
Percentage of the requests served within a certain time (ms)
50% 148
66% 174
75% 193
80% 205
90% 239
95% 263
98% 289
99% 309
100% 3830 (longest request)

XCache加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 99.76300 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 30.28 [#/sec] (mean)
Time per request: 165.127 [ms] (mean)
Time per request: 33.025 [ms] (mean, across all concurrent requests)
Transfer rate: 658.19 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 59 164 83.4 155 3367
Waiting: 52 156 66.4 148 1802
Total: 59 164 83.4 155 3367
Percentage of the requests served within a certain time (ms)
50% 155
66% 178
75% 196
80% 206
90% 237
95% 263
98% 287
99% 305
100% 3367 (longest request)

3、结果摘要

  请求时间(秒) 单次请求时间(毫秒) 最大内存占用(MB) 最小内存占用(MB)
None 10.41 96.08 24 24
APC 30.45 32.84 21 21
eAccelerator 31.26 31.99 23 18
XCache 30.28 33.02 29 19

4. Summary of PHP accelerator comparison results

1. Through testing, it is concluded that eAccelerator is the best in terms of request time and memory usage.

2. Through testing, it is concluded that the request time is about 3 times faster using the accelerator than without the accelerator.

3. According to various official observations, XCache is the fastest updated, which also shows that it has the most development.

The above is the summary result. You may ask me which accelerator is better? I can only tell you that first of all, it is better to use it than not to use it. Secondly, each accelerator has some parameters that can be tuned, so it depends on your system environment. Then, I personally think you can study eAccelerator and XCache in detail. , these two models still have great potential. Finally, I made a result picture from a more professional testing website:

About PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial

Original link address: http://www.vpser.net/opt/apc-eaccelerator-xAbout PHP acceleration eAccelerator, Xcache, APC and Zend Optimizer, eacceleratorxcache_PHP tutorial.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/944874.htmlTechArticleAbout PHP acceleration eAccelerator, This is what the book teaches, but when you meet a strange company...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software