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
投稿
猜你喜欢
- 本文实例为大家分享了Vue实现无限加载瀑布流的具体代码,供大家参考,具体内容如下我做的这个瀑布流放在了一个嵌套页面里,就是类似管理后台的ma
- 前言优雅关机就是服务端关机命令发出后不是立即关机,而是等待当前还在处理的请求全部处理完毕后再退出程序,是一种对客户端友好的关机方式。而执行C
- 在数据分析领域,数据库是我们的好帮手。不仅可以接受我们的查询时间,还可以在这基础上做进一步分析。所以,我们必然要在数据库插入数据。在实际应用
- 在matplotlib下,一个Figure对象可以包含多个子图(Axes),可以使用subplot()快速绘制,其调用形式如下:subplo
- 今天先聊一聊在windows/mac iOS系统下用venv搭建python轻量级虚拟环境的问题。使用venv搭建的虚拟环境同virtual
- rpc有多种调用方式,http、json-rpc、tcp一、服务端在代码中,启动了三个服务package mainimport ("
- Flask-RESTful是一个用于快速创建RESTful API接口的Flask扩展。使用Flask-RESTful可以很快速方便地创建一
- 这篇文章主要介绍了python实现windows桌面截图代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值
- php 运算符与表达式一、运算符的分类1、按操作数分类1.!true // 一元运算符2.$a+$b // 二元运算符3.true ? 1:
- 今天一个域名查询系统出现故障,该系统是用的ASP调用XMLHTTP获取whois库的数据,具体错误如下: msxml3.dll 错
- 网上关于Python的音视频播放示例都集中在简单的多媒体库或者PyGame这样的游戏库,有些库使用简单,但功能单一,有些库功能丰富,支持的格
- 在数据库表里,我们有时候会保存了很多重复的数据,这些重复的数据浪费资源,我们要将其删除掉,应该怎么处理呢?下面来看一下。先看下我们的表数据,
- 关于选课程序,最近着实有点忙,没机会复习os、pickle两部分模块,所以数据储存和字典读取成为了一个问题,大致原理知道,但是具体操作可能还
- 这篇文章主要介绍了基于python实现把图片转换成素描,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋
- python queue队列类型及函数1.队列的种类Python queue模块的FIFO队列先进先出。 class queue.Queue
- 尽管 JavaScript 历史上使用冗长而令人生厌的代码块来标的特定浏览器的时期已经结束了,但是偶尔使用一些简单的代码块和对象检测来确保一
- 如下所示:l = [1, 2, 3, 5]l_one = [2, 8, 6, 10]print set(l) & set(l_one
- 创建临时表,往临时表插入数据的时候报的错误。一开始提示没有打开主键,后来打开主键就提示上述错误异常。从网上查找资料没有找到,然后又到群里问各
- 本文实例为大家分享了python实现网络五子棋的具体代码,供大家参考,具体内容如下服务器端:import osimport socketim
- 1.返回值介绍现实生活中的场景:我给儿子10块钱,让他给我买包烟。这个例子中,10块钱是我给儿子的,就相当于调用函数时传递到参数,让儿子买烟