CakePHP2.0
  Performance
  UpgradeShell

      2011/12/12
    CakePHP2 study

    Yasushi Ichikawa
I am
Yasushi Ichikawa




@cakephper
http://d.hatena.ne.jp/cakephper
Services
KANAEL
http://kanael.net
ATND::Payment
http://atndpay.eizoku.com
Tipshare
http://tipshare.info
CakePHP
Advent
Calendar
2011
http://atnd.org/events/22721
Cake2 Performance
Upgrade shell
Memory Engine



   @ichikaway   http://cake.eizoku.com/blog/
Cake2 Performance
Cake2 Performance


「 CakePHP2.0 勉強会で発表しました
ローディングの話」

http://d.hatena.ne.jp/cakephper/2011
0627



     @ichikaway   http://cake.eizoku.com/blog/
Cake2 Performance
●   Lazy Load
●
  利用するギリギリまでロードしない
● 例 : uses に定義したモデルは、

 $this->Post->xxx() までオブジェクト生
 成されない
●   PHP4 のサポート廃止


      @ichikaway   http://cake.eizoku.com/blog/
Cake2 Performance
●
    環境
●   Dell SC440(Pen, 2Gmem) Ubuntu
●   PHP5.3.5(APC), Apache2, MySQL5.1
●
    計測ツール
●   siege -c 10 -b -t 3S
●
    アプリケーション
●     Bake した index アクション
    ●
       paginate, many link

       @ichikaway   http://cake.eizoku.com/blog/
Cake2 Performance




@ichikaway   http://cake.eizoku.com/blog/
Cake2 Performance
● CakePHP1.3.11
  ● 29 req/sec

  ● xhpref: 66msec, 16,931calls

● CakePHP2.0.4

  ● 40 req/sec

  ● xhpref: 50msec, 12,432calls




    @ichikaway   http://cake.eizoku.com/blog/
Cake2 Performance




30% 速度アップ!


@ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell
Upgrade Shell
●Cake1.3 のコードを自動変換
●
 全自動ではありません




    @ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell


$ cd 13/cake/app
$ lib/Cake/Console/cake upgrade




    @ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell


dry-run オプション
cake upgrade all --dry-run

実行ログのみ表示
コードは書き換えない

    @ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell
●all
 ●全てのオプションを実行

●tests

 ●テスト名の変更など

●locations

 ●ファイル / フォルダ名変更




    @ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell
●i18n
 ●__() 関係の変更

 ●true 廃止、 echo 追加

●helpers

 ●ヘルパー呼出し $this 経由

●basics

 ●廃止 Global 関数置換


    @ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell
●request
 ● $this->request->xxx()

 ● data,params,here,action

●configure

 ● Configure::read() 置換

●constants

 ●定数の変更



     @ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell
●components
 ●Component クラスを継承するように

●exceptions

 ●cakeError を例外に置換

 ●error400, error404, error500




    @ichikaway   http://cake.eizoku.com/blog/
Upgrade Shell
●cake upgrade all の後に ...
● webroot 入替え

● database.php 書き換え

  ●//'driver' => 'mysql',

    ●   'datasource' => 'Database/Mysql',
● core.php 入替え (APC off ?)
● routes.php 入替え

● tmp キャッシュ消去


          @ichikaway   http://cake.eizoku.com/blog/
Memory Engine
Memory Engine
●Cake2 Fixture
● fields['tableParameters']['engine']

● 何も指定が無い場合は

  ● MySQL Memory Engine 利用

  ● Transaction テストは注意

  ● テスト実行時間短縮 ( 利点 )

  ● SSD の IO 寿命短縮を回避




     @ichikaway   http://cake.eizoku.com/blog/
Memory Engine
●   詳しくは tipshare.info で
    「 CakePHP2.0 から Fixture で
    MySQL の MEMORY エンジンが使
    われる場合の回避方法 」

    http://tipshare.info/view/4ed736af4
    b2122247e000004


        @ichikaway   http://cake.eizoku.com/blog/
THANK YOU


@cakephper   http://cake.eizoku.com/blog/

CakePHP2.0 performance, upgrade shell