网站服务器部署及优化---3---使用eAccelerator提升网站服务器的性能(rhel6.5)

RedHat Enterprise 6.5环境下使用eAccelerator优化网站性能

第一步:在做优化之前,首先对网站服务器的硬件做一下检测

1,内存信息:2G内存,swap容量为4G

[[email protected] ~]# 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查看

[[email protected] ~]# 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

[[email protected] ~]#

3,查看磁盘的续写性能:读取速度为:2544MB,吸入速度为847MB

[[email protected] ~]# hdparm -t /dev/sda

/dev/sda:

Timing buffered disk reads: 2544 MB in  3.00 seconds = 847.63 MB/sec

[[email protected] ~]#

4,对网站首页进行压力测试:ab命令

对指定网页进行10次并发,1000次请求进行压力测试:返回的结果是10.13

也就是说一天24小时可以承受的请求数量为:10*60*60*24=86400

[[email protected] ~]# 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)

[[email protected] ~]#

第二步:安装eAccelerator,提升网站性能

1,安装Development Tool工具

yum groupinstall -y "Development Tools"

2,安装php-devel

注:可以在pkgs.org上下载相关的版本(必须和php版本相同)

[[email protected] ~]# 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

[[email protected] ~]# cd

[[email protected] ~]# 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

[[email protected] ~]# rpm -ivh php-devel-5.3.3-26.el6.x86_64.rpm

3,下载并安装eAccelerator

[[email protected] ~]# cd /usr/local/

下载eAccelerator并命名为master.zip:

[[email protected] local]# wget https://github.com/eaccelerator/eaccelerator/zipball/master -O master.zip

[[email protected] local]# unzip master.zip

重命名解压缩出来的文件夹为eAccelerator:

[[email protected] local]# mv eaccelerator-eaccelerator-42067ac/ eaccelerator

[[email protected] local]# cd eaccelerator/

