页面“Linux端口扫描工具nmap and nwatch”与“关于压力测试和并发的那些事儿”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
→‎nmap
 
→‎ab
 
第1行: 第1行:
==nmap==
+
== start==
 +
===首先是基本知识点===
 +
[http://www.ha97.com/5095.html 系统吞吐量(TPS)、用户并发量、性能测试概念和公式]
 +
 
 +
 
 +
===这两个比较偏向web 测试===
 +
 
 +
[http://wiki.linuxchina.net/index.php?title=%E7%BD%91%E7%AB%99%E8%BF%90%E7%BB%B4#chapter_5_.E6.B5.8B.E8.AF.95.E8.AF.84.E4.BC.B0 详情测试评估请见]
 +
 
 +
==并发承载==
 
<pre>
 
<pre>
nmap的使用方法
+
10W 活跃用户  访问4个页面  一次页面加3次接口
  
下面是Nmap支持的四种最基本的扫描方式:
+
10w*4*4 =160W
  
    * TCP connect()端口扫描(-sT参数)。
+
一般人睡觉8个小时 so 一天 24-8=16h
 +
10W日活 * 4次访问数*每次4个接口或者页面 = 160W
 +
16h*60min*60s= 57 600 s
 +
160w/57600=28QPS OR TPS
  
    * TCP同步(SYN)端口扫描(-sS参数)。
+
真实情况下
 +
5 分钟内的活跃用户为1000
 +
100*4*4=1600
 +
1600/(5*6)=53QPS
  
    * UDP端口扫描(-sU参数)。
+
反来说
 +
如果一个系统的qps 100  一天能顶的访问量为 100*60*60*24=8 640 000 也就是864W
  
    * Ping扫描(-sP参数)
 
  
如果要勾画一个网络的整体情况,Ping扫描和TCP SYN扫描最为实用。
+
ps
 +
TPS:Transactions Per Second(每秒传输的事物处理个数)
  
    * Ping扫描通过发送ICMP(Internet Control Message Protocol,Internet控制消息协议)回应请求数据包和TCP应答(Acknowledge,简写ACK)数据包,确定主机的状态,非常适合于检测指定网段内正在运行的主机数量。
+
QPS(TPS):每秒钟 request/事务 数量,在互联网领域,指每秒响应请求数(指http请求)
 +
</pre>
 +
==常用的压力测试工具==
 +
===ab===
 +
<pre> ab  参数有时比较 搞笑
 +
10000 请求100并发
 +
ab -n  10000 -c  100 ip
  
    * TCP SYN扫描一下子不太好理解,但如果将它与TCP connect()扫描比较,就很容易看出这种扫描方式的特点。在TCP connect()扫描中,扫描器利用操作系统本身的系统调用打开一个完整的TCP连接也就是说,扫描器打开了两个主机之间的完整握手过程(SYN, SYN-ACK,和ACK)。一次完整执行的握手过程表明远程主机端口是打开的。
+
Usage: ab [options] [http[s]://]hostname[:port]/path
 +
ab -n 100 -c 10 http://192.168.88.173/index.html
  
    * TCP SYN扫描创建的是半打开的连接,它与TCP connect()扫描的不同之处在于,TCP SYN扫描发送的是复位(RST)标记而不是结束ACK标记(即,SYN,SYN-ACK,或RST):如果远程主机正在监听且端口是打开的,远程主机用 SYN-ACK应答,Nmap发送一个RST;如果远程主机的端口是关闭的,它的应答将是RST,此时Nmap转入下一个端口。
 
  
-sS 使用SYN+ACK的方法,使用TCP SYN,
+
ab -n 1000  -c 1000  http://192.168.88.173/index.html
  
-sT 使用TCP的方法, 3次握手全做
+
可能就动不了了
 +
ab -n 10000  -c 10000  http://192.168.88.173/index.html
  
-sU 使用UDP的方法
+
eg
 +
# ab -n 1000  -c 1000  http://192.168.88.173/index.html
 +
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
 +
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
 +
Licensed to The Apache Software Foundation, http://www.apache.org/
  
-sP ICMP ECHO Request 送信,有反应的端口进行调查
+
Benchmarking 192.168.88.173 (be patient)
 +
Completed 100 requests
 +
Completed 200 requests
 +
Completed 300 requests
 +
Completed 400 requests
 +
Completed 500 requests
 +
Completed 600 requests
 +
Completed 700 requests
 +
Completed 800 requests
 +
Completed 900 requests
 +
Completed 1000 requests
 +
Finished 1000 requests
  
-sF FIN SCAN
 
  
-sX
+
Server Software:        Apache
 +
Server Hostname:        192.168.88.173
 +
Server Port:            80
  
-sN 全部FLAG OFF的无效的TCP包送信,根据错误代码判断端口情况
+
Document Path:          /index.html
 +
Document Length:        196 bytes
  
-P0 无视ICMP ECHO request的结果,SCAN
+
Concurrency Level:      1000
 +
Time taken for tests:  0.404 seconds
 +
Complete requests:      1000
 +
Failed requests:        0
 +
Non-2xx responses:      1000
 +
Total transferred:      360000 bytes
 +
HTML transferred:      196000 bytes
 +
Requests per second:    2473.61 [#/sec] (mean)
 +
Time per request:      404.268 [ms] (mean)
 +
Time per request:      0.404 [ms] (mean, across all concurrent requests)
 +
Transfer rate:          869.63 [Kbytes/sec] received
  
-p scan port range 指定SCAN的目端口的范围
+
Connection Times (ms)
 +
              min  mean[+/-sd] median  max
 +
Connect:        1  26  23.5    18      75
 +
Processing:    13  170 108.4    234    323
 +
Waiting:        1  170 108.5    234    323
 +
Total:        14  196 128.7    246    392
  
   1-100, 或者使用25,100的方式
+
Percentage of the requests served within a certain time (ms)
 +
  50%   246
 +
  66%    279
 +
  75%    300
 +
  80%    312
 +
  90%    369
 +
  95%    380
 +
  98%    387
 +
  99%    389
 +
100%    392 (longest request)
  
-O 侦测OS(操作系统)的种类 大写的字母O
+
   
 +
</pre>
 +
[https://www.jianshu.com/p/3afa6ecca808 ab压测]
  
-oN 文件名 通常格式文件输出
+
[https://www.cnblogs.com/linjiqin/p/9058432.html 网站性能压力测试工具--apache ab使用详解]
  
-oX 文件名 通过DTD,使用XML格式输出结果
+
===siege ===
 +
<pre>
  
-oG 文件名,grep容易的格式输出
 
  
-sV 服务的程序名和版本SCAN
+
可能得修改一下配置
 +
siege -c  2000  -t 60s http:192.168.88.173
 +
 
 +
================================================================
 +
WARNING: The number of users is capped at 255.  To increase this
 +
        limit, search your .siegerc file for 'limit' and change
 +
        its value. Make sure you read the instructions there...
 +
================================================================
 +
 
 +
vim  .siege/siege.conf
 +
 
 +
# ex: limit = 1023 (default is 255)                                                                                                                                         
 +
#                                                                                                                                                                           
 +
limit = 2559
 +
 
 +
 
 +
 
 +
 
 +
 
 +
100并发  30s
 +
siege -c  100 -t 30s http:ip
 +
 +
wrk 可以lua脚本
 +
4个线程
 +
wrk -c 100 -d 30s -t 4 ip
  
  
nmap -sV -sS
 
 
</pre>
 
</pre>
  
==Linux 下查看局域网内所有主机IP和MAC==
+
https://askubuntu.com/questions/932449/siege-cannot-perform-load-testing-for-more-than-255-tests
<pre>
+
 
root@latop:~# nmap -sP 192.168.88.0/24
+
 
Starting Nmap 7.70 ( https://nmap.org ) at 2019-06-11 13:56 CST
+
[http://blog.linuxchina.net/?p=3150 介绍几款Web服务器性能压力测试工具ApacheBench(ab) Siege详解]
Nmap scan report for 192.168.88.1
+
 
Host is up (0.00019s latency).
+
[https://www.vpser.net/opt/webserver-test.html  Web服务器性能/压力测试工具http_load、webbench、ab、Siege使用教程]
MAC Address: D4:CA:6D:67:5B:B7 (Routerboard.com)
 
Nmap scan report for 192.168.88.7
 
Host is up (0.00034s latency).
 
MAC Address: AA:C1:2E:43:73:E1 (Unknown)
 
Nmap scan report for 192.168.88.8
 
Host is up (0.00015s latency).
 
MAC Address: E0:D5:5E:54:1F:49 (Giga-byte Technology)
 
Nmap scan report for 192.168.88.52
 
Host is up (0.00051s latency).
 
MAC Address: 56:CD:ED:05:84:B7 (Unknown)
 
Nmap scan report for 192.168.88.72
 
Host is up (0.00028s latency).
 
MAC Address: 00:E0:70:82:0D:ED (DH Technology)
 
Nmap scan report for 192.168.88.98
 
Host is up (0.058s latency).
 
MAC Address: B8:27:EB:EE:BA:12 (Raspberry Pi Foundation)
 
Nmap scan report for 192.168.88.4
 
Host is up.
 
Nmap done: 256 IP addresses (7 hosts up) scanned in 2.59 seconds
 
  
 +
===如果你是 windows .net  请用 ===
  
</pre>
+
[http://zhang-ps.iteye.com/blog/2297318  如何测试一个网站的性能(并发数)]
  
== 参考==
+
[http://www.cnblogs.com/zhili/articles/StreeTool.html ASP.NET压力测试]
https://my.oschina.net/jccpp/blog/156691
 
  
[http://blog.csdn.net/keepsmi1e/article/details/9370049 Linux 下查看局域网内所有主机IP和MAC(及nmap的用法)]
+
[https://www.zhihu.com/question/40527273 如何对Asp.Net网站做并发测试?]
  
 +
== 参考==
 +
[https://segmentfault.com/q/1010000000588140  如何测试一个web网站的性能(并发数)?]
  
 +
[http://wetest.qq.com/lab/view/177.html  早知道早幸福——从压测工具谈并发、压力、吞吐量]
  
[[category:Security]]
+
[https://www.cnblogs.com/zhengah/p/5160772.html 如何估算网站日承受最大访问PV]
  
[[category:ops]]
+
[[category:ops]]

2021年4月24日 (六) 08:49的版本

start

首先是基本知识点

系统吞吐量(TPS)、用户并发量、性能测试概念和公式


这两个比较偏向web 测试

详情测试评估请见

并发承载

10W 活跃用户  访问4个页面  一次页面加3次接口

10w*4*4 =160W 

一般人睡觉8个小时 so 一天 24-8=16h
10W日活 * 4次访问数*每次4个接口或者页面 = 160W 
16h*60min*60s= 57 600 s
160w/57600=28QPS OR TPS

真实情况下
5 分钟内的活跃用户为1000
100*4*4=1600
1600/(5*6)=53QPS

反来说
如果一个系统的qps 100   一天能顶的访问量为 100*60*60*24=8 640 000 也就是864W 


ps
TPS:Transactions Per Second(每秒传输的事物处理个数)

 QPS(TPS):每秒钟 request/事务 数量,在互联网领域,指每秒响应请求数(指http请求)

常用的压力测试工具

ab

 ab  参数有时比较 搞笑
 10000 请求100并发
 ab -n  10000 -c  100 ip 

Usage: ab [options] [http[s]://]hostname[:port]/path
ab -n 100 -c 10 http://192.168.88.173/index.html


ab -n 1000  -c 1000  http://192.168.88.173/index.html

可能就动不了了 
ab -n 10000  -c 10000  http://192.168.88.173/index.html

eg 
# ab -n 1000  -c 1000  http://192.168.88.173/index.html
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.88.173 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache
Server Hostname:        192.168.88.173
Server Port:            80

Document Path:          /index.html
Document Length:        196 bytes

Concurrency Level:      1000
Time taken for tests:   0.404 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      360000 bytes
HTML transferred:       196000 bytes
Requests per second:    2473.61 [#/sec] (mean)
Time per request:       404.268 [ms] (mean)
Time per request:       0.404 [ms] (mean, across all concurrent requests)
Transfer rate:          869.63 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   26  23.5     18      75
Processing:    13  170 108.4    234     323
Waiting:        1  170 108.5    234     323
Total:         14  196 128.7    246     392

Percentage of the requests served within a certain time (ms)
  50%    246
  66%    279
  75%    300
  80%    312
  90%    369
  95%    380
  98%    387
  99%    389
 100%    392 (longest request)

 
 

ab压测

网站性能压力测试工具--apache ab使用详解

siege



可能得修改一下配置
 siege -c  2000  -t 60s http:192.168.88.173

================================================================
WARNING: The number of users is capped at 255.  To increase this
         limit, search your .siegerc file for 'limit' and change
         its value. Make sure you read the instructions there...
================================================================

vim  .siege/siege.conf

# ex: limit = 1023 (default is 255)                                                                                                                                          
#                                                                                                                                                                            
limit = 2559





 100并发  30s
 siege -c  100 -t 30s http:ip 
 
 wrk 可以lua脚本 
 4个线程
 wrk -c 100 -d 30s -t 4 ip 


https://askubuntu.com/questions/932449/siege-cannot-perform-load-testing-for-more-than-255-tests


介绍几款Web服务器性能压力测试工具ApacheBench(ab) Siege详解

Web服务器性能/压力测试工具http_load、webbench、ab、Siege使用教程

如果你是 windows .net 请用

如何测试一个网站的性能(并发数)

ASP.NET压力测试

如何对Asp.Net网站做并发测试?

参考

如何测试一个web网站的性能(并发数)?

早知道早幸福——从压测工具谈并发、压力、吞吐量

如何估算网站日承受最大访问PV