1. 云栖社区>
  2. PHP教程>
  3. 正文

webbench对php和go语言的简单性能测试(含php7)

作者:用户 来源:互联网 时间:2017-11-30 13:25:57

php测试语言性能简单php7Webbench

webbench对php和go语言的简单性能测试(含php7) - 摘要: 本文讲的是webbench对php和go语言的简单性能测试(含php7),测试环境介绍网络环境:局域网操作系统:CentOS release 6.3 (Final)硬件:四核8GPHP环境:nginx+php-fpmgo语言:http.ListenAndServe端口数据监听本次测试为简单测试并未考虑到各种复杂环

测试环境介绍
网络环境:局域网
操作系统:CentOS release 6.3 (Final)
硬件:四核8G
PHP环境:nginx+php-fpm
go语言:http.ListenAndServe端口数据监听

本次测试为简单测试并未考虑到各种复杂环境测试结果仅供参考:

  整体测试结果go语言完胜,在1000并发的情况下能够0failed的表现确实让人敬佩,在并发2000的情况下也只有20个failed也不是不可接受的,由此可以看出go语言的稳定性是有绝对保障的。

  php5和php7的测试结果基本差不太多php7略优,这不是否定php7对比php5的性能没有提升而是基本没有使用到php7的特性仅仅使用了php的一个函数echo 说明不了任何php7与php5 的对比关系,请知晓!

PHP 在测试过程中表现相对较差 并发100时可以达到0failed的表现,在略提高至200-300时开始失败率增加,下面给出详细测试数据请参考!


下面是详细测试数据:

go语言直接输出数据
cpu峰值25%
[[email protected] ~]# webbench -c 1000 -t 10 http://192.168.228.58:9002/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.228.58:9002/
1000 clients, running 10 sec.
Speed=441960 pages/min, 987178 bytes/sec.
Requests: 73660 susceed, 0 failed.

[[email protected] ~]# webbench -c 2000 -t 20 http://192.168.228.58:9002/
cpu峰值30%
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.228.58:9002/
2000 clients, running 20 sec.
Speed=548214 pages/min, 1222944 bytes/sec.
Requests: 182509 susceed, 229 failed.


go语言接收参数并输出参数内容测试结果如下:
CPU峰值 35%
[[email protected] ~]# webbench -c 1000 -t 10 http://192.168.228.58:9002/alun
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.228.58:9002/alun
1000 clients, running 10 sec.
Speed=604788 pages/min, 1372104 bytes/sec.
Requests: 100798 susceed, 0 failed.

================================================================

php5.3.1直接echo("hello,word")访问测试结果如下:
CPU峰值46%
[[email protected] ~]# webbench -c 1000 -t 10 http://dh.alun.com/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://dh.alun.com/
1000 clients, running 10 sec.
Speed=331242 pages/min, 865823 bytes/sec.
Requests: 55149 susceed, 58 failed.

CPU峰值45%
[[email protected] ~]# webbench -c 2000 -t 20 http://dh.alun.com/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://dh.alun.com/
2000 clients, running 20 sec.

Speed=312702 pages/min, 814586 bytes/sec.
Requests: 103769 susceed, 465 failed.


php5.3.1接收参数并输出参数内容测试结果如下:
CPU峰值43%
[[email protected] ~]# webbench -c 2000 -t 20 http://dh.alun.com/?name=alun
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://dh.alun.com/?name=alun
2000 clients, running 20 sec.
Speed=264783 pages/min, 706411 bytes/sec.
Requests: 87755 susceed, 506 failed.

================================================================

php7.1.9直接输出echo
CPU峰值35%
[[email protected] ~]# webbench -c 2000 -t 20 http://dh.alun.com/?name=alun
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://dh.alun.com/?name=alun
2000 clients, running 20 sec.

Speed=319122 pages/min, 906607 bytes/sec.
Requests: 105900 susceed, 474 failed.


CPU峰值31%
[[email protected] ~]# webbench -c 1000 -t 20 http://dh.alun.com/?name=alun
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://dh.alun.com/?name=alun
1000 clients, running 20 sec.
Speed=365955 pages/min, 1041082 bytes/sec.
Requests: 121765 susceed, 220 failed.


php7.1.9 带参数输出
[[email protected] ~]# webbench -c 2000 -t 20 http://dh.alun.com/?name=alun
CPU峰值31%
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://dh.alun.com/?name=alun
2000 clients, running 20 sec.
Speed=246021 pages/min, 724363 bytes/sec.
Requests: 81548 susceed, 459 failed.

php7-fpm配置:
pm.max_children = 100
pm.start_servers = 30
pm.min_spare_servers = 20
pm.max_spare_servers = 100
pm.max_requests = 500

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索php , 测试 , 语言 , 性能 , 简单 , php7 Webbench ,以便于您获取更多的相关知识。