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

随着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
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
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

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

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor