linux-ab

 linux-shell  shell  ab


安装配置

sudo apt -y install apache2-utils

参数说明

  • [ -c concurrency ] Number of multiple requests to perform at a time.
  • [ -n requests ] Number of requests to perform for the benchmarking session.

使用示例

# 100个并发用户持续3秒向服务端发出请求
ab -c 100 -t 3    http://127.0.0.1:9999/

# 100个并发用户总共向服务端发出1000个请求
ab -c 100 -n 1000 http://127.0.0.1:9999/

80/20峰值公式:80%的业务是在20%的业务时间内完成的 假如A接口每天接收50000个请求,那么A接口的指标应该是(50000*80%)/(3600*8*20%)=28 request/s 因此,使用ab进行压力测试:

ab -n 50000 -c 30 http://www.yourdomain.com/

ls -alF /dev/*random crw-rw-rw- 1 root wheel 0x11000000 8 29 17:49 /dev/random crw-rw-rw- 1 root wheel 0x11000001 8 24 14:58 /dev/urandom