How do I use cURL to perform multiple simultaneous requests?

后端 未结 3 971
清酒与你
清酒与你 2020-12-29 04:18

I\'d like to use cURL to test flood handling on my server. Right now I\'m using this on a Windows command line:

curl www.example.com
         


        
相关标签:
3条回答
  • 2020-12-29 04:49

    While curl is a very useful and flexible tool, isn't intended for this type of use. There are other tools available which will let you make multiple concurrent requests to the same URL.

    ab is a very simple yet effective tool of this type, which works for any web server (despite the introduction focusing on Apache server).

    Grinder is a more sophisticated tool, which can let you specify many different URLs to use in a load test. This lets you mix requests for cheap and expensive pages, which may more closely resemble standard load for your website.

    0 讨论(0)
  • 2020-12-29 04:50

    Curl may not do it itself but bash can.

    curl -o 1.txt -X GET https://foo & curl -o 2.txt -X GET https://foo
    
    0 讨论(0)
  • 2020-12-29 05:03

    I had a similar case and I ended up writing a python script:

    import threading
    import requests
    
    def thread_function(url):
        response = requests.get(url)
    
    thread1 = threading.Thread(target=thread_function, args=('http://foo',))
    thread2 = threading.Thread(target=thread_function, args=('http://bar',))
    
    thread1.start()
    thread2.start()
    
    0 讨论(0)
提交回复
热议问题