/http

A simple, easy to use HTTP load generator.

Primary LanguageC

http-client

A simple and easy to use http load generator tool. Tool is based on libevent for asynchronous event handling and uses NodeJS parser for parsing HTTP responses/requests.

===============How does it work ? ===============

http-client tool can be used to load the server at a particular RPS and connections. Tool opens several connections in parallel and sends the requests at the mentioned rate.

===============How to run========================

./http-client --help
http-client - Easy to use HTTP Client
Allowed options:
-h [ --help ]                         Display this message
-c [ --client-ip ]                    Http Client ip
-n [ --num-client ]                   No. of Clients
-i [ --req-client ]                   Requests per client
-r [ --rps ]                          Requests per second
-s [ --server-ip ]                    Http Server Ip
-p [ --server-port-start ]            Http Server port start
-l [ --num-srvs ]                     Http Server port range
-d [ --dest-file ]                    Read Http Dest Endpoint from file
-f [ --file ]                         Http Request template
-k [--debug-log ]                     Print Debug logs

============ Command line options and usage =====

--help -  Prints the help string
--client-ip - This argument represents the IP to use and by default binds the client to 0.0.0.0
--num-client - Number of parallel client connections opened with the server
--req-client - Number of requests sent out on each client.
--rps  -  Determines requests per second generated by the tool
--server-ip  -  Server Ip Address and it could be a domain name as well. For eg: google.com
--server-port-start - Incase, Servers are bound at contigous ports this option can be used. For eg: server-ip:port1, server-ip:port2, et al
--num-srvs - Number of server connections to open incase of multiple servers
--file - Read Server endpoints from a file
--debug-log - Enable logs at several levels
  Log-Levels    Severity
  1             INFO
  2             TRACE
  3             CRITICAL
  4             ERROR
  5             DEBUG

  http-client sends out r RPS spread equally across several client connections. For each request that is sent out by the client, tool maintains time-to-last-byte.
  It must be noted that to maintain a constant RPS, we do not wait for responses before sending out requests in pipelines. HTTP RFC recommends that responses arrive
  in order and this method is used to tag time stamp to a round trip req-rsp. If tool is configured with N clients, I requests per client, a total of N*I requests
  will be sent by the tool before exiting. On exit, the tool summarizes several HTTP parameters and statistics

===============Sample o/p========================

./http-client -c 0.0.0.0 -s google.com -p 80 -k 5
Setting default value gclientcfg.client_count:1
Setting default value gclientcfg.reqs:1
Setting default value rps_ctxt.rps:1
Setting default value gclientcfg.tot_srvs:1
Setting default value rps_ctxt.tot_req_to_send:1
Setting LOG level to 5
[LOG_LEVEL_ERROR:2019-07-10 15:27:44 ]- Server located at address: 216.58.196.174
Using default GET Template
[LOG_LEVEL_INFO:2019-07-10 15:27:45 ]- Starting cnxns from id : 0
[LOG_LEVEL_INFO:2019-07-10 15:27:46 ]- Finished creating 1 cnxns
[LOG_LEVEL_INFO:2019-07-10 15:27:46 ]- sent 1 reqs
[LOG_LEVEL_TRACE:2019-07-10 15:27:46 ]- Begin of Http msg
[LOG_LEVEL_TRACE:2019-07-10 15:27:46 ]- Received HTTP-Status code=404
[LOG_LEVEL_DEBUG:2019-07-10 15:27:46 ]- Received resp for client-id 0 of len 1418
[LOG_LEVEL_DEBUG:2019-07-10 15:27:46 ]- HTTP/1.1 404 Not Found
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Content-Length: 1561
Date: Wed, 10 Jul 2019 09:58:16 GMT

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-si
[LOG_LEVEL_TRACE:2019-07-10 15:27:46 ]- End of msg
[LOG_LEVEL_DEBUG:2019-07-10 15:27:46 ]- Received resp for client-id 0 of len 298
[LOG_LEVEL_DEBUG:2019-07-10 15:27:46 ]- ze:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/</code> was not found on this server.  <ins>That’s all we know.</ins>

ClientInfo stats for client with id=0
Http Requests  Sent :              1
Http Responses Rcvd :              1
HTTP_RSP_CODE_404   :              1
Latency Distribution in seconds
P10                   :  0.166799
P20                   :  0.166799
P30                   :  0.166799
P40                   :  0.166799
P50                   :  0.166799
P60                   :  0.166799
P90                   :  0.166799
P95                   :  0.166799
P99                   :  0.166799

======================Build Dependencies===================

The following libraries/tools are needed to build the tool
* automake
* libtool
* autoconf
* libevent
* libssl-dev
* libcrypt, libcrypto