php 10000并发服务器,MixPHP 与原生 PHP 并发压力测试
PHP 性能最好的应该就是原生代码了吧,真的么?MixPHP 是基于 Swoole 扩展的高性能 PHP 框架,今天我来做个对比测试,一行代码 VS 六千多行代码。
环境
虚拟机: 4 核,1G
使用 ab 工具压测,命令:ab -n 10000 -c 300 URL
原生 PHP
Apache worker模式,mpm配置如下:
ServerLimit 50
ThreadLimit 200
StartServers 5
MaxClients 5000
MinSpareThreads 25
MaxSpareThreads 500
ThreadsPerChild 100
MaxRequestsPerChild 0
只有一行代码,输出一个 Hello World。
echo 'Hello World';
MixPHP
默认控制器代码如下,输出一个 Hello World。
public function actionIndex()
{
return 'Hello World';
}
开始测试
首先测试原生 PHP,QPS: 1147.96
C:\Server\apache24vc11\bin>ab -n 10000 -c 300 http://www.p.com/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.p.com (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: Apache/2.2.32
Server Hostname: www.p.com
Server Port: 80
Document Path: /
Document Length: 9 bytes
Concurrency Level: 300
Time taken for tests: 8.711 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 2010000 bytes
HTML transferred: 90000 bytes
Requests per second: 1147.96 [#/sec] (mean)
Time per request: 261.333 [ms] (mean)
Time per request: 0.871 [ms] (mean, across all concurrent requests)
Transfer rate: 225.33 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.5 1 32
Processing: 10 254 23.0 257 298
Waiting: 4 142 71.9 142 278
Total: 10 255 23.0 258 299
Percentage of the requests served within a certain time (ms)
50% 258
66% 260
75% 262
80% 263
90% 267
95% 272
98% 279
99% 288
100% 299 (longest request)
然后测试 MixPHP,QPS: 1296.35
C:\Server\apache24vc11\bin>ab -n 10000 -c 300 http://www.v.com:9501/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.v.com (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: swoole-http-server
Server Hostname: www.v.com
Server Port: 9501
Document Path: /
Document Length: 12 bytes
Concurrency Level: 300
Time taken for tests: 7.714 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 1600000 bytes
HTML transferred: 120000 bytes
Requests per second: 1296.35 [#/sec] (mean)
Time per request: 231.419 [ms] (mean)
Time per request: 0.771 [ms] (mean, across all concurrent requests)
Transfer rate: 202.55 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.4 1 5
Processing: 10 227 23.0 231 261
Waiting: 7 138 61.8 142 250
Total: 11 228 23.0 231 262
Percentage of the requests served within a certain time (ms)
50% 231
66% 235
75% 236
80% 237
90% 241
95% 243
98% 245
99% 247
100% 262 (longest request)
结论
是不是测试结果让你惊讶,一行代码 VS 六千多行代码,竟然是 MixPHP 框架并发性能更强。
我来分析下原因:MixPHP 框架的核心组件全部都是常驻内存的,也就是说,六千多行代码在每次请求时,实际上只执行了其中很小的一部分代码,当然也还是要比一行代码多很多的,但是为何性能上还是要更强,这个就要归功于 swoole_http_server 了,在并发性能上他是优于 Apache 的,所以才使得 MixPHP 的性能可以超越原生 PHP。
ITEM
DESC
原生 PHP
1147.96 QPS
MixPHP
1296.35 QPS
php 10000并发服务器,MixPHP 与原生 PHP 并发压力测试相关推荐
- 【Linux】云服务器部署网站后的ab压力测试,服务器网络接口io情况、进程cpu占用等有关情况查看
压测 一.windows端压力测试工具 1.1 下载 1.2 安装 1.3 使用 二.Linux服务端监控 一.windows端压力测试工具 1.1 下载 主要使用ab(apache bench)工具 ...
- windows web服务器性能测试工具,网站性能Web压力测试工具webbench
webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便. 1.适用系统:Linux 2.编译安装: wget http:/ ...
- Apache服务器下使用 ab 命令进行压力测试
ab是Apache超文本传输协议(HTTP)的性能测试工具. 其设计意图是描绘当前所安装的Apache的执行性能,主要是显示你安装的Apache每秒可以处理多少个请求. #ab -v可以看出其基本信息 ...
- 服务器终端性能测试之GPU burn压力测试
GPU burn 测试GPU 1.下载软件 wget https://codeload.github.com/wilicc/gpu-burn/zip/master 2.解压缩 unzip gpu-bu ...
- 网络基础+Socket编程+高并发服务器
网络编程 P1 复习 Linux 网络编程 P2 信号量生产者复习 P3 协议 P4 七层模型和四层模型及代表协议 P5 网络传输数据封装流程 P6 以太网帧和ARP请求 P7 IP 协议 P8 TC ...
- 如何使用 Go 语言搭建企业级高并发服务器?
每到节假日和过年,需要外出通行的人几乎都会遇到一个问题:抢火车票!当全国上亿人都在固定的时间段抢票,服务器动辄就要承受上百万级并发的情况时,你就会明白,一个支持高并发的服务器架构有多重要! 在后端程序 ...
- C++网络编程(四):多进程并发服务器
部分内容转自Linux并发服务器编程之多进程并发服务器. 目录 前言 创建进程 Linux下的进程 进程创建函数fork与vfork exec函数 使用fork函数实现多进程并发服务器 分割I/O程序 ...
- [Linux 高并发服务器]GDB调试
[Linux 高并发服务器]GDB调试 [Linux 高并发服务器]GDB调试 [Linux 高并发服务器]GDB调试 GDB是什么 预先准备 基本命令 例子 进入和退出gdb 获取帮助 查看文件代码 ...
- Linux网络编程3——多进/线程并发服务器
视频链接 黑马程序员-Linux网络编程_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV1iJ411S7UA?p=37 目录 一.高并发服务器 1.1 图 ...
最新文章
- 没有安装python如何使用anaconda运行python命令行
- LINUX-NAT(二)
- Navicat for Oracle Cannot load OCI DLL
- python和c哪个好学-C/C++和Python哪个更有前景?
- 概率论-3.5 条件分布与条件期望
- java 随机数 【指定范围】
- Qt 独立运行时伴随CMD命令窗口
- linux内核深度解析_十年磨一剑,第一本龙芯平台的Linux内核书来了
- 图片里的标志化的构造和执行
- Codeforces 1110D. Jongmah 动态规划
- Word文档,英文字母间隔非常大,解决方法
- 【lidar】单目深度估计与伪雷达点云、可视化
- java modelbus_modelbus tcp java
- JVM 重点知识点总结
- Linux查看CPU和内存使用情况
- 域名证书续期 SSL证书如何续费
- Keil中部分Error Warning解决方法记录
- Fans没信心,回家继续修行
- Serverless 架构的 N 种可能,你 Pick 谁?
- 几个常用的免费高清无版权图片网站