美文网首页
ab压力测试之post与get请求 --- 2022-08-31

ab压力测试之post与get请求 --- 2022-08-31

作者: 一位先生_ | 来源:发表于2022-08-31 10:06 被阅读0次

    安装ab工具

     yum install httpd-tools 
    

    参数说明

    -n:执行的请求个数,默认时执行一个请求

    -c:一次产生的请求个数,即并发个数

    -p:模拟post请求,文件格式为gid=2&status=1,配合-T使用

    -T:post数据所使用的Content-Type头信息,如果-T 'application/x-www-form-urlencoded'

    1.模拟get请求
    直接在url后面带参数即可

    ab -c 10 -n 10 http://www.test.api.com/?gid=2
    

    2.模拟post请求

    在当前目录下创建一个文件post.txt

    编辑文件post.txt写入

    cid=4&status=1

    相当于post传递cid,status参数

    ab -n 100  -c 10 -p 'post.txt' -T 'application/x-www-form-urlencoded' 'http://test.api.com/ttk/auth/info/'
    

    相关文章

      网友评论

          本文标题:ab压力测试之post与get请求 --- 2022-08-31

          本文链接:https://www.haomeiwen.com/subject/ksqdnrtx.html