Home php教程 php手册 php缓冲器:eaccelerator与xcache性能测试对比

php缓冲器:eaccelerator与xcache性能测试对比

Jun 06, 2016 pm 07:54 PM
eaccelerator php xcache performance

随着PHP流行,PHP的执行效率也越来越被大家关注,可以选择的缓存器也是越来越多,从老的php-memcache到eaccelerator还有新兴的xcache。为了挑选一个合适的缓存器决定自己实测一下,看看哪个缓存器的效率更高,由于php-memcache很少有人用了现在只测试eaccele

随着PHP流行,PHP的执行效率也越来越被大家关注,可以选择的缓存器也是越来越多,从老的php-memcache到eaccelerator还有新兴的xcache。为了挑选一个合适的缓存器决定自己实测一下,看看哪个缓存器的效率更高,由于php-memcache很少有人用了现在只测试eaccelerator和xcache。 硬件配置: CPU:Intel 2140(双核心) 内存:2G DDR667 硬盘:80G(IDE接口,2M缓存)

软件版本 系统:Mandriva 2008 free,apache-2.2.6,php-5.2.4,ZendOptimizer-3.3.0,mysql-5.0.45。 测试对象的版本:eaccelerator-0.9.5.2,xcache-1.2.1

eaccelerator与xcache都是手动编译安装,安装安装官方公布的安装步骤和参数,需要了解的可以登录他们的网站去看。考虑到对商业代码的支持,缓存器都安装为zend的扩展,同时两个缓存器的缓存大小都是64M(呵呵有点大一般16M就不小了)。测试的时候关于eaccelerator会测试两项,一项是默认的,一项是把eaccelerator的缓存目录放到tmpfs中,我叫他为eaccelerator的内存模式。关于tmpfs的情况可以看下这里http://lcuc.org.cn/node/304。

测试工具为ab,测试读取对象是phpMyAdmin-2.11.2,Discuz!_6.0.0_SC_GBK

phpMyAdmin部分

测试语句为:ab -n 100000 http://localhost/phpmyadmin

不安装任何缓存器

[root@mandriva phpmyadmin]# ab -n 100000 http://localhost/phpmyadmin This is ApacheBench, Version 2.0.40-dev apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient) Completed 10000 requests Completed 20000 requests Completed 30000 requests Completed 40000 requests Completed 50000 requests Completed 60000 requests Completed 70000 requests Completed 80000 requests Completed 90000 requests Finished 100000 requests

Server Software: Apache/2.2.6 Server Hostname: localhost Server Port: 80

Document Path: /phpmyadmin Document Length: 337 bytes

Concurrency Level: 1 Time taken for tests: 20.699322 seconds Complete requests: 100000 Failed requests: 0 Write errors: 0 Non-2xx responses: 100000 Total transferred: 59100000 bytes HTML transferred: 33700000 bytes Requests per second: 4831.08 [#/sec] (mean) Time per request: 0.207 [ms] (mean) Time per request: 0.207 [ms] (mean, across all concurrent requests) Transfer rate: 2788.21 [Kbytes/sec] received

Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 0 0 1.2 0 294 Waiting: 0 0 1.2 0 294 Total: 0 0 1.2 0 294

Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 0 80% 0 90% 0 95% 0 98% 0 99% 0 100% 294 (longest request) 主要的性能指标是Requests per second,为了看着方便,只在第一次的给出所有反馈,其他的都之提供Requests per second

结果:Requests per second: 4831.08 [#/sec] (mean)

eAccelerator 结果:Requests per second: 4850.92 [#/sec] (mean)

eAccelerator 内存模式 结果:Requests per second: 4690.77 [#/sec] (mean)

xcache 结果:Requests per second: 4781.96 [#/sec] (mean)

发现eAccelerator与xcache可以同时安装,就也试验了一下。 eAccelerator+xcache 结果:Requests per second: 4791.29 [#/sec] (mean)

测试的结果是eAccelerator 内存模式胜出。不过这样似乎看不出缓存器的必要,同时phpMyAdmin也太单一了。下面开始对Discuz!_6.0.0_SC_GBK的请求测试,这样对国内的用户才更加有参考意义。

Discuz!部分 说明:Discuz!默认安装,不带任何的数据,Discuz!自带了缓存功能不过默认没有开启,不影响测试的结果。

测试语句为:ab -n 100000 http://localhost/bbs/index.php 针对Discuz!测试又增加了一句:ab -n 100000 -c 200 http://localhost/bbs/index.php 超BT^_^

ab -n 100000

不安装任何缓存器

[root@mandriva bbs]# ab -n 100000 http://localhost/bbs/index.php This is ApacheBench, Version 2.0.40-dev apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient) Completed 10000 requests Completed 20000 requests Completed 30000 requests Completed 40000 requests Completed 50000 requests Completed 60000 requests Completed 70000 requests Completed 80000 requests Completed 90000 requests Finished 100000 requests

Server Software: Apache/2.2.6 Server Hostname: localhost Server Port: 80

Document Path: /bbs/index.php Document Length: 9251 bytes

Concurrency Level: 1 Time taken for tests: 2278.10424 seconds Complete requests: 100000 Failed requests: 0 Write errors: 0 Total transferred: 958900000 bytes HTML transferred: 925100000 bytes Requests per second: 43.90 [#/sec] (mean) Time per request: 22.780 [ms] (mean) Time per request: 22.780 [ms] (mean, across all concurrent requests) Transfer rate: 411.07 [Kbytes/sec] received

Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 21 22 0.9 22 137 Waiting: 14 21 0.6 21 40 Total: 21 22 0.9 22 137

Percentage of the requests served within a certain time (ms) 50% 22 66% 22 75% 22 80% 23 90% 23 95% 23 98% 24 99% 24 100% 137 (longest request)

结果:Requests per second: 43.90 [#/sec] (mean)

eAccelerator 结果:Requests per second: 167.28 [#/sec] (mean)

eAccelerator 内存模式 结果:Requests per second: 168.53 [#/sec] (mean)

xcache 结果:Requests per second: 191.68 [#/sec] (mean)

ab -n 100000 -c 200

不安装任何缓存器 结果:Requests per second: 77.73 [#/sec] (mean)

eAccelerator 结果:Requests per second: 317.69 [#/sec] (mean)

eAccelerator 内存模式 结果:Requests per second: 325.86 [#/sec] (mean)

xcache 结果:Requests per second: 388.76 [#/sec] (mean)

这时候结果已经很明显了xcache胜出,各项的差距也拉大了。

结果:xcache的性能相当的不错,可以取代eAccelerator。eAccelerator的内存模式对eAccelerator的性能提升不是很大,用了反而会增加系统配置的复杂度。

同时要注意的是mysql的性能,在进行Discuz!部分测试的时候CPU占用率几乎是100%。在没有安装任何缓存器的时mysql的占用率只有10%左右,其他的都被apache占去。安装任何一款缓冲器时,单线程mysql的占用率35%左右,多线程的时候是40%左右,其他的都被apache占去。这样看来缓存器在php应用中是非常重要的,一个缓存器可以大大减轻apache的负担,所以建议所有的php用户都安装一个缓存器。

后记:这次的测试用的参数有点BT了^_^,不过我们就是想得到一个近似合理的测试结果,时间长一点也不过分。

Statement of this Website
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

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

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles