我知道这是一则旧文章,但有人可能仍需要它。
如果要进行负载测试但要使用python,则应使用locust之类的工具:http :
//locust.io/
这是我的解决方案,它在10秒内产生10,000个请求:
所需软件包: sudo pip install grequests
码:
import grequestsimport timestart_time = time.time()# Create a 10000 requestsurls = ['http://www.google.co.il']*10000rs = (grequests.head(u) for u in urls)# Send them.grequests.map(rs)print time.time() - start_time # Result was: 9.66666889191



