在pods中添加有关httpclient的 压力测试 & 监控
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | PS D:\****.WebSite> docker exec -ti d630dc731617 /bin/bash root@d630dc731617: /app # apt-get install net-tools Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: net-tools 0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded. Need to get 248 kB of archives. After this operation, 963 kB of additional disk space will be used. Get:1 http: //mirrors .163.com /debian stretch /main amd64 net-tools amd64 1.60+git20161116.90da8a0-1 [248 kB] Fetched 248 kB in 6s (35.8 kB /s ) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package net-tools. (Reading database ... 21948 files and directories currently installed.) Preparing to unpack ... /net-tools_1 .60+git20161116.90da8a0-1_amd64.deb ... Unpacking net-tools (1.60+git20161116.90da8a0-1) ... Setting up net-tools (1.60+git20161116.90da8a0-1) ... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | root@d630dc731617: /app # ss -o state ESTABLISHED|wc -l #替代netstat -ant |grep 172.16.32.80:8080|grep -i "ESTABLISHED"|wc -l 0 root@d630dc731617: /app # ss -o state close-wait|wc -l #替代netstat -ant |grep 172.16.32.80:8080|grep -i "CLOSE_WAIT"|wc -l 0 root@d630dc731617: /app # apt-get install apache2-utils Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libapr1 libaprutil1 The following NEW packages will be installed: apache2-utils libapr1 libaprutil1 0 upgraded, 3 newly installed, 0 to remove and 4 not upgraded. Need to get 400 kB of archives. After this operation, 905 kB of additional disk space will be used. Do you want to continue ? [Y /n ] y Get:1 http: //mirrors .163.com /debian stretch /main amd64 libapr1 amd64 1.5.2-5 [96.6 kB] Get:2 http: //mirrors .163.com /debian stretch /main amd64 libaprutil1 amd64 1.5.4-3 [85.8 kB] Get:3 http: //mirrors .163.com /debian stretch /main amd64 apache2-utils amd64 2.4.25-3+deb9u8 [218 kB] Fetched 400 kB in 0s (1,369 kB /s ) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package libapr1:amd64. (Reading database ... 22004 files and directories currently installed.) Preparing to unpack ... /libapr1_1 .5.2-5_amd64.deb ... Unpacking libapr1:amd64 (1.5.2-5) ... Selecting previously unselected package libaprutil1:amd64. Preparing to unpack ... /libaprutil1_1 .5.4-3_amd64.deb ... Unpacking libaprutil1:amd64 (1.5.4-3) ... Selecting previously unselected package apache2-utils. Preparing to unpack ... /apache2-utils_2 .4.25-3+deb9u8_amd64.deb ... Unpacking apache2-utils (2.4.25-3+deb9u8) ... Setting up libapr1:amd64 (1.5.2-5) ... Processing triggers for libc-bin (2.24-11+deb9u4) ... Setting up libaprutil1:amd64 (1.5.4-3) ... Setting up apache2-utils (2.4.25-3+deb9u8) ... Processing triggers for libc-bin (2.24-11+deb9u4) ... root@d630dc731617: /app # env |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | root@d630dc731617: /app # curl -X GET "http://localhost:5001/api/Ops/TestProxy" -H "accept: text/plain" curl: (7) Failed to connect to localhost port 5001: Connection refused root@d630dc731617: /app # curl -X GET "http://localhost/api/Ops/TestProxy" -H "accept: text/plain" { "opSucess" : true , "result" :3020000, "resultContent" : true , "type" : "System.Boolean" , "isArray" : false }root@d630dc731617: /app # root@d630dc731617: /app # ab -n 1 -c 1 http://localhost/api/Ops/TestProxy This is ApacheBench, Version 2.3 <$Revision: 1757674 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http: //www .zeustech.net/ Licensed to The Apache Software Foundation, http: //www .apache.org/ Benchmarking localhost (be patient)..... done Server Software: Kestrel Server Hostname: localhost Server Port: 80 Document Path: /api/Ops/TestProxy Document Length: 95 bytes Concurrency Level: 1 Time taken for tests: 1.603 seconds Complete requests: 1 Failed requests: 0 Total transferred: 279 bytes HTML transferred: 95 bytes Requests per second: 0.62 [ #/sec] (mean) Time per request: 1602.877 [ms] (mean) Time per request: 1602.877 [ms] (mean, across all concurrent requests) Transfer rate: 0.17 [Kbytes /sec ] received Connection Times (ms) min mean[+ /-sd ] median max Connect: 0 0 0.0 0 0 Processing: 1603 1603 0.0 1603 1603 Waiting: 1603 1603 0.0 1603 1603 Total: 1603 1603 0.0 1603 1603 |
1 2 3 4 5 | root@d630dc731617: /app # ss -o state close-wait|wc -l #替代 netstat -ant |grep 172.16.32.80:8080|grep -i "CLOSE_WAIT"|wc -l 0 root@d630dc731617: /app # ss -o state ESTABLISHED|wc -l #替代netstat -ant |grep 172.16.32.80:8080|grep -i "ESTABLISHED"|wc -l 3 root@d630dc731617: /app # |
监控脚本内容::监控端点正常与异常情况
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/bash n=100 while [ $n -gt 0 ]; do sleep 10s n=$((n-1)) msg=$( netstat -ant | grep -i "CLOSE_WAIT" | wc -l) msg2=$( netstat -ant | grep -i "ESTABLISHED" | wc -l) echo "----" echo "established:$msg2" echo "CLOSE_WAIT:$msg" done |
netstat命令过时,更新如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/bin/bash n=100 while [ $n -gt 0 ]; do sleep 10s n=$((n-1)) msg=$(ss -o state ESTABLISHED| wc -l) msg2=$(ss -o state close-wait| wc -l) msg4=$(ss -o state closing| wc -l) msg5=$(ss -o state closed| wc -l) msg3=$(ss -o state time -wait| wc -l) echo "----" echo "ESTABLISHED:$msg2" echo "close-wait:$msg" echo "closing:$msg4" echo "closed:$msg5" echo "time-wait:$msg3" done |
1.copy本地文件进入pods:执行压力测试下断点的监控
2.执行压力测试
1 2 3 4 5 6 7 8 9 | PS C:\Users\panxi> docker ps #查找container PS C:\Users\panxi> docker inspect -f '{{.ID}}' 27d239cf4df9 #根据container的short id获取full id PS D:\> docker cp .\TestTCP.sh 27d239cf4df920851af22e531915a735b01f803dc57759634c9328dda81e0084: /app/a .sh #copy本地文件TestTCP.sh进入pods PS D:\> docker exec -ti 27d239cf4df9 /bin/bash #进入pods root@27d239cf4df9: /app # vi a.sh #确认文件内容 root@27d239cf4df9: /app # chmod -R u+rwx ./a.sh #设置文件权限 root@27d239cf4df9: /app # ./a.sh #执行脚本文件 root@27d239cf4df9: /app # ab -n 10000 -c 20 http://localhost/api/Ops/TestProxy3 #运行压力测试 |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步