nginx 限制配置

nginx-----

1.nginx 正常配置& up

### 100并发测试

$ ab -c 100 -n 10000 http://testdocs.raystuner.com/docs
This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking testdocs.raystuner.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.20.1
Server Hostname:        testdocs.raystuner.com
Server Port:            80

Document Path:          /docs
Document Length:        169 bytes

Concurrency Level:      100
Time taken for tests:   13.258 seconds
Complete requests:      10000
Failed requests:        0
Non-2xx responses:      10000
Total transferred:      3740000 bytes
HTML transferred:       1690000 bytes
Requests per second:    754.24 [#/sec] (mean)
Time per request:       132.583 [ms] (mean)
Time per request:       1.326 [ms] (mean, across all concurrent requests)
Transfer rate:          275.48 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       31   64  12.8     64    1089
Processing:    34   67   8.2     66     380
Waiting:       30   54   8.8     52     115
Total:         68  131  16.5    130    1157

Percentage of the requests served within a certain time (ms)
  50%    130
  66%    134
  75%    138
  80%    141
  90%    147
  95%    152
  98%    162
  99%    168
 100%   1157 (longest request)

限制连接数NginxHttpLimitConnModule

http下
limit_conn_zone $binary_remote_addr zone=linux:10m;

location 下:
limit_conn linux 10;

###
ab -c 100 -n 10000 https://testdocs.raystuner.com/docs
This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking testdocs.raystuner.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.20.1
Server Hostname:        testdocs.raystuner.com
Server Port:            443
SSL/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
Server Temp Key:        X25519 253 bits
TLS Server Name:        testdocs.raystuner.com

Document Path:          /docs
Document Length:        169 bytes

Concurrency Level:      100
Time taken for tests:   22.641 seconds
Complete requests:      10000
Failed requests:        115
   (Connect: 0, Receive: 0, Length: 115, Exceptions: 0)
Non-2xx responses:      10000
Total transferred:      3751035 bytes
HTML transferred:       1693220 bytes
Requests per second:    441.68 [#/sec] (mean)
Time per request:       226.410 [ms] (mean)
Time per request:       2.264 [ms] (mean, across all concurrent requests)
Transfer rate:          161.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       96  181  36.7    174    1211
Processing:    27   43  16.5     34     386
Waiting:       27   42  16.3     34     377
Total:        128  224  47.5    213    1263

Percentage of the requests served within a certain time (ms)
  50%    213
  66%    233
  75%    248
  80%    259
  90%    285
  95%    309
  98%    336
  99%    355
 100%   1263 (longest request)

限制请求频率NginxHttpLimitReqModule

http { }下
limit_req_zone $binary_remote_addr zone=linux:10m rate=30r/m;

server { } location下
limit_req  zone=linux;
 ab -c 100 -n 10000 https://testdocs.raystuner.com/docs
This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking testdocs.raystuner.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.20.1
Server Hostname:        testdocs.raystuner.com
Server Port:            443
SSL/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
Server Temp Key:        X25519 253 bits
TLS Server Name:        testdocs.raystuner.com

Document Path:          /docs
Document Length:        169 bytes

Concurrency Level:      100
Time taken for tests:   20.986 seconds
Complete requests:      10000
Failed requests:        9989
   (Connect: 0, Receive: 0, Length: 9989, Exceptions: 0)
Non-2xx responses:      10000
Total transferred:      3839901 bytes
HTML transferred:       1969692 bytes
Requests per second:    476.52 [#/sec] (mean)
Time per request:       209.857 [ms] (mean)
Time per request:       2.099 [ms] (mean, across all concurrent requests)
Transfer rate:          178.69 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       88  164  48.3    159    1246
Processing:    27   43  13.2     39     318
Waiting:       27   41  12.7     34     318
Total:        116  207  54.2    199    1318

Percentage of the requests served within a certain time (ms)
  50%    199
  66%    215
  75%    227
  80%    235
  90%    257
  95%    276
  98%    299
  99%    321
 100%   1318 (longest request)

限制每分钟只能送出 30 个请求,也就是说每个请求之间至少间隔 2 秒,有20s请求,所以成功就10个左右
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值