Background Image
응용개발
2009.07.01 00:09

PHP 성능 최적화를 위한 고려 사항

조회 수 17416 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

1 . strace를 통한 시스템콜 추적

테스트 방법

/usr/sbin/apache2 -X &
[1] 16367

% strace -p 16367 -o sys1.txt
Process 16367 attached - interrupt to quit

Process 16367 detached
% grep stat sys1.txt | grep -v fstat | wc -l 153

잘 고민 하지 않고 넘어 가는 부분이긴 하지만 다음의 실수는 strace를 통한 시스템콜에서 발견 할 수 있다.
여러 확장자를 디렉토리 인덱스에 적용하면 여러번의 시스템콜이 일어나며 성능에 악영향을 미친다.
stat64("/var/www/index.html", 0xbfd279ac) = -1 ENOENT (No such file or directory)
stat64("/var/www/index.cgi", 0xbfd27afc) = -1 ENOENT (No such file or directory)
stat64("/var/www/index.pl", 0xbfd27afc) = -1 ENOENT (No such file or directory)
stat64("/var/www/index.php", {st_mode=S_IFREG|0664, st_size=7198, ...}) = 0
TODO: DirectoryIndex 에 필요한 확장자만 등록 할것
<Directory /var/www>
    DirectoryIndex index.php
</Directory>

2. include 경로 설정 주의

다음의 두가지 경우를 테스트 해볼것
TODO:

;include_path = ".:/usr/local/lib/php" --worst
include_path = "/usr/local/lib/php:." -- best
 
% /usr/sbin/apache2 -X &
[1] 16381
% strace -p 16381 -o sys2.txt 
Process 16381 attached - interrupt to quit
Process 16381 detached
% grep stat sys2.txt | grep -v fstat | wc -l
36
All the syscalls
accept(3, {sa_family=AF_INET, sin_port=htons(52362), sin_addr=inet_addr("10.211.55.2")}, [16]) = 9
getsockname(9, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("10.211.55.3")}, [16]) = 0
fcntl64(9, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(9, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
read(9, "GET /index.php?action=public HTT"..., 8000) = 230
gettimeofday({1216450700, 390225}, NULL) = 0

3. Cache를 적용 할 것

APC Cache 인스톨
$pecl install apc
vi php.ini
extension="apc.so"
apc.enabled=1
apc.shm_segments=1
apc.shm_size=256
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.include_once_override=1

4. 다 해봤는데 어렵다면 프로파일링을 해볼것


  1. PHP 프로그램을 작성할때 주의할 점

    Date2009.07.01 Category응용개발 ByPrototype Views13728
    Read More
  2. PHP PEAR extension Cache-Lite 를 이용한 응용 프로그램 최적화

    Date2009.07.01 Category응용개발 By웁쓰 Views17044
    Read More
  3. PHP PEAR extension 을 이용한 DB Time 추적

    Date2009.07.01 Category응용개발 By웁쓰 Views19185
    Read More
  4. PHP 성능 최적화를 위한 고려 사항

    Date2009.07.01 Category응용개발 By웁쓰 Views17416
    Read More
  5. CSQL 로 쿼리 플랜을 볼때 주의해야 할 점

    Date2009.06.30 Category운영관리 ByPrototype Views12382
    Read More
  6. OS별 CPU, memory, kernel bit 를 확인하는 방법입니다.

    Date2009.06.30 Category기타 By남재우 Views26903
    Read More
  7. PHP에서 prepared statement 사용시 BIND 관련 팁

    Date2009.06.30 Category응용개발 ByPrototype Views14843
    Read More
  8. csql 인터프리터를 통해 쿼리 수행시간을 확인하는 방법.

    Date2009.06.30 Category운영관리 Byseongjoon Views13196
    Read More
  9. CUBRID 2008에서의 class 정보를 확인하는 sql 쿼리문.

    Date2009.06.30 Category질의작성 Byseongjoon Views13288
    Read More
  10. cubrid_fetch_all() php 함수로 만들어 사용하기

    Date2009.06.30 Category응용개발 By시난 Views18619
    Read More
  11. ODBC 드라이버만 따로 배포하는 방법

    Date2009.06.26 Category기타 By손승일 Views18060
    Read More
  12. 큐브리드와 hostname 관계

    Date2009.06.25 Category운영관리 By정만영 Views18584
    Read More
  13. pivot() 간략하게 구현하기

    Date2009.06.24 Category질의작성 By남재우 Views23429
    Read More
  14. CUBRID Manager 결과창에서 레코드 값 변경하기.

    Date2009.06.22 CategoryCUBRID 매니저 Byseongjoon Views19074
    Read More
  15. 큐브리드 사용포트 정리

    Date2009.06.19 Category운영관리 By정만영 Views29776
    Read More
  16. 큐브리드 백업방법

    Date2009.06.18 Category운영관리 By정만영 Views24564
    Read More
  17. Broker_log_top 결과 분석 방법

    Date2009.06.18 Category운영관리 Bycubebridge Views11559
    Read More
  18. Java Data Type의 CUBRID Data Type으로의 변경 Tip

    Date2009.06.16 Category응용개발 Bycubebridge Views18032
    Read More
  19. CUBRID Manager 실행 에러의 총정리와 해결방법.

    Date2009.06.16 CategoryCUBRID 매니저 Byseongjoon Views17789
    Read More
  20. CUBRID 2008에서 ' 사용하기.

    Date2009.06.16 Category질의작성 Byseongjoon Views13315
    Read More
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 Next
/ 14

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales