国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP開啟opcache提升代碼性能

2024-05-04 23:34:41
字體:
來源:轉載
供稿:網友

APC在PHP5.4及以下版本是性能最好的代碼緩存。不過PHP升級到5.5及以上后,APC不再有效。需要使用Zend的OpCache擴展。

配置指令如下:

 

 
  1. [opcache] 
  2. zend_extension=opcache.so 
  3. opcache.enable_cli=1 
  4. ;共享內存大小, 這個根據你們的需求可調 
  5. opcache.memory_consumption=256  
  6. ;interned string的內存大小, 也可調 
  7. opcache.interned_strings_buffer=8 
  8. ;最大緩存的文件數目 
  9. opcache.max_accelerated_files=4000 
  10. ;60s檢查一次文件更新 
  11. opcache.revalidate_freq=60 
  12. ;打開快速關閉, 打開這個在PHP Request Shutdown的時候 會收內存的速度會提高 
  13. opcache.fast_shutdown=1 
  14. ;不保存文件/函數的注釋 
  15. opcache.save_comments=0  

實際性能對比:

下面是實際測試中沒有開啟opcache的數據:

 

 
  1. [root@localhost ~]# ab -n 10000 -c 200 "http://112.126.69.14/main.php?a=Role&m=createRole" 
  2. This is ApacheBench, Version 2.3 <$Revision: 655654 #FormatTableID_1#gt; 
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 
  4. Licensed to The Apache Software Foundation, http://www.apache.org/ 
  5.  
  6. Benchmarking 112.126.69.14 (be patient) 
  7. Completed 1000 requests 
  8. Completed 2000 requests 
  9. Completed 3000 requests 
  10. Completed 4000 requests 
  11. Completed 5000 requests 
  12. Completed 6000 requests 
  13. Completed 7000 requests 
  14. Completed 8000 requests 
  15. Completed 9000 requests 
  16. Completed 10000 requests 
  17. Finished 10000 requests 
  18.  
  19. Server Software: openresty/1.7.2.1 
  20. Server Hostname: 112.126.69.14 
  21. Server Port: 80 
  22.  
  23. Document Path: /main.php?a=Role&m=createRole 
  24. Document Length: 2 bytes 
  25.  
  26. Concurrency Level: 200 
  27. Time taken for tests: 26.061 seconds 
  28. Complete requests: 10000 
  29. Failed requests: 20 
  30. (Connect: 0, Receive: 0, Length: 20, Exceptions: 0) 
  31. Write errors: 0 
  32. Non-2xx responses: 20 
  33. Total transferred: 1713580 bytes 
  34. HTML transferred: 23520 bytes 
  35. Requests per second: 383.72 [#/sec] (mean) 
  36. Time per request: 521.216 [ms] (mean) 
  37. Time per request: 2.606 [ms] (mean, across all concurrent requests) 
  38. Transfer rate: 64.21 [Kbytes/sec] received 
  39.  
  40. Connection Times (ms) 
  41. min mean[+/-sd] median max 
  42. Connect: 2 3 3.2 2 60 
  43. Processing: 17 461 905.0 219 16496 
  44. Waiting: 17 461 904.9 219 16496 
  45. Total: 21 464 905.0 222 16502 
  46.  
  47. Percentage of the requests served within a certain time (ms) 
  48. 50% 222 
  49. 66% 271 
  50. 75% 369 
  51. 80% 412 
  52. 90% 805 
  53. 95% 1248 
  54. 98% 2597 
  55. 99% 3489 
  56. 100% 16502 (longest request) 

開啟之后的數據:

 

 
  1. [root@localhost ~]# ab -n 10000 -c 200 "http://112.126.69.14/main.php?a=Role&m=createRole" 
  2. This is ApacheBench, Version 2.3 <$Revision: 655654 #FormatTableID_2#gt; 
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 
  4. Licensed to The Apache Software Foundation, http://www.apache.org/ 
  5.  
  6. Benchmarking 112.126.69.14 (be patient) 
  7. Completed 1000 requests 
  8. Completed 2000 requests 
  9. Completed 3000 requests 
  10. Completed 4000 requests 
  11. Completed 5000 requests 
  12. Completed 6000 requests 
  13. Completed 7000 requests 
  14. Completed 8000 requests 
  15. Completed 9000 requests 
  16. Completed 10000 requests 
  17. Finished 10000 requests 
  18.  
  19.  
  20. Server Software: openresty/1.7.2.1 
  21. Server Hostname: 112.126.69.14 
  22. Server Port: 80 
  23.  
  24. Document Path: /main.php?a=Role&m=createRole 
  25. Document Length: 2 bytes 
  26.  
  27. Concurrency Level: 200 
  28. Time taken for tests: 14.237 seconds 
  29. Complete requests: 10000 
  30. Failed requests: 0 
  31. Write errors: 0 
  32. Total transferred: 1711710 bytes 
  33. HTML transferred: 20020 bytes 
  34. Requests per second: 702.40 [#/sec] (mean) 
  35. Time per request: 284.739 [ms] (mean) 
  36. Time per request: 1.424 [ms] (mean, across all concurrent requests) 
  37. Transfer rate: 117.41 [Kbytes/sec] received 
  38.  
  39. Connection Times (ms) 
  40. min mean[+/-sd] median max 
  41. Connect: 2 66 272.6 2 3005 
  42. Processing: 4 176 666.4 6 9026 
  43. Waiting: 4 163 642.8 6 9026 
  44. Total: 6 242 745.7 9 10028 
  45.  
  46. Percentage of the requests served within a certain time (ms) 
  47. 50% 9 
  48. 66% 14 
  49. 75% 99 
  50. 80% 122 
  51. 90% 1006 
  52. 95% 1476 
  53. 98% 2853 
  54. 99% 3543 
  55. 100% 10028 (longest request) 

以上所述就是本文的全部內容,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平湖市| 边坝县| 上饶县| 互助| 滦平县| 武功县| 怀远县| 古浪县| 凤阳县| 台江县| 长葛市| 遂宁市| 共和县| 七台河市| 紫金县| 苍梧县| 哈巴河县| 冀州市| 南康市| 乌兰浩特市| 左权县| 鄂州市| 汉沽区| 桐柏县| 综艺| 大庆市| 连江县| 蕉岭县| 来宾市| 黄平县| 天门市| 青州市| 重庆市| 济阳县| 玉树县| 昆山市| 合江县| 商南县| 锦屏县| 揭西县| 咸丰县|