Skip to content

HTTP Sim

httpsim

This is a super hacky little webserver that attempts to simulate the kinda of responses you'd expect to see from a real server in the wild.

The goal was to use it as a means of generating realistic'ish backend responses under load for testing. As I said ... suuuuuuper hacky please make it better.

I've been using it to test NGINX proxy_pass using httpsim as the backend, can do a similar trick in Apache with mod_proxy.

default mode

Starting the sim up in the default mode it will listen bind to localhost:8675. It will happily respond to any request with a 200 and will generate a response with the following characteristics:

  • The request will have between 100 and 1000 ms of latency added to simulate backend application "response" time
  • 5 junk headers will be added the key being a string of random 10-50 character string, the value being a random 10-200 character string - attempting to simulate a range of different header sizes
  • a response body of up to 128k random characters is also cooked into the response to simulate a variety of response sizes

tweaking

You can of course tweak most of the params on the command line:

./httpsim --help
Usage of ./httpsim:
  -body-size=131072: maximum size for message body (bytes)
  -http-listener="127.0.0.1:8675": server address to listen on
  -max-resp-time=1000: maximum response time (ms)
  -min-resp-time=100: minimum response time (ms)
  -num-junk-headers=5: number of random junk headers to insert

future ideas and work

please feel free to hack on these

  • generate response times and sizes according to a distribution (real traffic at volume doesn't really have this level of randomness in response times or sizes)
  • randomize a few occasional non-200 responses
  • do some nasty things (just drop the connection, hang a request for a really really long time)