设为首页 收藏本站
查看: 796|回复: 0

[经验分享] RedHat Enterprise 6.5环境下使用eAccelerator优化网站性能

[复制链接]

尚未签到

发表于 2018-5-11 08:51:38 | 显示全部楼层 |阅读模式
RedHat Enterprise 6.5环境下使用eAccelerator优化网站性能

  第一步:在做优化之前,首先对网站服务器的硬件做一下检测
  1,内存信息:2G内存,swap容量为4G
[root@linuxcast ~]# free -m

  total       used       free     shared    buffers     cached
  Mem:          1870       1228        642          0         47        435
  -/+ buffers/cache:        744       1125
  Swap:         4095          0       4095
  

  2,cpu信息,也可以通过cat /proc/cpuinfo查看
[root@linuxcast ~]# lscpu

  Architecture:          x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Byte Order:            Little Endian
  CPU(s):                1
  On-line CPU(s) list:   0
  Thread(s) per core:    1
  Core(s) per socket:    1
  Socket(s):             1
  NUMA node(s):          1
  Vendor ID:             GenuineIntel
  CPU family:            6
  Model:                 58
  Stepping:              9
  CPU MHz:               3569.819
  BogoMIPS:              7139.63
  Hypervisor vendor:     VMware
  Virtualization type:   full
  L1d cache:             32K
  L1i cache:             32K
  L2 cache:              256K
  L3 cache:              8192K
  NUMA node0 CPU(s):     0
[root@linuxcast ~]#

  

  3,查看磁盘的续写性能:读取速度为:2544MB,吸入速度为847MB
[root@linuxcast ~]# hdparm -t /dev/sda

  

  /dev/sda:
  Timing buffered disk reads: 2544 MB in  3.00 seconds = 847.63 MB/sec
[root@linuxcast ~]#

  

  4,对网站首页进行压力测试:ab命令
  对指定网页进行10次并发,1000次请求进行压力测试:返回的结果是10.13
  也就是说一天24小时可以承受的请求数量为:10*60*60*24=86400
  

