Adventures in Learning Full Stack Web Development

Measuring Web Requests with Httping

2020.01.31

I recently encountered a bug where an http request was taking up to 3 seconds. Once I developed a potential solution, I needed to test the request to see if it was faster with the new code changes. In order to test, I developed a baseline by curling the request without any code changes. Next, I updated the code with the hopeful solution, and curled the request again to observe the change.

Below is an example. Note, the -v (short for -verbose) shows extra information, like the runtime, which shows the length of the request in seconds.

curl -v http://api.citybik.es/v2/networks

I found myself curling repeatedly to check the length of the request. I even recorded the times and averaged them. This was cumbersome. Fortunately, I discovered a useful program called httping that allows you to test the latency of a request by pinging it on a loop. When you exit the loop, an average runtime is provided for you.

httping http://api.citybik.es/v2/networks

httping-demo

It’s worth checking out the man pages because there are a number other useful httping features. For example, the demo below enables color highlighting and highlights all requests above the provided threshold.

httping http://api.citybik.es/v2/networks -Y --threshold-red 325

httping-color-demo