>  기사  >  백엔드 개발  >  PHP7.0과 PHP5.6에서 Laravel 블로그 애플리케이션 성능 비교 분석에 대한 자세한 설명

PHP7.0과 PHP5.6에서 Laravel 블로그 애플리케이션 성능 비교 분석에 대한 자세한 설명

藏色散人
藏色散人앞으로
2020-04-23 14:07:423016검색

현재 제가 설치한 홈스테드 가상머신 버전은 2.1.8입니다.

PHP7.0과 PHP5.6에서 Laravel 블로그 애플리케이션 성능 비교 분석에 대한 자세한 설명

홈스테드에 사전 설치된 PHP 버전은 5.6.15입니다.

PHP7.0과 PHP5.6에서 Laravel 블로그 애플리케이션 성능 비교 분석에 대한 자세한 설명

ab 명령(성능 테스트 도구 제공: Apache) 이 버전에서는 Laravel 애플리케이션(현재 Laravel을 사용하여 개발된 블로그 애플리케이션을 예로 들어)의 성능을 테스트하기 위해 스트레스 테스트를 위해 10,000개의 요청과 100개의 동시성을 시뮬레이션합니다.

ab -n 10000 -c 100 http://blog.app/

실행 결과는 다음과 같습니다.

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 blog.app (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/1.8.0
Server Hostname: blog.app
Server Port: 80

Document Path: /
Document Length: 324 bytes

Concurrency Level: 100
Time taken for tests: 69.354 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 19851388 bytes
HTML transferred: 10230000 bytes
Requests per second: 144.19 [#/sec] (mean)
Time per request: 693.545 [ms] (mean)
Time per request: 6.935 [ms] (mean, across all concurrent requests)
Transfer rate: 279.52 [Kbytes/sec] received

Connection Times (ms)
                  min  mean[+/-sd]  median  max
Connect:       0       0     0.2                 0      3
Processing: 17    684   319.1           588   2720
Waiting:      17     684   319.1           588   2720
Total:          20     684   319.1           588   2720

Percentage of the requests served within a certain time (ms)
 50%      588
 66%      695
 75%      842
 80%      933
 90%    1155
 95%    1321
 98%    1545
 99%    1813
 100%  2720 (longest request)

여기서 빨간색 굵은 텍스트에 주목하세요. 초당 처리되는 요청 수는 시스템 성능 측정의 핵심 지표입니다. 시스템 및 하드웨어 구성에 따라 데이터에 일부 불일치가 있을 수 있습니다.

이제 "Laravel Homestead는 PHP 7을 지원합니다" 섹션에 설명된 대로 Homestead의 PHP를 버전 7.0으로 업그레이드합니다.

vagrant ssh를 사용하여 새로 추가된 homestead-7 가상 머신에 로그인하고 PHP 버전 정보가 올바른지 확인하십시오.

PHP7.0과 PHP5.6에서 Laravel 블로그 애플리케이션 성능 비교 분석에 대한 자세한 설명

이 때 브라우저에서 http://blog.app에 액세스하면 새로 설치된 홈스테드 때문에 오류가 발생했습니다. 데이터베이스 데이터가 비어 있으므로 마이그레이션을 실행하고 데이터를 채우려면 다음 명령을 실행해야 합니다.

php artisan migrate 
php artisan db:seed

다시 액세스해도 괜찮습니다. 계속해서 동일한 ab 명령을 사용하여 스트레스 테스트를 수행합니다.

ab -n 10000 -c 100 http://blog.app/

실행 결과는 다음과 같습니다.

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 blog.app (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/1.8.0
Server Hostname: blog.app
Server Port: 80

Document Path: /
Document Length: 324 bytes

Concurrency Level: 100
Time taken for tests: 45.032 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 20101202 bytes
HTML transferred: 10230000 bytes
Requests per second: 222.06 [#/sec] (mean)
Time per request: 450.319 [ms] (mean)
Time per request: 4.503 [ms] (mean, across all concurrent requests)
Transfer rate: 435.91 [Kbytes/sec] received

Connection Times (ms)
                  min  mean[+/-sd]  median   max
Connect:       0       0     0.2                 0       4
Processing: 11    443   252.8           379   1978
Waiting:      11     443   252.8           379   1978
Total:          15     443   252.8           379   1978

Percentage of the requests served within a certain time (ms)
 50%      379
 66%      517
 75%      590
 80%      631
 90%      795
 95%      938
 98%    1060
 99%    1229
 100%  1978 (longest request)

비교 후 PHP 7.0에서 동일한 Laravel 애플리케이션의 성능은 PHP 5.6에서보다 54% 더 높습니다. 물론, 데이터는 환경에 따라 다르며 아직 개선의 여지가 더 많습니다.

원본 주소: https://xueyuanjun.com/post/2398

위 내용은 PHP7.0과 PHP5.6에서 Laravel 블로그 애플리케이션 성능 비교 분석에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 xueyuanjun.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제