2013/04/26 @shin1x1
6th Kansai PHP Study
PHP5.5
Zend OPcache
@shin1x1
(c) 2013 Masashi Shinbara @shin1x1
http://www.1x1.jp/blog/
https://github.com/shin1x1
PHP / DevOps / AWS /
Varnish / Fabric / Chef
Agenda
(c) 2013 Masashi Shinbara @shin1x1
1. PHP5.5 beta4 install
2. Zend OPcache
3. Benchmark
4. Data Cache
PHP5.5 beta4 install
(c) 2013 Masashi Shinbara @shin1x1
PHP5.5 beta4 install
(c) 2013 Masashi Shinbara @shin1x1
# for RHEL6 / CentOS6
$ sudo yum install httpd-devel libxml2-
devel
# for extract .xz file
$ sudo yum insall xz
PHP5.5 beta4 install
(c) 2013 Masashi Shinbara @shin1x1
$ curl -OL http://downloads.php.net/dsp/
php-5.5.0beta4.tar.xz
$ tar xvf php-5.5.0beta4.tar.xz
$ cd php-5.5.0beta4
$ ./configure --enable-mbstring --with-
apxs2
$ make
$ sudo make install
PHP5.5 beta4 install
(c) 2013 Masashi Shinbara @shin1x1
$ php -v
PHP 5.5.0beta4 (cli) (built: Apr 25 2013
21:21:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0-dev, Copyright (c)
1998-2013 Zend Technologies
Zend OPcache
(c) 2013 Masashi Shinbara @shin1x1
Zend OPcache
(c) 2013 Masashi Shinbara @shin1x1
•aka Zend Optimizer+
https://github.com/zend-dev/ZendOptimizerPlus
•opcode cache
•opcode optimization
•no user data cache
Zend OPcache
(c) 2013 Masashi Shinbara @shin1x1
$ sudo cp -a php.ini-production /usr/
local/lib/php.ini
$ sudo echo "zend_extension=opcache.so"
>> /usr/local/lib/php.ini
Zend OPcache
(c) 2013 Masashi Shinbara @shin1x1
$ php -v
PHP 5.5.0beta4 (cli) (built: Apr 26 2013
13:26:28)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0-dev, Copyright (c)
1998-2013 Zend Technologies
with Zend OPcache v7.0.2-dev,
Copyright (c) 1999-2013, by Zend
Technologies
Zend OPcache
(c) 2013 Masashi Shinbara @shin1x1
$ php -i | grep -i opcache
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 0 => 0
opcache.force_restart_timeout => 180 => 180
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 4 => 4
opcache.load_comments => 1 => 1
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 2000 => 2000
....
Zend OPcache
(c) 2013 Masashi Shinbara @shin1x1
https://github.com/zend-dev/ZendOptimizerPlus
Benchmark
(c) 2013 Masashi Shinbara @shin1x1
Benchmark
(c) 2013 Masashi Shinbara @shin1x1
<?php
class HelloController extends AppController {
  public $uses = array();
  public function index() {
    var_dump("Hello");
    exit;
  }
}
•CakePHP 2.3.2
Benchmark
(c) 2013 Masashi Shinbara @shin1x1
$ ab -c 50 -n 1000 http://localhost/hello
•CakePHP 2.3.2
Benchmark
(c) 2013 Masashi Shinbara @shin1x1
•Zend OPcache off
Requests per second: 41.05 [#/sec]
Benchmark
(c) 2013 Masashi Shinbara @shin1x1
•Zend OPcache off
Requests per second:270.55 [#/sec]
•Zend OPcache on
Requests per second: 41.05 [#/sec]
Data Cache
(c) 2013 Masashi Shinbara @shin1x1
APCu
(c) 2013 Masashi Shinbara @shin1x1
•APCu - APC User Cache
https://github.com/krakjoe/apcu
http://pecl.php.net/package/APCu
Yac
(c) 2013 Masashi Shinbara @shin1x1
•Yac(Yet Another Cache)
https://github.com/laruence/yac
http://www.laruence.com/2013/03/18/2846.html
?
Summary
(c) 2013 Masashi Shinbara @shin1x1
•Zend OPcache が標準バンドル
•php.ini で設定が必要
(beta4時点)
•データストアは別拡張で
@shin1x1
(c) 2013 Masashi Shinbara @shin1x1

PHP 5.5 Zend OPcache

  • 1.
    2013/04/26 @shin1x1 6th Kansai PHPStudy PHP5.5 Zend OPcache
  • 2.
    @shin1x1 (c) 2013 MasashiShinbara @shin1x1 http://www.1x1.jp/blog/ https://github.com/shin1x1 PHP / DevOps / AWS / Varnish / Fabric / Chef
  • 3.
    Agenda (c) 2013 MasashiShinbara @shin1x1 1. PHP5.5 beta4 install 2. Zend OPcache 3. Benchmark 4. Data Cache
  • 4.
    PHP5.5 beta4 install (c)2013 Masashi Shinbara @shin1x1
  • 5.
    PHP5.5 beta4 install (c)2013 Masashi Shinbara @shin1x1 # for RHEL6 / CentOS6 $ sudo yum install httpd-devel libxml2- devel # for extract .xz file $ sudo yum insall xz
  • 6.
    PHP5.5 beta4 install (c)2013 Masashi Shinbara @shin1x1 $ curl -OL http://downloads.php.net/dsp/ php-5.5.0beta4.tar.xz $ tar xvf php-5.5.0beta4.tar.xz $ cd php-5.5.0beta4 $ ./configure --enable-mbstring --with- apxs2 $ make $ sudo make install
  • 7.
    PHP5.5 beta4 install (c)2013 Masashi Shinbara @shin1x1 $ php -v PHP 5.5.0beta4 (cli) (built: Apr 25 2013 21:21:51) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0-dev, Copyright (c) 1998-2013 Zend Technologies
  • 8.
    Zend OPcache (c) 2013Masashi Shinbara @shin1x1
  • 9.
    Zend OPcache (c) 2013Masashi Shinbara @shin1x1 •aka Zend Optimizer+ https://github.com/zend-dev/ZendOptimizerPlus •opcode cache •opcode optimization •no user data cache
  • 10.
    Zend OPcache (c) 2013Masashi Shinbara @shin1x1 $ sudo cp -a php.ini-production /usr/ local/lib/php.ini $ sudo echo "zend_extension=opcache.so" >> /usr/local/lib/php.ini
  • 11.
    Zend OPcache (c) 2013Masashi Shinbara @shin1x1 $ php -v PHP 5.5.0beta4 (cli) (built: Apr 26 2013 13:26:28) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0-dev, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.2-dev, Copyright (c) 1999-2013, by Zend Technologies
  • 12.
    Zend OPcache (c) 2013Masashi Shinbara @shin1x1 $ php -i | grep -i opcache opcache.blacklist_filename => no value => no value opcache.consistency_checks => 0 => 0 opcache.dups_fix => Off => Off opcache.enable => On => On opcache.enable_cli => Off => Off opcache.enable_file_override => Off => Off opcache.error_log => no value => no value opcache.fast_shutdown => 0 => 0 opcache.force_restart_timeout => 180 => 180 opcache.inherited_hack => On => On opcache.interned_strings_buffer => 4 => 4 opcache.load_comments => 1 => 1 opcache.log_verbosity_level => 1 => 1 opcache.max_accelerated_files => 2000 => 2000 ....
  • 13.
    Zend OPcache (c) 2013Masashi Shinbara @shin1x1 https://github.com/zend-dev/ZendOptimizerPlus
  • 14.
    Benchmark (c) 2013 MasashiShinbara @shin1x1
  • 15.
    Benchmark (c) 2013 MasashiShinbara @shin1x1 <?php class HelloController extends AppController {   public $uses = array();   public function index() {     var_dump("Hello");     exit;   } } •CakePHP 2.3.2
  • 16.
    Benchmark (c) 2013 MasashiShinbara @shin1x1 $ ab -c 50 -n 1000 http://localhost/hello •CakePHP 2.3.2
  • 17.
    Benchmark (c) 2013 MasashiShinbara @shin1x1 •Zend OPcache off Requests per second: 41.05 [#/sec]
  • 18.
    Benchmark (c) 2013 MasashiShinbara @shin1x1 •Zend OPcache off Requests per second:270.55 [#/sec] •Zend OPcache on Requests per second: 41.05 [#/sec]
  • 19.
    Data Cache (c) 2013Masashi Shinbara @shin1x1
  • 20.
    APCu (c) 2013 MasashiShinbara @shin1x1 •APCu - APC User Cache https://github.com/krakjoe/apcu http://pecl.php.net/package/APCu
  • 21.
    Yac (c) 2013 MasashiShinbara @shin1x1 •Yac(Yet Another Cache) https://github.com/laruence/yac http://www.laruence.com/2013/03/18/2846.html ?
  • 22.
    Summary (c) 2013 MasashiShinbara @shin1x1 •Zend OPcache が標準バンドル •php.ini で設定が必要 (beta4時点) •データストアは別拡張で
  • 23.
    @shin1x1 (c) 2013 MasashiShinbara @shin1x1