Hi Adis,

On 15.10.20 15:03, Adis Nezirovic wrote:
On 10/15/20 2:08 PM, Aleksandar Lazic wrote:
Hi.

I though maybe the peers could help me when I yust add the client IP with the URL but I'm not sure if I can query the peers store in a efficient way.

The target is to know how much concurrent IP's request the a specific URL.

Could lua be a solution.

Hey Aleks,

I'm not sure Lua would be the right solution for your situation, counting stuff 
is tricky.

Hm so you mean that lua could be a performance bottleneck for youtube scale ?
As I haven't used lua in haproxy or nginx I have no experience how it behaves 
on high
traffic sites.

I thought to use something like this but "proc" wide

function action(txn)
  -- Get source IP
  local clientip = txn.f:src()
  local url      = txn.sf:path_beg("/MY_URL")

  save_in_global_hash(clientip+url)
end

and query this save_in_global_hash with a service.

However, I think Redis has INCR, you you can store per URL counters and maybe (just maybe) use Lua action in HAProxy to write to Redis.

Obviously, you'd need to look out for performance, added latency etc, but it 
would be a start.
You can then access Redis outside of the HAProxy context and observe the 
counters.

Maybe the stick tables could also be a solution because I use it already for 
limiting access.

```
  # 
https://www.haproxy.com/blog/application-layer-ddos-attack-protection-with-haproxy/
  http-request track-sc0 src table per_ip_rates
```
# table: per_ip_rates, type: ip, size:1048576, used:3918

0x7f3c58fa9620: key=<IP> use=0 exp=597470 http_req_rate(10000)=1

0x7f3c4d299960: key=<IP> use=0 exp=588433 http_req_rate(10000)=2
0x7f3c50cc8830: key=<IP> use=0 exp=241004 http_req_rate(10000)=0
0x7f3c5c6b3eb0: key=<IP> use=0 exp=586046 http_req_rate(10000)=1
...
```

Can i add there a URL part like path_beg("/MYURL")

Just my 2c, hope it helps you (like you helped many people on this list)

Thank you for your input.

Best regards,


Reply via email to