Iptables – apache rate limit best practice

apache-2.2httpdiptablesrate-limiting

I have the following business scenario:

  1. apache http server load balances client request to application servers via ajp
  2. all the resource intensive work is done on application servers for each request
  3. requests are application user based, however there's no easy way to rate limit the user.
  4. most users would be coming from a single ip, a few might be coming from a few ips. Therefore for
    the intent of this problem I assume each user would be coming from an ip.
  5. the goal is to prevent any single user swamp the server with requests.

I'm currently using iptables rate limiting to limit the maximum number of concurrent connections per ip.

Is there a better approach?

Best Answer

Probably your best chance will be something like http://bloke.org/apache/limit-apache-requests-per-ip-address-with-mod_limitipconn/

Also, since you are using ajp, I am going to assume that you are front ending tomcat. Another technique that my help is using an Async Servlet - https://plumbr.eu/blog/how-to-use-asynchronous-servlets-to-improve-performance