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 PEAR extension Cache-Lite 를 이용한 응용 프로그램 최적화

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

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

    Date2009.07.01 Category응용개발 By웁쓰 Views17416
    Read More
  4. PHP에서 prepared statement 사용시 BIND 관련 팁

    Date2009.06.30 Category응용개발 ByPrototype Views14843
    Read More
  5. cubrid_fetch_all() php 함수로 만들어 사용하기

    Date2009.06.30 Category응용개발 By시난 Views18619
    Read More
  6. Java Data Type의 CUBRID Data Type으로의 변경 Tip

    Date2009.06.16 Category응용개발 Bycubebridge Views18032
    Read More
  7. ODBC 드라이버를 이용한 Prepare 사용하기.

    Date2009.06.16 Category응용개발 Byseongjoon Views19591
    Read More
  8. PHP에서 prepared statement 사용하기

    Date2009.04.16 Category응용개발 ByPrototype Views21454
    Read More
  9. jdbc에서 질의 플랜정보 보는 방법

    Date2009.04.15 Category응용개발 By손승일 Views15840
    Read More
  10. jdbc에서 bit 데이터 타입 사용하기

    Date2009.04.11 Category응용개발 By손승일 Views15013
    Read More
  11. CUBRID 에서 제공하는 ODBC 함수 목록

    Date2008.11.21 Category응용개발 Byadmin Views26052
    Read More
  12. Attempt to access a closed ResultSet(PreparedStatement) 오류

    Date2008.11.21 Category응용개발 Byadmin Views28035
    Read More
  13. loadjava 사용 시 inner class 로딩은 어떻게?

    Date2008.11.21 Category응용개발 Byadmin Views27450
    Read More
  14. tomcat 5.5 버전 이상에서 dbcp(커넥션 풀링) 설정법

    Date2008.11.21 Category응용개발 Byadmin Views28527
    Read More
  15. embedded sql 에서 char 사용시 주의 사항

    Date2008.11.21 Category응용개발 Byadmin Views19008
    Read More
  16. 응용프로그램에서 질의 처리시 commit/rollback 처리 문제

    Date2008.11.21 Category응용개발 Byadmin Views21600
    Read More
Board Pagination Prev 1 2 3 Next
/ 3

Contact Cubrid

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