How to rate-limit Apache server on IP basis?

you may be able to do this at a lower level with iptables and bypass apache/mysql all together…. match and forward to another host / port? i have only dropped:

<span style="color: #242729;">iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set</span>
<span style="color: #242729;">iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 60 --hitcount 6 -j DROP
</span>