APC入れてみた

2013.05.09

最近、会社のサーバのレスポンスに不満が出ていて

どうしたものかと考えたところ

まだAPCを入れていないことに気がついた。

 

早速インストールしてみた。

 

 

[root@www homepage]# pecl install APC
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading APC-3.1.13.tgz ...
Starting to download APC-3.1.13.tgz (171,591 bytes)
.............................done: 171,591 bytes
55 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
Enable internal debugging in APC [no] :
Enable per request file info about files used from the APC cache [no] :
Enable spin locks (EXPERIMENTAL) [no] :
Enable memory protection (EXPERIMENTAL) [no] :
Enable pthread mutexes (default) [no] :
Enable pthread read/write locks (EXPERIMENTAL) [yes] :
building in /var/tmp/pear-build-homepagebLL5yA/APC-3.1.13
running: /var/tmp/APC/configure --enable-apc-debug=no --enable-apc-filehits=no --enable-apc-spinlocks=no --enable-apc-memprotect=no --enable-apc-pthreadmutex=no --enable-apc-pthreadrwlocks=yes
 

[root@www]#vi /etc/php.d/apc.ini

 

extension=apc.so
[apc]
apc.enabled = 1
apc.shm_size = 64M
apc.ttl = 1800
apc.user_ttl = 1800
apc.gc_ttl = 1800
apc.rfc1867 = 1 ←Drupalのアップロード進捗状況

 

[root@www]# vi /etc/php.ini

extension=apc.so

を追加

 

[root@www]# /etc/rc.d/init.d/httpd restart
apache再起動
 
[root@www]# ab -n 100 -c 10 http://127.0.0.1/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
 
Benchmarking 127.0.0.1 (be patient).....done
 
Server Software:        Apache/2.2.3
Server Hostname:        127.0.0.1
Server Port:            80
 
Document Path:          /
Document Length:        45374 bytes
 
Concurrency Level:      10
Time taken for tests:   6.866161 seconds
Complete requests:      100
Failed requests:        98
   (Connect: 0, Length: 98, Exceptions: 0)
Write errors:           0
Total transferred:      4571734 bytes
HTML transferred:       4539734 bytes
Requests per second:    14.56 [#/sec] (mean)
Time per request:       686.616 [ms] (mean)
Time per request:       68.662 [ms] (mean, across all concurrent requests)
Transfer rate:          650.14 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   362  671 262.7    575    1364
Waiting:       64  134 100.2     97     456
Total:        362  671 262.7    575    1364
 
Percentage of the requests served within a certain time (ms)
  50%    575
  66%    615
  75%    641
  80%    885
  90%   1309
  95%   1353
  98%   1363
  99%   1364
 100%   1364 (longest request)

 

APC無効の場合

 

[root@www]# ab -n 100 -c 10 http://127.0.0.1/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
 
Benchmarking 127.0.0.1 (be patient).....done
 
 
Server Software:        Apache/2.2.3
Server Hostname:        127.0.0.1
Server Port:            80
 
Document Path:          /
Document Length:        45382 bytes
 
Concurrency Level:      10
Time taken for tests:   17.770440 seconds
Complete requests:      100
Failed requests:        96
   (Connect: 0, Length: 96, Exceptions: 0)
Write errors:           0
Total transferred:      4572736 bytes
HTML transferred:       4540736 bytes
Requests per second:    5.63 [#/sec] (mean)
Time per request:       1777.044 [ms] (mean)
Time per request:       177.704 [ms] (mean, across all concurrent requests)
Transfer rate:          251.26 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  1026 1744 560.6   1564    3491
Waiting:      132  376 282.2    275    1809
Total:       1026 1744 560.6   1564    3491
 
Percentage of the requests served within a certain time (ms)
  50%   1564
  66%   1782
  75%   1895
  80%   2008
  90%   2895
  95%   3118
  98%   3475
  99%   3491
 100%   3491 (longest request)
 
随分速くなったもんだ。