[Django]-Make a POST request using ab (apache benchmarking) on a django server

6👍

@jacobm654321,

for sure, the best thing to do is encode the URL programmatically. But my problem wasn’t that. My problem is that the file containing the post data had a blank line at end of file. EditorConfig put it there. After remove that blank line, everything worked well.

Thanks anyway.

29👍

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/

10👍

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.

Leave a comment