Make a POST request using ab (apache benchmarking) on a django server

When using ab, the entire contents of the data file must be wrapped onto a single line - it fails silently if it's normally expanded JSON. So a post from a data file that works fine with curl will fail with ab until you do this.

Tip: If using Atom or VSCode, select all and hit Cmd-J to wrap everything to one line.


File must have a properly url-encode data. If you url-encode manually, it is too easy to have typos like blanks wrong encodes. Best do it programmatically. See an another answer: Apache Bench and POST data on how to use Python to create such file ( ex: post.data)

Then use: ab -T 'application/x-www-form-urlencoded' -n 10 -p post.data http://localhost:8080/