tomMoulard / fail2ban

Traefik plugin on fail2ban middleware
MIT License
200 stars 11 forks source link

Pages load slowly when plugin enabled #59

Closed aqos156 closed 1 year ago

aqos156 commented 2 years ago

Hi, we have tried running this plugin (v0.6.6) in production to test out the fix of #52 but all the pages have started to load very slowly (before 200ms, 5-10s after enabling the plugin)

I suspect #51 to be the problem, where it always locks and waits until a requests is finished (maybe?)

tomMoulard commented 2 years ago

Hello @aqos156,

Thanks for your interest in this Traefik plugin !

Oh! yeah, you might be right. The mutex is closed when the function end using a defer.

https://github.com/tomMoulard/fail2ban/blob/5b110872e0c520f95158377ab8bc190630e62360/fail2ban.go#L245

This implies that the mutext is unlocked after the HTTP request has been served.

https://github.com/tomMoulard/fail2ban/blob/5b110872e0c520f95158377ab8bc190630e62360/fail2ban.go#L297

A good fix might be to remove the defer and unlock the mutex after ipViewed has been used.

fradeve commented 1 year ago

@tomMoulard would this issue make the plugin unusable? I that is the case, I would love seeing it fixed -- it's a shame that GoLang is not my strong suite :cry:

tomMoulard commented 1 year ago

No, this plugin is usable as is, but it might not be as fast as it can be. Using the plugin might throttle a bit down the overall HTTP performance of the request handling of Traefik.

tomMoulard commented 1 year ago

As this issue is being too broad, following my comment https://github.com/tomMoulard/fail2ban/issues/59#issuecomment-1031181693, the pr #77 closes this issue.