I tried searching for this; I found many people asking but I wasn't successfully to find a working (for me) solution.
I have an application that logs each connection on a custom log file.
When fail2ban detect more than 10 connections in 5 second from the same ip it ban the "attacker" for 600 second.
It happens that the attacker can make 11/20 connections before getting banned (and that's ok).
After that i get xxx.xxx.xxx.xxx already banned
messages in fail2ban.log
for each line > 11. There is one of those message each second; it's like fail2ban take 1 seconds for each of the log lines with the same IP after the ban.
But in the meantime I have another attacker from another IP and he successfully connects more times (i.e 50) because fail2ban is analyzing the log's lines from the previous IP (1 per second).
And so on... While fail2ban processes past log's lines new attackers make thousands of connections. That's incremental and only first few attackers get banned.
I have fail2ban NOW analyzing lines that were from connections made 1 or more hours before.