Centos7安装ab(Apache Benchmark)测试工具及使用

  • Apache Benchmark简称AB

一、安装

yum install -y httpd-tools

二、创建Post请求测试文件

  • 创建文件
vim postfile
  • 添加参数文件
  • &不删除
proid=0101&
  1. 测试高并发
  2. -n 请求总数 -c 并发数 -p post请求参数文件 -T application/x-www-form-urlencoded(post/put请求头) 请求地址
ab -n 1000 -c 100 -p ~/postfile -T application/x-www-form-urlencoded http://192.168.43.7:8090/api/doseckill/1111/0101
  1. 测试连接超时
  2. 修改连接超时时间
# 通常设置为5000
spring.redis.timeout= 100
  1. 发送请求
ab -n 1000 -c 200 -p ~/postfile -T application/x-www-form-urlencoded http://192.168.43.7:8090/api/doseckill/1111/0101

三、问题

  • 问题一
  • 此时发生超卖问题,库存数量为负
  • 问题二
  • 连接超时
2022-05-19 13:05:05.544 ERROR 31180 --- [io-9090-exec-85] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: Command timed out after 100 millisecond(s)] with root cause

io.lettuce.core.RedisCommandTimeoutException: Command timed out after 100 millisecond(s)

  • 报错
  • Command timed out after 100 millisecond(s)
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