Rate limit base on bucket name

Hello

We have a ceph cluster with s3 gateway and I want to set per bucket rate limit in haproxy. Paths are like https://myDomain.com/bucketName/fileName. how can I set rate limit for each bucketName? I can not have list of bucket names.

Hi Mahnoosh,
you can use follow configs

stick-table  type string size 100k  expire 10s  store http_req_rate(20s)
http-request set-var(txn.bucket_name) path,word(1,/)
http-request track-sc0 var(txn.bucket_name)
http-request set-var(req.rate_limit)  var(txn.bucket_name),map_beg(/usr/local/etc/haproxy/rates.map,7)
http-request set-var(req.request_rate)  var(txn.bucket_name),table_http_req_rate()
acl rate_abuse var(req.rate_limit),sub(req.request_rate) lt 0
http-request deny deny_status 429 if rate_abuse

rates.map:

bucket1 10
bucket2 100

rate limit for bucket1 is 10, bucket2 is 100 and another bucket is 7(default value of map)

1 Like