Mac环境下,进行接口压力测试

brew install ctags # 依赖安装
wget http://blog.zyan.cc/soft/linux/webbench/webbench-1.5.tar.gz
tar -zxvf webbench-1.5.tar.gz
cd webbench-1.5
mkdir -pv /usr/local/man/man1 # 必须
sodo make && sudo make install # sudo 权限因为需要创建文件夹
liuxin@KK-MINI  ~/webbench/webbench-1.5  mkdir -pv /usr/local/man/man1
liuxin@KK-MINI  ~/webbench/webbench-1.5  sudo make && sudo makeinstall
make: Nothing to be done for `all'.
install -s webbench /usr/local/bin
install -m 644 webbench.1 /usr/local/man/man1
install -d /usr/local/share/doc/webbench
install -m 644 debian/copyright /usr/local/share/doc/webbench
install -m 644 debian/changelog /usr/local/share/doc/webbench

webbench -c 50 -t 30 http://127.0.0.1:6969/shenghuojiaofei/test

  • 系统默认会开启1500个端口,所以如果大于1500也会出错
  • 当设每秒进行800连接时候
 ✘ liuxin@KK-MINI  ~  webbench -c 800 -t 1 --get http://localhost:6969/shenghuojiaofei/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://localhost:6969/shenghuojiaofei/
800 clients, running 1 sec.
problems forking worker no. 539
fork failed.: Operation timed out
prompt_status:5: fork failed: resource temporarily unavailable
  • 解决办法是修改线程数
  • 查看mac下最大线程数
 liuxin@KK-MINI  ~  ulimit -u 10000
ulimit: value exceeds hard limit
 ✘ liuxin@KK-MINI  ~  ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       709
-n: file descriptors                4864
 liuxin@KK-MINI  ~ 

因为我用了800个所以就出错了

你可能感兴趣的:(Mac环境下,进行接口压力测试)