백엔드 개발 PHP 튜토리얼 php opcache 效果测试

php opcache 效果测试

Jun 20, 2016 pm 12:49 PM

测试环境

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ lscpu

Architecture:          i686

CPU op-mode(s):        32-bit, 64-bit

Byte Order:            Little Endian

CPU(s):                4

On-line CPU(s) list:   0-3

Thread(s) per core:    2

Core(s) per socket:    2

Socket(s):             1

Vendor ID:             GenuineIntel

CPU family:            6

Model:                 37

Stepping:              2

CPU MHz:               1199.000

BogoMIPS:              4521.76

Virtualization:        VT-x

L1d cache:             32K

L1i cache:             32K

L2 cache:              256K

L3 cache:              3072K

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ free -m

             total       used       free     shared    buffers     cached

Mem:          1869       1654        215        265          4        526

-/+ buffers/cache:       1123        745

Swap:         3320          1       3319



??未安装opcache测试??

lyolzj@localhost ~ $ ab -n 1000 -c 10 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      10

Time taken for tests:   79.554 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    12.57 [#/sec] (mean)

Time per request:       795.536 [ms] (mean)

Time per request:       79.554 [ms] (mean, across all concurrent requests)

Transfer rate:          111.70 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.0      0       0

Processing:   258  793 163.7    771    2227

Waiting:      249  777 163.1    755    2227

Total:        258  793 163.7    771    2227


Percentage of the requests served within a certain time (ms)

  50%    771

  66%    822

  75%    849

  80%    867

  90%    926

  95%    963

  98%   1040

  99%   1901

 100%   2227 (longest request)

lyolzj@localhost ~ $ ab -n 1000 -c 100 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      100

Time taken for tests:   81.475 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    12.27 [#/sec] (mean)

Time per request:       8147.464 [ms] (mean)

Time per request:       81.475 [ms] (mean, across all concurrent requests)

Transfer rate:          109.06 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   1.0      0       5

Processing:   232 7758 1533.2   7921    9906

Waiting:      220 7740 1532.2   7908    9893

Total:        237 7758 1532.3   7921    9906


Percentage of the requests served within a certain time (ms)

  50%   7921

  66%   8258

  75%   8488

  80%   8682

  90%   9020

  95%   9289

  98%   9531

  99%   9674

 100%   9906 (longest request)




安装opcache

lyolzj@localhost /usr/local/src $ sudo wget http://pecl.php.net/get/zendopcache-7.0.5.tgz

lyolzj@localhost /usr/local/src $ sudo tar -zxf zendopcache-7.0.5.tgz 

lyolzj@localhost /usr/local/src $ cd zendopcache-7.0.5/

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ ls

config.m4                     zend_accelerator_debug.c

config.w32                    zend_accelerator_debug.h

CREDITS                       ZendAccelerator.h

LICENSE                       zend_accelerator_hash.c

Optimizer                     zend_accelerator_hash.h

README                        zend_accelerator_module.c

shared_alloc_mmap.c           zend_accelerator_module.h

shared_alloc_posix.c          zend_accelerator_util_funcs.c

shared_alloc_shm.c            zend_accelerator_util_funcs.h

shared_alloc_win32.c          zend_persist.c

tests                         zend_persist_calc.c

zend_accelerator_blacklist.c  zend_persist.h

zend_accelerator_blacklist.h  zend_shared_alloc.c

ZendAccelerator.c             zend_shared_alloc.h

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo /usr/local/php5.4/bin/phpize 

Configuring for:

PHP Api Version:         20100412

Zend Module Api No:      20100525

Zend Extension Api No:   220100525

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo ./configure --with-php-config=/usr/local/php5.4/bin/php-config

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo make

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo make install

Installing shared extensions:     /usr/local/php5.4/lib/php/extensions/no-debug-non-zts-20100525/


配置opcache

在php.ini中添加

zend_extension= /usr/local/php5.4/lib/php/extensions/no-debug-non-zts-20100525/opcache.so

[opcache]

opcache.memory_consumption=128

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4000

opcache.revalidate_freq=60

opcache.fast_shutdown=1

opcache.enable_cli=1


lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo netstat -ntlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      2549/php-fpm.conf)

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN   

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo kill 2549

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo /usr/local/php5.4/sbin/php-fpm -y /usr/local/php5.4/etc/php-fpm.conf


lyolzj@localhost ~ $ ab -n 1000 -c 10 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      10

Time taken for tests:   27.116 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    36.88 [#/sec] (mean)

Time per request:       271.158 [ms] (mean)

Time per request:       27.116 [ms] (mean, across all concurrent requests)

Transfer rate:          327.70 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.4      0       5

Processing:   190  270  55.9    260     628

Waiting:      185  263  54.2    254     625

Total:        190  270  56.1    260     632


Percentage of the requests served within a certain time (ms)

  50%    260

  66%    282

  75%    301

  80%    313

  90%    341

  95%    368

  98%    398

  99%    443

 100%    632 (longest request)

lyolzj@localhost ~ $ ab -n 1000 -c 100 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      100

Time taken for tests:   28.363 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    35.26 [#/sec] (mean)

Time per request:       2836.330 [ms] (mean)

Time per request:       28.363 [ms] (mean, across all concurrent requests)

Transfer rate:          313.28 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    1   1.7      0       7

Processing:    86 2700 515.9   2804    3322

Waiting:       81 2692 515.3   2797    3311

Total:         94 2700 514.3   2804    3322


Percentage of the requests served within a certain time (ms)

  50%   2804

  66%   2853

  75%   2886

  80%   2909

  90%   3025

  95%   3127

  98%   3186

  99%   3223

 100%   3322 (longest request)


结果

    由Time per request:       81.475 [ms] 变成Time per request:       28.363 [ms];提升了近3倍。


본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. 크로스 플레이가 있습니까?
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

JWT (JSON Web Tokens) 및 PHP API의 사용 사례를 설명하십시오. JWT (JSON Web Tokens) 및 PHP API의 사용 사례를 설명하십시오. Apr 05, 2025 am 12:04 AM

JWT는 주로 신분증 인증 및 정보 교환을 위해 당사자간에 정보를 안전하게 전송하는 데 사용되는 JSON을 기반으로 한 개방형 표준입니다. 1. JWT는 헤더, 페이로드 및 서명의 세 부분으로 구성됩니다. 2. JWT의 작업 원칙에는 세 가지 단계가 포함됩니다. JWT 생성, JWT 확인 및 Parsing Payload. 3. PHP에서 인증에 JWT를 사용하면 JWT를 생성하고 확인할 수 있으며 사용자 역할 및 권한 정보가 고급 사용에 포함될 수 있습니다. 4. 일반적인 오류에는 서명 검증 실패, 토큰 만료 및 대형 페이로드가 포함됩니다. 디버깅 기술에는 디버깅 도구 및 로깅 사용이 포함됩니다. 5. 성능 최적화 및 모범 사례에는 적절한 시그니처 알고리즘 사용, 타당성 기간 설정 합리적,

확실한 원칙과 PHP 개발에 적용되는 방법을 설명하십시오. 확실한 원칙과 PHP 개발에 적용되는 방법을 설명하십시오. Apr 03, 2025 am 12:04 AM

PHP 개발에서 견고한 원칙의 적용에는 다음이 포함됩니다. 1. 단일 책임 원칙 (SRP) : 각 클래스는 하나의 기능 만 담당합니다. 2. Open and Close Principle (OCP) : 변경은 수정보다는 확장을 통해 달성됩니다. 3. Lisch의 대체 원칙 (LSP) : 서브 클래스는 프로그램 정확도에 영향을 미치지 않고 기본 클래스를 대체 할 수 있습니다. 4. 인터페이스 격리 원리 (ISP) : 의존성 및 사용되지 않은 방법을 피하기 위해 세밀한 인터페이스를 사용하십시오. 5. 의존성 반전 원리 (DIP) : 높고 낮은 수준의 모듈은 추상화에 의존하며 종속성 주입을 통해 구현됩니다.

시스템 재시작 후 UnixSocket의 권한을 자동으로 설정하는 방법은 무엇입니까? 시스템 재시작 후 UnixSocket의 권한을 자동으로 설정하는 방법은 무엇입니까? Mar 31, 2025 pm 11:54 PM

시스템이 다시 시작된 후 UnixSocket의 권한을 자동으로 설정하는 방법. 시스템이 다시 시작될 때마다 UnixSocket의 권한을 수정하려면 다음 명령을 실행해야합니다.

PHP에서 늦은 정적 결합의 개념을 설명하십시오. PHP에서 늦은 정적 결합의 개념을 설명하십시오. Mar 21, 2025 pm 01:33 PM

기사는 PHP 5.3에 도입 된 PHP의 LSB (Late STATIC BING)에 대해 논의하여 정적 방법의 런타임 해상도가보다 유연한 상속을 요구할 수있게한다. LSB의 실제 응용 프로그램 및 잠재적 성능

PHP의 CURL 라이브러리를 사용하여 JSON 데이터가 포함 된 게시물 요청을 보내는 방법은 무엇입니까? PHP의 CURL 라이브러리를 사용하여 JSON 데이터가 포함 된 게시물 요청을 보내는 방법은 무엇입니까? Apr 01, 2025 pm 03:12 PM

PHP 개발에서 PHP의 CURL 라이브러리를 사용하여 JSON 데이터를 보내면 종종 외부 API와 상호 작용해야합니다. 일반적인 방법 중 하나는 컬 라이브러리를 사용하여 게시물을 보내는 것입니다 ...

프레임 워크 보안 기능 : 취약점 보호. 프레임 워크 보안 기능 : 취약점 보호. Mar 28, 2025 pm 05:11 PM

기사는 입력 유효성 검사, 인증 및 정기 업데이트를 포함한 취약점을 방지하기 위해 프레임 워크의 필수 보안 기능을 논의합니다.

프레임 워크 사용자 정의/확장 : 사용자 정의 기능을 추가하는 방법. 프레임 워크 사용자 정의/확장 : 사용자 정의 기능을 추가하는 방법. Mar 28, 2025 pm 05:12 PM

이 기사에서는 프레임 워크에 사용자 정의 기능 추가, 아키텍처 이해, 확장 지점 식별 및 통합 및 디버깅을위한 모범 사례에 중점을 둡니다.

See all articles