模拟1,000,000 次请求:
从上表中可以看出http2.0相对http1.1节省近28s的返回时间
cpu(us+sy)平均:82.51%
cpu(us+sy)平均:63.09%
测试http1.1是使用了apache的ab命令;
测试http2.0是使用了nghttp2的h2load命令
- windows
-
下载文件
-
安装文件
双击exe文件,一路向下
-
配置环境变量
我的电脑----》右键“属性”---》高级系统设置---》环境变量---》系统变量 新建系统变量,变量名:APACHE_HOME,变量值:apache安装的目录;并修改Path的值(添加apache的系统变量);
-
- Linux
- Centos/RedHat
yum install apache
- ab是apache自带的命令,安装后可以直接使用
- Ubuntu/Debian
apt-get install apache2
- Centos/RedHat
- OSX(darwin)
brew install apache2
OSX系统默认已经安装了apache2,ab命令在/usr/sbin/ab
ab -k -t 180 -c 6 -n 1000000 http://172.16.37.66/index.html
- -k 使用http的 KeepAlive属性,保持连接处于活动状态
- -t 超时时间
- -c 并发数
- -n 请求数量
- Linux
- Centos/RedHat
- 6.8
- 下载最新epel-release rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- 安装epel-release rpm
rpm -Uvh epel-release*rpm
- 安装nghttp2
yum install nghttp2
- 7.x
- 更新yum仓库
yum update
- 安装nghttp2
yum install nghttp2
- 6.8
- Centos/RedHat
h2load -c 6 -T 180 -n 1000000 https://172.16.37.66/index.html
- -c 并发数
- -T 超时时间限制
- -n 请求数量