1fy07h 发表于 2024-10-4 13:01:04

PHP运行时性能基准测试


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">测试环境 </p>

    <span style="color: black;"><span style="color: black;">每一个</span>运行时在1或2个Docker容器中运行</span>
    <span style="color: black;"><span style="color: black;">每一个</span>容器有1个CPU和1GB RAM</span>
    <span style="color: black;">负载测试工具<span style="color: black;">位置于</span>同一Docker网络中</span>
    测试应用程序
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">Symfony<span style="color: black;">供给</span>了运行时组件。<span style="color: black;">按照</span>官方文档,它“从任何全局状态中提取引导<span style="color: black;">规律</span>,以<span style="color: black;">保证</span>应用程序<span style="color: black;">能够</span>在运行时运行,如”。这<span style="color: black;">寓意</span>着,您<span style="color: black;">能够</span><span style="color: black;">运用</span>任何您<span style="color: black;">爱好</span>的运行时来<span style="color: black;">研发</span>应用程序,但在生产中运行最高性能。<span style="color: black;">因此呢</span>,<span style="color: black;">咱们</span>不仅<span style="color: black;">能够</span><span style="color: black;">运用</span>传统的服务器运行应用程序,还<span style="color: black;">能够</span><span style="color: black;">运用</span>Swoole,AMPHP和ReactPHP等库。展望<span style="color: black;">将来</span>,最后两人被排除在竞争之外。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">负载测试工具 </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">K6用于运行负载测试。<span style="color: black;">每一个</span>运行时运行3次,30秒内有<span style="color: black;">十、</span>100和1000个并发连接。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">运行时</span></strong></span></p>

    <span style="color: black;">Apache(prefork模式)+ mod_php</span>
    <span style="color: black;">Apache(事件模式)+ PHP-FPM</span>
    <span style="color: black;">Nginx + PHP-FPM</span>
    <span style="color: black;">Nginx Unit应用服务器</span>
    <span style="color: black;">Nginx Unit应用服务器</span>
    <span style="color: black;">Nginx + Roadrunner(fcgi模式)</span>
    <span style="color: black;">FrankenPHP</span>
    <span style="color: black;">FrankenPHP(worker模式)</span>
    <span style="color: black;">Swoole</span>

    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">所有运行时都基于官方Docker镜像。<span style="color: black;">倘若</span>不<span style="color: black;">运用</span>镜像,则在构建过程中将应用程序的代码复制到镜像中。PHP 8.3无处不在,除了Nginx Unit。2024年初,Nginx Unit支持的最高PHP版本为8.2。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">不幸的是,我<span style="color: black;">无</span>找到与Symfony 7兼容的最新版本的ReactPHP和AMPHP运行时。PHPPM GitHub和Dockerhub看起来都被抛弃了。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">应用以下PHP和Symfony设置:</span></span></p>

    <span style="color: black;"><span style="color: black;">运用</span>php.ini-production(附带官方Docker容器)</span>
    <span style="color: black;">已启用Opcache</span>
    <span style="color: black;">启用JIT</span>
    <span style="color: black;"><span style="color: black;">按照</span>Symfony最佳实践配置preload</span>
    <span style="color: black;">Composer自动加载器已优化</span>
    <span style="color: black;">Symfony在生产模式下运行</span>
    <span style="color: black;">服务容器转储到单个文件</span>
    <span style="color: black;">Symfony缓存在容器构建<span style="color: black;">时期</span>预热</span>

    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">应用程序代码以及容器配置<span style="color: black;">能够</span>在GitHub https://github.com/DimDev/php-runtimes-benchmark上找到。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">结果 </p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="//q3.itc.cn/q_70/images03/20240701/68ef7bf3a99e4fc48886e37a13592d6d.jpeg" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="//q8.itc.cn/q_70/images03/20240701/a12fdd5df12d48a79ad07d9d911542ed.jpeg" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="//q1.itc.cn/q_70/images03/20240701/5fef4f88a1bb48bcbd3c0dc2b7a0d1a6.jpeg" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="//q9.itc.cn/q_70/images03/20240701/851c98d0234b4fafaba252df3bfbdec4.jpeg" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="//q4.itc.cn/q_70/images03/20240701/32260599fb3048e296b06fda4bd0ba62.jpeg" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="//q9.itc.cn/q_70/images03/20240701/039183b2ef9d4543b89e0681a3760f92.jpeg" style="width: 50%; margin-bottom: 20px;"><a style="color: black;"><span style="color: black;">返回<span style="color: black;">外链论坛: http://www.fok120.com</span>,查看<span style="color: black;">更加多</span></span></a></p>

    <span style="color: black;">001_Apache+mod_php和002_Apache + PHP-FPM显示了几乎相同的结果。</span>
    <span style="color: black;">003_Nginx+PHP-FPM在工作负载较低(并发10和100)时非常接近001_Apache+mod_php和002_Apache + PHP-FPM。</span>
    <span style="color: black;">003_Nginx+PHP-FPM在并发量为1000时,能够服务的请求数是Apache堆栈的2倍</span>
    <span style="color: black;">004_Nginx单元。首先-哇!!它比传统和最流行的003_Nginx+PHP-FPM快3倍</span>
    <span style="color: black;">我不认为005_Roadrunner和006_Nginx+Roadrunner之间有很大的区别</span>
    <span style="color: black;">尽管如此,基于Roadrunner的堆栈比003_Nginx+PHP-FPM快2倍以上</span>
    <span style="color: black;">007_FrankenPHP(非工作模式)从性能<span style="color: black;">方向</span>来看非常接近003_Nginx+PHP-FPM</span>
    <span style="color: black;">008_FrankenPHP(worker mode). Double WOW!我不相信从<span style="color: black;">第1</span>次尝试和运行负载测试3或4倍。<span style="color: black;">因此呢</span>,当发送1000个并发请求时,FrankenPHP(工人模式)比Nginx+PHP-FPM快10倍。<span style="color: black;">同期</span>,<span style="color: black;">亦</span>面临着一个问题。无法用php-ini. production<span style="color: black;">起步</span>容器。</span>
    <span style="color: black;">009_swoole -<span style="color: black;">亦</span>是双重WOW!.几乎与008_FrankenPHP(wm)相同的速度。非常快。<span style="color: black;">然则</span>,请记住,您的代码应该<span style="color: black;">调节</span>为与Swoole<span style="color: black;">一块</span>运行。<span style="color: black;">针对</span>Symfony,<span style="color: black;">咱们</span>有一个bundle,它扩展了symfony/runtime组件。</span>


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">责任编辑:网友投稿</span></p>




j8typz 发表于 2024-10-6 12:47:19

谷歌外贸网站优化技术。

4zhvml8 发表于 2024-11-10 03:16:43

你的留言真是温暖如春,让我感受到了无尽的支持与鼓励。
页: [1]
查看完整版本: PHP运行时性能基准测试