【发布时间】:2020-02-24 00:26:02
【问题描述】:
我正在处理 WebGoat 上的一些挑战,我需要对服务器进行暴力请求攻击。我在 bash 中编写了一个脚本(使用 curl)。但是,我在网上找到了一个类似的用python编写的脚本,当我运行它时,python脚本能够以更快的速度运行攻击。
因此,我想出了一个小的基准测试实验。我将使用以下脚本向该容器发出请求,并使用time 对性能进行基准测试。
$ cat test_curl
#!/usr/bin/env bash
for i in {1..1000}; do
curl -s -o /dev/null 'http://localhost:8080/WebGoat/login'
done
$ cat test_wget
#!/usr/bin/env bash
for i in {1..1000}; do
wget -q -O /dev/null 'http://localhost:8080/WebGoat/login'
done
$ cat test_request
#!/usr/bin/env python3
import requests
for i in range(1, 1001):
requests.get('http://localhost:8080/WebGoat/login')
$ time ./test_request
real 0m4.240s
user 0m2.136s
sys 0m0.125s
$ time ./test_wget
real 0m4.623s
user 0m1.752s
sys 0m0.731s
$ time ./test_curl
real 0m17.907s
user 0m7.420s
sys 0m3.692s
总之,当我提出大量请求时,我是否应该避免使用curl?似乎python-requests 在这里脱颖而出。有人可以验证我的结论吗?我错过了什么吗?
有人知道curl 和wget 在性能上的巨大差异吗?
似乎几年前在curl 和wget here 之间进行了类似的实验。但在性能上仍然存在明显差异。
【问题讨论】:
标签: curl python-requests wget