RedHat Enterprise 6.5 environment using Eaccelerator to optimize website performance
The first step: Before the optimization, first of the Web server hardware to do a test
1, Memory information: 2G memory, swap capacity 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 information can also be viewed through 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, check the disk's resume performance: Read speed: 2544MB, suction speed of 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, stress test on the homepage of the website: AB command
10 concurrent, 1000 requests for stress tests on the specified Web page: The returned result is 10.13
That means 24 hours a day. The number of requests that can be sustained is: 10*60*60*24=86400
[Email protected] ~]# ab-c 10-n 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 requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Finished 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] ~]#
Step Two: Install Eaccelerator to improve website performance
1, Install development tool tools
Yum groupinstall-y "Development Tools"
2, install Php-devel
Note: You can download the relevant version on pkgs.org (must be the same as the PHP version)
[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. Download and install Eaccelerator
[Email protected] ~]# cd/usr/local/
Download the eaccelerator and name it master.zip:
[Email protected] local]# wget Https://github.com/eaccelerator/eaccelerator/zipball/master-O master.zip
[Email protected] local]# Unzip Master.zip
Rename the extracted folder to 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
Execute the phpize command in the Eaccelerator directory to generate the Configure file:
[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
Install Eaccelerator:
[Email protected] eaccelerator]#./configure
[[email protected] eaccelerator]# make && make install
Step three: Edit the eaccelerator configuration file:
Create Eacceleractor.ini under the/ETC/PHP.D directory
Content reference: Https://github.com/eaccelerator/eaccelerator on the Web page
To install as PHP extension:
Eaccelerator.ini File Contents:
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"
To create a eaccelerator virtual directory:
Mkdir/tmp/eaccelerator
To set permissions for the Eaccelerator directory:
chmod 0777/tmp/eaccelerator
Note: The HTTPD service needs to be restarted after the configuration is complete
Service httpd Restart
Fourth step: After the installation of Eaccelerator, once again on the site first stress test:
Test results:
[Email protected] php.d]# ab-c 10-n 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 requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Finished 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]#
You can see that the optimized return result is:requests per second:23.96 [#/sec] (mean)
That is, three times times before the optimization.
PHP Accelerator In addition to Eaccelerator also have XCache, APC (alternative php Cache) and so on ...