53、PHP启用xcache加速

资源限定

软限制:可以超出的限制,但仅能超出一定时长

硬限制:绝对不能超出的限制

ulimit:只能修改软限制

   -n [N]:显示或限制能打开的最大的文件句柄数,

   -u [N]:所能够打开的最大进程数

如果修改硬限制

/etc/security/limits.conf,扩展配置etc/security/limits.d/*.conf

对谁进行限定    类型  要限定的选项 值

apache hard nofile65535

apache hard nproc30000


ab工具的初步使用

-c 模拟的并发数

-n 模拟的总请求数

一般并发数应该小于等于请求数   

ulimit -n 3000

ab -c 100 -n 10000 http://192.168.130.65/pma/index.php


启动加速前

[root@localhost ~]# ab -c 10 -n 1000 http://192.168.130.65/pma/index.php  

This is ApacheBench, Version 2.3 <$Revision: 1843412 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking 192.168.130.65 (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.4.37

Server Hostname:        192.168.130.65

Server Port:            80


Document Path:          /pma/index.php

Document Length:        14323 bytes


Concurrency Level:      10

Time taken for tests:   19.420 seconds

Complete requests:      1000

Failed requests:        947

   (Connect: 0, Receive: 0, Length: 947, Exceptions: 0)

Total transferred:      15841640 bytes

HTML transferred:       14321640 bytes

Requests per second:    51.49 [#/sec] (mean)

Time per request:       194.201 [ms] (mean)

Time per request:       19.420 [ms] (mean, across all concurrent requests)

Transfer rate:          796.62 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.2      0       7

Processing:   105  192  93.3    153     786

Waiting:       98  185  92.7    145     778

Total:        105  192  93.3    153     786


Percentage of the requests served within a certain time (ms)

  50%    153

  66%    193

  75%    227

  80%    262

  90%    337

  95%    373

  98%    437

  99%    522

 100%    786 (longest request)

[root@localhost ~]# 


1、安装

tar xf xcache-3.2.0.tar.gz 

cd xcache-3.2.0

/usr/local/php/bin/phpize

./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

make && make install


安装结束时,会出现类似如下行:

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20131226/


2、编辑php.ini,整合php和xcache:

mkdir /etc/php.d

cp xcache.ini /etc/php.d

vim /etc/php.d/xcache.ini

extension = /usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so



启动加速后

[root@localhost xcache-3.2.0]# ab -c 10 -n 1000 http://192.168.130.65/pma/index.php  

This is ApacheBench, Version 2.3 <$Revision: 1843412 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking 192.168.130.65 (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.4.37

Server Hostname:        192.168.130.65

Server Port:            80


Document Path:          /pma/index.php

Document Length:        14322 bytes


Concurrency Level:      10

Time taken for tests:   6.322 seconds

Complete requests:      1000

Failed requests:        871

   (Connect: 0, Receive: 0, Length: 871, Exceptions: 0)

Total transferred:      15842084 bytes

HTML transferred:       14322084 bytes

Requests per second:    158.17 [#/sec] (mean)

Time per request:       63.225 [ms] (mean)

Time per request:       6.322 [ms] (mean, across all concurrent requests)

Transfer rate:          2446.95 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.1      0       0

Processing:    36   63  55.1     50     670

Waiting:       34   60  54.8     47     670

Total:         36   63  55.1     50     670


Percentage of the requests served within a certain time (ms)

  50%     50

  66%     56

  75%     62

  80%     65

  90%     78

  95%     98

  98%    229

  99%    426

 100%    670 (longest request)

[root@localhost xcache-3.2.0]# 




猜你喜欢

转载自blog.51cto.com/kaiyuandiantang/2326446
今日推荐