[[email protected] 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

[[email protected] eaccelerator]# ls configure

ls: cannot access configure: No such file or directory

在eAccelerator目录中执行phpize命令,生成configure文件:

[[email protected] eaccelerator]# phpize

Configuring for:

PHP Api Version:         20090626

Zend Module Api No:      20090626

Zend Extension Api No:   220090626

[[email protected] eaccelerator]# ls configure

configure

安装eAccelerator:

[[email protected] eaccelerator]# ./configure

[[email protected] 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之后,再次对网站首页进行压力测试:

测试结果:

[[email protected] 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)

[[email protected] php.d]#

可以看到优化后的返回结果为:Requests per second:    23.96 [#/sec] (mean)

也就是说,是优化之前的三倍。

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

网站服务器部署及优化---3---使用eAccelerator提升网站服务器的性能(rhel6.5)

时间: 2024-08-02 06:54:24

网站服务器部署及优化---3---使用eAccelerator提升网站服务器的性能(rhel6.5)的相关文章

网站服务器部署及优化---1---LAMP环境搭建(rhel6.5)

RedHat Enterprise 6.5 第一步:安装apache yum install -y httpd      安装相应软件包(前提是需要搭好yum源) service httpd start    启动apache服务 默认配置文件为:/etc/httpd/conf/httpd.conf 模块配置文件存放目录:/etc/httpd/conf.d 注:Apache可以通过扩展模块来扩充自己的功能,通常一个模块对应一个文件在/etc/httpd/conf.d目录下 /etc/httpd/

网站服务器部署及优化---2---部署wordpress网站(rhel6.5)

RedHat Enterprise 6.5环境下wordpress网站部署 第一步:下载wordpress网站压缩包并解压 [[email protected] data]# wget http://cn.wordpress.org/wordpress-3.9-zh_CN.zip -O wordpress.zip [[email protected] data]# unzip wordpress.zip [[email protected] data]# mkdir /var/www/html/

如何在linux服务器部署Rstudio server,配置ODBC远程访问win 服务器上的SQL server

如何在linux服务器部署Rstudio server,配置ODBC后通过RODBC包远程访问SQL server 背景介绍:之前写过一篇文章,提到近期要部署Rstudio server(搭建数据分析团队的分析环境),花了一个星期,搭好了.还YY过给这个亲生的儿子起个装逼的名字呢,莫扎特,巴赫什么的,并YY出以下场景{Jenny ,你把模型扔到莫扎特上跑一版最新结果出来...啊哈是不是特有逼格..哦哈哈...}我是部署的Rstudio server,这个是免费的,但是Rstudio sererv

Lync2013OWA服务器部署(五)

LYNC2013 - Office Web Apps Server 2013服务器部署 作者:牛志会 在lync服务器上OWA所要实现的功能: 为帮助解决这些问题并改善演示或观看 PowerPoint 演示文稿的用户的总体体验,Lync Server 2013 使用 Office Web Apps Server 来处理 PowerPoint 演示文稿.除其他优点外,此新方法还允许以下功能: 更高分辨率显示以及对 PowerPoint 功能(例如动画.幻灯片切换和嵌入视频)更好的支持. 更多移动设

Linux运维---DHCP服务器部署

DHCP协议 DHCP(Dynamips Host configuration Protocal)动态主机配置协议是一种基于UDP协议且仅限于在局域网内部使用的网络协议,主要用于大型的局域网环境或者存在较多移动办公设备的局域网环境中,其主要用途是用于自动管理局域网内主机的IP地址.子网掩码.网关地址及DNS地址等参数,可以有效地提升IP地址的利用率,提高配置效率,并降低管理与维护成本. 在DHCP的工作原理中,DHCP服务器提供了三种IP分配方式:自动分配.手动分配和动态分配. 自动分配是当DH

基于python的种子搜索网站-项目部署

本讲会对种子搜索网站的部署过程进行详细的讲解. 网站演示: https://bt.mypython.me 源码地址: https://github.com/geeeeeeeek/bt 项目部署过程 系统要求:ubuntu 16.04(或以上) 环境搭建和配置,必须严格按照以下步骤来安装部署!如有问题可以咨询(微信:java2048) 安装部分 安装nginx sudo apt install nginx 安装python3和pip3 sudo apt install python3sudo ap

Nginx&mdash;&mdash;使用 Nginx 提升网站访问速度【转载+整理】

原文地址 本文是写于 2008 年,文中提到 Nginx 不支持 Windows 操作系统,但是现在它已经支持了,此外还支持 FreeBSD,Solaris,MacOS X~ Nginx("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 服务器. Nginx 是由俄罗斯人 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru(俄文:Рамблер)站点开发的,第一个公开版本 0.1.0 发布于2004年10月4日.

vue-小爱ADMIN系列文章(二):微信微博等分享,国际化,前端性能优化,nginx服务器部署

最近在做我的小爱ADMIN后台管理系统,结合当前市场后台管理系统对相关功能的需求,我又开始新增了一些新的功能和组件,如分享功能组件,项目国际化功能:项目完成后,部署在nginx服务器,发现首次访问的速度特别慢,严重的影响了用户体验,因此,我又开始进行了一系列的前端性能优化;以及将优化后的项目部署到nginx服务器二级子目录的注意细节. 效果演示地址 github地址 分享功能 背景说明 用微信,微博等做网站的第三方登录及用微信和支付宝进行支付,都需要注册开发者账号和添加网站应用,比较麻烦.另外,

高性能网站服务器的架设优化

一:对于高性能网站 ,请求量大,如何支撑?思路 1,要减少请求 对于开发人员----合并css, 背景图片, 减少mysql查询等. 2: 对于运维 nginx的expires ,利用浏览器缓存.jpg.png.css等,减少查询. 3: 利用cdn来响应请求 4: 最终剩下的,不可避免的请求----服务器集群+负载均衡来支撑. 所以,来到第4步后,就不要再考虑减少请求这个方向了,根据业务需求来选择服务器,是IO大点的选择更好的磁盘.而是思考如何更好的响应高并发请,既然响应是不可避免的,我们要做