[root@linuxcast ~]# ab -c 10 -n 1000 http://www.linuxcast.net/index.php

  This is ApacheBench, Version 2.3 <$Revision: 655654 $>
  Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  Licensed to The Apache Software Foundation, http://www.apache.org/
  

  Benchmarking www.linuxcast.net (be patient)
  Completed 100 requests
  Completed 200 requests
  Completed 300 requests
  Completed 400 requests
  Completed 500 requests
  Completed 600 requests
  Completed 700 requests
  Completed 800 requests
  Completed 900 requests
  Completed 1000 requests
  Finished 1000 requests
  

  

  Server Software:        Apache/2.2.15
  Server Hostname:        www.linuxcast.net
  Server Port:            80
  

  Document Path:          /index.php
  Document Length:        0 bytes
  

  Concurrency Level:      10
  Time taken for tests:   98.761 seconds
  Complete requests:      1000
  Failed requests:        0
  Write errors:           0
  Non-2xx responses:      1000
  Total transferred:      293000 bytes
  HTML transferred:       0 bytes
  Requests per second:    9.23 [#/sec] (mean)
  Time per request:       987.614 [ms] (mean)
  Time per request:       98.761 [ms] (mean, across all concurrent requests)
  Transfer rate:          2.90 [Kbytes/sec] received
  

  Connection Times (ms)
  min  mean[+/-sd] median   max
  Connect:        0    0   2.0      0      32
  Processing:   355  986  49.7    985    1625
  Waiting:      355  983  48.8    982    1605
  Total:        355  986  49.7    985    1625
  

  Percentage of the requests served within a certain time (ms)
  50%    985
  66%    997
  75%   1004
  80%   1010
  90%   1032
  95%   1050
  98%   1076
  99%   1097
  100%   1625 (longest request)
[root@linuxcast ~]#

  

  第二步:安装eAccelerator,提升网站性能
  1,安装Development Tool工具
  yum groupinstall -y "Development Tools"
  2,安装php-devel
  注:可以在pkgs.org上下载相关的版本(必须和php版本相同)
[root@linuxcast ~]# rpm -qa | grep php

  php-pdo-5.3.3-26.el6.x86_64
  php-gd-5.3.3-26.el6.x86_64
  php-5.3.3-26.el6.x86_64
  php-common-5.3.3-26.el6.x86_64
  php-devel-5.3.3-26.el6.x86_64
  php-mysql-5.3.3-26.el6.x86_64
  php-xml-5.3.3-26.el6.x86_64
  php-cli-5.3.3-26.el6.x86_64
  php-pear-1.9.4-4.el6.noarch
[root@linuxcast ~]# cd

[root@linuxcast ~]# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/php-devel-5.3.3-26.el6.x86_64.rpm

  --2014-08-08 14:11:48--  http://mirror.centos.org/centos/6/os/x86_64/Packages/php-devel-5.3.3-26.el6.x86_64.rpm
[root@linuxcast ~]# rpm -ivh php-devel-5.3.3-26.el6.x86_64.rpm

  3,下载并安装eAccelerator

[root@linuxcast ~]# cd /usr/local/

  

  下载eAccelerator并命名为master.zip:
[root@linuxcast local]# wget https://github.com/eaccelerator/eaccelerator/zipball/master -O master.zip

[root@linuxcast local]# unzip master.zip

  

  重命名解压缩出来的文件夹为eAccelerator:
[root@linuxcast local]# mv eaccelerator-eaccelerator-42067ac/ eaccelerator

[root@linuxcast local]# cd eaccelerator/

[root@linuxcast eaccelerator]# ls

  AUTHORS       config.w32   debug.c         eaccelerator.h          ea_dasm.h    ea_restore.h  fnmatch.h      mm.h       optimize.c         win32
  bugreport.php control.php  debug.h         eaccelerator.ini        ea_info.c     ea_store.c    Makefile.frag  NEWS       PHP_Highlight.php
  ChangeLog      COPYING      doc             eaccelerator_version.h  ea_info.h     ea_store.h    Makefile.in    opcodes.c  README
  config.m4     dasm.php     eaccelerator.c  ea_dasm.c               ea_restore.c  fnmatch.c     mm.c           opcodes.h  README.win32
[root@linuxcast eaccelerator]# ls configure

  ls: cannot access configure: No such file or directory
  

  在eAccelerator目录中执行phpize命令,生成configure文件:
[root@linuxcast eaccelerator]# phpize

  Configuring for:
  PHP Api Version:         20090626
  Zend Module Api No:      20090626
  Zend Extension Api No:   220090626
[root@linuxcast eaccelerator]# ls configure

  configure
  

  安装eAccelerator:
[root@linuxcast eaccelerator]# ./configure

[root@linuxcast eaccelerator]# make && make install

  

  第三步:编辑eAccelerator的配置文件:
  在/etc/php.d目录下创建eacceleractor.ini
  内容参照:https://github.com/eaccelerator/eaccelerator网页上的
  To install as PHP extension:

  eAccelerator.ini文件内容:
  extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
  eaccelerator.shm_only="0"

  

  创建eAccelerator虚拟目录:
  mkdir /tmp/eaccelerator
  

  设置eAccelerator目录的权限:
chmod 0777 /tmp/eaccelerator

  

  注:配置完成之后需要重新启动httpd服务
  service httpd restart
  

  第四步:安装好eAccelerator之后,再次对网站首页进行压力测试:
  测试结果:
[root@linuxcast php.d]# ab -c 10 -n 1000 http://www.linuxcast.net/index.php

  This is ApacheBench, Version 2.3 <$Revision: 655654 $>
  Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  Licensed to The Apache Software Foundation, http://www.apache.org/
  

  Benchmarking www.linuxcast.net (be patient)
  Completed 100 requests
  Completed 200 requests
  Completed 300 requests
  Completed 400 requests
  Completed 500 requests
  Completed 600 requests
  Completed 700 requests
  Completed 800 requests
  Completed 900 requests
  Completed 1000 requests
  Finished 1000 requests
  

  

  Server Software:        Apache/2.2.15
  Server Hostname:        www.linuxcast.net
  Server Port:            80
  

  Document Path:          /index.php
  Document Length:        0 bytes
  

  Concurrency Level:      10
  Time taken for tests:   41.735 seconds
  Complete requests:      1000
  Failed requests:        0
  Write errors:           0
  Non-2xx responses:      1000
  Total transferred:      293000 bytes
  HTML transferred:       0 bytes
  Requests per second:    23.96 [#/sec] (mean)
  Time per request:       417.353 [ms] (mean)
  Time per request:       41.735 [ms] (mean, across all concurrent requests)
  Transfer rate:          6.86 [Kbytes/sec] received
  

  Connection Times (ms)
  min  mean[+/-sd] median   max
  Connect:        0    0   0.6      0      10
  Processing:   179  417  21.9    416     480
  Waiting:      178  415  21.7    415     480
  Total:        179  417  21.9    416     480
  

  Percentage of the requests served within a certain time (ms)
  50%    416
  66%    423
  75%    429
  80%    432
  90%    440
  95%    450
  98%    461
  99%    466
  100%    480 (longest request)
[root@linuxcast php.d]#

  

  可以看到优化后的返回结果为:Requests per second:    23.96 [#/sec] (mean)
  也就是说,是优化之前的三倍。
  

  php的加速器除了eAccelerator之外还有xcache、APC(Alternative PHP Cache)等...
  

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-458415-1-1.html 上篇帖子: redhat6.4使用163的Centosyum源 下篇帖子: redhat Linux 5.0 如何识别网卡和安装驱动
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表