Finally, I figured out how to test the throughput difference of enabled/disabled proxy buffering. I think slowtest
isn't a good tool to test it. I used wrk
My new set up:
Slow client (10.2.0.7) \
\
Nginx (10.2.0.5) <===> PythonApp (10.2.0.4, port 8000)
/
/
Fast client (10.2.0.6)
You can reference this Digital Ocean guide to set up Flask app
Python App:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
@app.route("/big-file")
def big_file():
return "<h1 style='color:blue'>" + "Hello There!"*1000000 + "</h1>"
if __name__ == "__main__":
app.run(host='0.0.0.0')
Slow client:
# modprobe ifb
# ip link set dev ifb0 up
# tc qdisc add dev eth0 ingress
# tc filter add dev eth0 parent ffff: \
protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0
# tc qdisc add dev ifb0 root netem delay 750ms
Run wrk test on fast & slow client:
Slow client:
# wrk -t4 -c10 -d30 http://pythonapp.com/big-file
Fast client:
# wrk -t2 -c100 -d10 http://pythonapp.com
It's a must for slow client to access /big-file path, which will return a fairly large response. If the response is smaller than proxy_buffer_size, the connection between Nginx and proxied server will be closed very quickly, and you cannot simulate the blocking.
Connections occupied by slow clients under no proxy_buffering in Nginx & throughput of fast clients:

Throughput of fast clients when no proxy buffering

If there is proxy_buffering, you shall not see connections occupied by slow clients. You can run the commands for slow clients to download slow response first, then check the connections in Nginx.

Throughput of fast clients when there is proxy buffering
