Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare with python requests #35

Closed
likezjuisee opened this issue May 2, 2018 · 4 comments
Closed

compare with python requests #35

likezjuisee opened this issue May 2, 2018 · 4 comments
Labels

Comments

@likezjuisee
Copy link

likezjuisee commented May 2, 2018

Why the latency result of the bom is different with the python requests package?

bom average 1.58ms, requests 250ms

bom result:

Statistics        Avg      Stdev        Max
  Reqs/sec      6286.72     460.12    7012.96
  Latency        1.58ms   349.64us    26.34ms
  HTTP codes:
    1xx - 0, 2xx - 63013, 3xx - 0, 4xx - 0, 5xx - 0
    others - 0
  Throughput:     2.13MB/s

python requests package:
>>> import requests
>>> url = "http://10.143.192.105:9362/hotrizon/GetScore?m2=000029da81eafcfcdbde82d6bd2d2&qid=29957933"
>>> import time
>>> def func():
...     t = time.time()
...     requests.get(url)
...     print time.time() -t 
... 
>>> func()
0.376302957535
>>> func()
0.293756961823
>>> func()
0.292520046234
>>> func()
0.291940927505
>>> func()
0.291563034058
>>> func()
0.292473077774
@codesenberg
Copy link
Owner

Well, I'm not all that familiar with python and requests library, but it seems like when you perform a single request, time to establish TCP connection, do a DNS lookup, etc. is much larger than the time to perform a single request (this is what you do with python). While with bombardier, by default, you establish something like 125 TCP connections, which are reused, and perform as many requests as you can in 10 seconds — 63013 in your case. With this setup, time to establish TCP connections (etc.) becomes negligible compared to the total time spent performing requests and therefore you get the results that you are seeing.
You should probably get something close to your python's results if you use bombardier -n 1 <url>.

@likezjuisee
Copy link
Author

likezjuisee commented May 2, 2018

bom 1.8ms
requests 286ms

root@ubuntu-HP-ProDesk-680-G2-MT:~/software# ./bombardier-linux-amd64 -n 1 http://10.209.5.34:8013/hotrizon/get-score?m2=0000090ecb899d858576495c70f27a29&qid=123
[1] 15519
root@ubuntu-HP-ProDesk-680-G2-MT:~/software# Bombarding http://10.209.5.34:8013/hotrizon/get-score?m2=0000090ecb899d858576495c70f27a29 with 1 requests using 125 connections
 1 / 1 [========================================================================================================================================================] 100.00% 0s
Done!
Statistics        Avg      Stdev        Max
  Reqs/sec       135.49      95.80     270.97
  Latency        1.80ms     1.27ms     3.60ms
  HTTP codes:
    1xx - 0, 2xx - 1, 3xx - 0, 4xx - 0, 5xx - 0
    others - 0
  Throughput:    88.94KB/s

[1]+  Done                    ./bombardier-linux-amd64 -n 1 http://10.209.5.34:8013/hotrizon/get-score?m2=0000090ecb899d858576495c70f27a29
root@ubuntu-HP-ProDesk-680-G2-MT:~/software# 
root@ubuntu-HP-ProDesk-680-G2-MT:~/software# 
root@ubuntu-HP-ProDesk-680-G2-MT:~/software# python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> def func():
...     import time
...     t= time.time()
...     requests.get("http://10.209.5.34:8013/hotrizon/get-score?m2=0000090ecb899d858576495c70f27a29&qid=123")
...     print time.time() -t
... 
>>> func()
0.286794900894
>>> 

@codesenberg
Copy link
Owner

I just noticed that you forgot to double-quote URL for bombardier, i.e. you type:

./bombardier-linux-amd64 -n 1 http://10.209.5.34:8013/hotrizon/get-score?m2=0000090ecb899d858576495c70f27a29&qid=123

, but it should be:

./bombardier-linux-amd64 -n 1 "http://10.209.5.34:8013/hotrizon/get-score?m2=0000090ecb899d858576495c70f27a29&qid=123"

Might not be the reason for the different results, but you test two different URLs.

@likezjuisee
Copy link
Author

Finally, I found this problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants