[펌]PHP accelerator 선택 (APC, eAccelerator, XCache, Nusphere PhpExpress, Zend Optimizer+)

4 minute read

http://blog.naver.com/kimbumsuc?Redirect=Log&logNo=80155677456

내용 요약

  • APC가 좋다. 
  • 대응이 빠르다.
  • PHP6에 기본으로 들어갈 예정
  • 몇몇 프레임 워크에서 기본 지원한다.
  • http://pecl.php.net/package/APC

APC binaries for PHP 5.x (windows builds)

http://www.sitebuddy.com/PHP/Accelerators/apc_windows_binaries_builds
http://dev.freshsite.pl/php-accelerators/apc.html


다운로드 관련 http://downloads.php.net/pierre/


테스트 적용

  • File Cache Information

<tbody>&lt;tr class="tr-0" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Cached Files&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;**1115 ( 54.0 MBytes)**&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr class="tr-1" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Hits&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;181380&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr class="tr-0" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Misses&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;1590&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr class="tr-1" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Request Rate (hits, misses)&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;2.38 cache requests/second&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr class="tr-0" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Hit Rate&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;2.36 cache requests/second&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr class="tr-1" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Miss Rate&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;0.02 cache requests/second&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr class="tr-0" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Insert Rate&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;0.02 cache requests/second&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr class="tr-1" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); background-position: initial initial; background-repeat: initial initial; "&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; border-right-style: solid; border-right-color: rgb(102, 102, 153); border-right-width: 1px; white-space: nowrap; "&amp;gt;Cache full count&amp;lt;/td&amp;gt;&amp;lt;td style="font-size: 0.8em; vertical-align: top; padding-top: 0.3em; padding-right: 1em; padding-bottom: 0.3em; padding-left: 1em; "&amp;gt;0&amp;lt;/td&amp;gt;&lt;/tr&gt;</tbody>

Host Status Diagrams

<tbody>&lt;tr&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.2em; padding-right: 1em; padding-bottom: 0.4em; padding-left: 1em; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); "&amp;gt;Memory Usage &amp;amp;#xD; &amp;amp;lt;font size="-2"&amp;amp;gt;(multiple slices indicate fragments)&amp;amp;lt;/font&amp;amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td class="td-1" style="font-size: 0.8em; vertical-align: top; padding-top: 0.2em; padding-right: 1em; padding-bottom: 0.4em; padding-left: 1em; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); "&amp;gt;Hits &amp;amp;amp;amp; Misses&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.2em; padding-right: 1em; padding-bottom: 0.4em; padding-left: 1em; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); "&amp;gt; Free: 201.8 MBytes (78.8%)&amp;lt;/td&amp;gt;&amp;lt;td class="td-1" style="font-size: 0.8em; vertical-align: top; padding-top: 0.2em; padding-right: 1em; padding-bottom: 0.4em; padding-left: 1em; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); "&amp;gt; **Hits: 181380 (99.1%)**&amp;lt;/td&amp;gt;&lt;/tr&gt;&lt;tr&gt;&amp;lt;td class="td-0" style="font-size: 0.8em; vertical-align: top; padding-top: 0.2em; padding-right: 1em; padding-bottom: 0.4em; padding-left: 1em; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); "&amp;gt; **Used: 54.2 MBytes (21.2%)**&amp;lt;/td&amp;gt;&amp;lt;td class="td-1" style="font-size: 0.8em; vertical-align: top; padding-top: 0.2em; padding-right: 1em; padding-bottom: 0.4em; padding-left: 1em; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); "&amp;gt; Misses: 1590 (0.9%)&amp;lt;/td&amp;gt;&lt;/tr&gt;</tbody>

1000여개의 파일이고 54MB 사이즈를 가지고 있고 99%의 HIT률을 보인다.

좋구나.


APC 튜닝 포인트

  • apc.shm_size=256M //쉐어드메모리 사이즈: 너무 작으면 단편화가 너무 많이 생긴다. HITS보다 MISS가 더 생실 수 있으니, 넉넉히…
  • apc.stat=1 //0으로 하면 CPU사용률이 조금 내려가지만, 소스파일 수정을 체크하지 않는다. 즉, 그냥 1로 두어라.
  • apc.include_once_override=0 //1로 하면 APC에서 include_once(require_once)를 처리한다. CPU사용률이 꽤 내려가지만, PHP의 소스 작성에 따라서 에러가 발생할 수 있다.
  • apc.shm_size를 넉넉히 하고
    apc.stat=1
    apc.include_once_override=0
    일 때 CPU IDLE이 56 정도였는데
    apc.include_once_override=1로 바꾸니 거의 70까지 CPU IDLE이 높아졌다.

알아낸 버그

  • include_once 할 때 경로를 같게하라.
  • 한쪽에서는 절대경로, 한쪽에서는 상대 경로로 할경우 class 를 찾을 수 없다는 에러가 발생할 수 있다.(APC 3.1.9 버전에서 확인)
  • 해결법은 상대 경로일 경우
    include_once(‘../../lib/class.CCCC.php’);
    ->
    include_once(dirname(_FILE).’/../../lib/class.CCCC.php’);
    처럼 바꿔서 전부 절대경로를 사용하도록 한다.
  • 아니면 APC를 끄던가.

🔗original-link

Updated: