PHP开启opcache提升代码性能
作者:hebedich 发布时间:2023-06-17 04:39:55
标签:PHP,开启opcache
配置指令如下:
[opcache]
zend_extension=opcache.so
opcache.enable_cli=1
;共享内存大小, 这个根据你们的需求可调
opcache.memory_consumption=256
;interned string的内存大小, 也可调
opcache.interned_strings_buffer=8
;最大缓存的文件数目
opcache.max_accelerated_files=4000
;60s检查一次文件更新
opcache.revalidate_freq=60
;打开快速关闭, 打开这个在PHP Request Shutdown的时候 会收内存的速度会提高
opcache.fast_shutdown=1
;不保存文件/函数的注释
opcache.save_comments=0
实际性能对比:
下面是实际测试中没有开启opcache的数据:
[root@localhost ~]# ab -n 10000 -c 200 "http://112.126.69.14/main.php?a=Role&m=createRole"
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 112.126.69.14 (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: openresty/1.7.2.1
Server Hostname: 112.126.69.14
Server Port: 80
Document Path: /main.php?a=Role&m=createRole
Document Length: 2 bytes
Concurrency Level: 200
Time taken for tests: 26.061 seconds
Complete requests: 10000
Failed requests: 20
(Connect: 0, Receive: 0, Length: 20, Exceptions: 0)
Write errors: 0
Non-2xx responses: 20
Total transferred: 1713580 bytes
HTML transferred: 23520 bytes
Requests per second: 383.72 [#/sec] (mean)
Time per request: 521.216 [ms] (mean)
Time per request: 2.606 [ms] (mean, across all concurrent requests)
Transfer rate: 64.21 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 3 3.2 2 60
Processing: 17 461 905.0 219 16496
Waiting: 17 461 904.9 219 16496
Total: 21 464 905.0 222 16502
Percentage of the requests served within a certain time (ms)
50% 222
66% 271
75% 369
80% 412
90% 805
95% 1248
98% 2597
99% 3489
100% 16502 (longest request)
开启之后的数据:
[root@localhost ~]# ab -n 10000 -c 200 "http://112.126.69.14/main.php?a=Role&m=createRole"
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 112.126.69.14 (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: openresty/1.7.2.1
Server Hostname: 112.126.69.14
Server Port: 80
Document Path: /main.php?a=Role&m=createRole
Document Length: 2 bytes
Concurrency Level: 200
Time taken for tests: 14.237 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1711710 bytes
HTML transferred: 20020 bytes
Requests per second: 702.40 [#/sec] (mean)
Time per request: 284.739 [ms] (mean)
Time per request: 1.424 [ms] (mean, across all concurrent requests)
Transfer rate: 117.41 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 66 272.6 2 3005
Processing: 4 176 666.4 6 9026
Waiting: 4 163 642.8 6 9026
Total: 6 242 745.7 9 10028
Percentage of the requests served within a certain time (ms)
50% 9
66% 14
75% 99
80% 122
90% 1006
95% 1476
98% 2853
99% 3543
100% 10028 (longest request)
以上所述就是本文的全部内容,希望大家能够喜欢。
0
投稿
猜你喜欢
- 请问论坛的树状记录表是怎么展开的?如何做?论坛的这种展开技术一般采用两种方法实现,一种是采用递归的方法,优点是逻辑简单,编程简单,缺点是速度
- 这是个删除非空目录的例子test.asp要执行删除你需要对该目录具有修改权限<% dim fso,tmpfold
- 摘要: Portal是IT领域的新技术,是企业信息化工作的发展方向之一。本文首先介绍了Oracle Portal的定义、特点,接着阐述了po
- 这篇论坛文章着重介绍了SQL Server数据库简体繁体数据混用的问题,详细内容请参考下文:我现在要说的是一个在简体繁体数据混用的时候很容易
- ASP与存储过程(Stored Procedures)的文章不少,但是我怀疑作者们是否真正实践过。我在初学时查阅过大量相关资料,发现其中提供
- 英文原文:The seven rules of Unobtrusive JavaScript原文地址:http://icant.co.uk/
- 一个朋友给她的朋友买礼物。撕心裂肺、绞尽脑汁。最后蹦出来一个主意:“送打火机”我不知道小妞们通过哪的投票,就这么断定男人都喜欢打火机。导致一
- 在本文上两篇中,我们学习了脚本语言 VBScript 的变量、函数、过程和条件语句,本篇将继续给大家介绍 VBScipt 的循环语句,并对脚
- 译者按:我们时常能看到不同JavaScript库/框架之间的各种比较,但这次 YUI3 架构师和 jQuery 之父的直接对话却非常难得,也
- 我们可以通过更改注册表来解决这个问题: 打开注册表,进入到[HKEY_USERS\.DEFAULT\Control Panel\Intern
- 在对跨多个表格的数据进行组合时,有时很难搞清楚要使用哪一个SQL句法。我将在这里对将多个表格中的查询合并至单一声明中的常用方式进行阐述。在这
- 运行MySQL Server 5.0安装程序“setup.exe”,出现如下界面: 安装向导启动,按“Next”继续:
- 在Microsoft SQL Server 2000中,用于数据存储的实用工具是数据库。数据库的物理表现是操作系统文件,即在物理上,一个数据
- 举例如下,一个服务器端的form 代码自动被解释成客户端代码:服务器端代码: &l
- 当使用AJAX进行GET请求的时候,会有一个现象就是刷新网页后,AJAX请求的数据没有改变,只有把IE的缓存清空,或者从新打开一个IE窗口的
- 哲学上有种说法,“运动是绝对的,静止是相对的”。我们在编写各样的效果时,时常会碰到动画。下面的章,将讨论动画的原理以及实现。动画,简而言之就
- 核心提示:VB读取MP3文件帧的信息比特率,采样频率,播放时间Private Sub Command1_Click()On Error Go
- 内容: ************* 1安装MYSQL后更改了ROOT的密码后用 net startmysql 启动时我就遇到了这样的问题.使
- 下面都是我收集的一些比较常用的正则表达式,因为平常可能在表单验证的时候,用到的比较多。特发出来,让各位朋友共同使用。呵呵。匹配中文字符的正则
- 译者newstart写的简介:Ross Dawson所在的Future Exploration Network于2007年5月发布的web2