php apc install(ubuntu)

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.
大的网站都用它

sudo apt-get install apache2-threaded-dev php5-dev php-pear make
sudo ln -s /usr/bin/apxs2 /usr/bin/apxs
sudo pecl install apc
回答:YES

sudo vi /etc/php5/apache2/php.ini
增加:extension=apc.so
sudo vi /usr/share/php/pearcmd.php
增加:@ini_set('memory_limit', '16M');

测试

使用APC
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Finished 300 requests


Server Software: Apache/2.2.8
Server Hostname: localhost
Server Port: 80

Document Path: /PHPUnit/src/test/runall_test.php
Document Length: 3935 bytes

Concurrency Level: 1
Time taken for tests: 23.418973 seconds
Complete requests: 300
Failed requests: 0
Write errors: 0
Total transferred: 1335000 bytes
HTML transferred: 1180500 bytes
Requests per second: 12.81 [#/sec] (mean)
Time per request: 78.063 [ms] (mean)
Time per request: 78.063 [ms] (mean, across all concurrent requests)
Transfer rate: 55.64 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 67 77 14.7 73 250
Waiting: 2 2 3.7 2 60
Total: 67 77 14.7 73 250

Percentage of the requests served within a certain time (ms)
50% 73
66% 76
75% 83
80% 85
90% 88
95% 91
98% 103
99% 129
100% 250 (longest request)

不使用APC
enchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Finished 300 requests


Server Software: Apache/2.2.8
Server Hostname: localhost
Server Port: 80

Document Path: /PHPUnit/src/test/runall_test.php
Document Length: 3935 bytes

Concurrency Level: 1
Time taken for tests: 51.773192 seconds
Complete requests: 300
Failed requests: 0
Write errors: 0
Total transferred: 1335000 bytes
HTML transferred: 1180500 bytes
Requests per second: 5.79 [#/sec] (mean)
Time per request: 172.577 [ms] (mean)
Time per request: 172.577 [ms] (mean, across all concurrent requests)
Transfer rate: 25.17 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 156 172 21.7 163 367
Waiting: 15 20 3.6 20 48
Total: 156 172 21.7 163 367

Percentage of the requests served within a certain time (ms)
50% 163
66% 166
75% 177
80% 193
90% 196
95% 204
98% 216
99% 283
100% 367 (longest request)


时间消耗几乎相差一倍。
注意,如果是用phpinfo()类的简单函数,测试效果将非常不明显。

使用系统默认的apc.php查看cache情况,可以把apc.php cp到你的web目录。我机器上该文件默认目录是:
/usr/share/php
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值