一.Nginx并发预估
预估算法:{(?G)*1024-system}/请求大小
(?G):表示内存大小
1024:表示内存容量标准进制
system:表示系统和服务占用的额外内存和需要预留的内存
请求大小:表示静态(一般为KB)或动态(一般为MB)的请求大小
16核32G服务器,可以抗住4万多用于负载均衡的并发,最多可以抗住5-6万,跑满文件描述符。
二.压测工具AB
1.安装压力测试工具ab
[[email protected] ~]# yum install httpd-tools -y
2.了解压测工具使用方式
[[email protected] ~]# ab -n 200 -c 2 http://127.0.0.1/
//-n总的请求次数
//-c并发请求数
//-k是否开启长连接
3.参数详解
[[email protected] conf.d]# ab -n2000 -c2 http://127.0.0.1/index.html
...
Server Software: nginx/1.12.2
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /index.html
Document Length: 19 bytes
Concurrency Level: 200
# 总花费总时长
Time taken for tests: 1.013 seconds
# 总请求数
Complete requests: 2000