title: How can I implement server-side rate limiting for a Perl web service?
body: <p>I have a Perl-based CGI/Fast CGI web service and want to rate-limit clients by IP address to stop aggressive clients causing too much work.</p>
  
  <p>I have looked around for some code and found <a href="http://search.cpan.org/dist/Algorithm-TokenBucket" rel="nofollow noreferrer">Algorithm::TokenBucket</a> in CPAN but that is for client requests; it has no persistence and has no per-user config so is not really useful for server-side rate limiting.</p>
  
  <p>I am looking for suggestions for something that already exists, otherwise I'll need to roll my own based on some simple persistence such as tie to <a href="http://search.cpan.org/dist/DB_File" rel="nofollow noreferrer">DB_File</a> per-IP address and some batch job that does the token management.</p>