tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: how to block the duplicated requests?
Date Mon, 18 May 2015 20:00:28 GMT
Hash: SHA256

To whom it may concern,

On 5/18/15 11:44 AM, javalishixml wrote:
> I have a website. It is built by apache + tomcat.
> Now we make a lottery activity at this website. But we find that
> some robots always raise the duplicated requests to hit this
> lottery activity. It causes that robots almost get all the awards.
> So we just want to block these kind of duplicated requests at every
> interval unit. For example, we set the interval unit is 3 seconds.
> The if the robot want to hit the lottery activity in 3 seconds, the
> website could block this action.
> So how to do it? I suppose if we do it at tomcat level, is it a
> very low performance? Can I do it at apache level? how to do it? If
> I could not do it apache level, can I do it by setting sth at
> tomcat?

If you have a way to identify a "duplicate" request (e.g. using a
fingerprint of the request that you can check during that 3-second
interval), then this is conceptually very easy.

It may not be great for performance, but you'll have to weigh that
against your own requirements. (For example, which is worse: poor
performance, or a site where only robots ever win the lottery?)

This will not be something you can configure in Apache httpd or
Tomcat. This will have to be an application thing (unless you can
describe the fingerprint technique to some httpd module such as
mod_security or mod_qos and then allow it to discard duplicates).

Back to the solution:

1. Take a fingerprint of the request
2. Lookup the fingerprint in a database of previous requests
   ( fingerprint -> latest timestamp )
3. If the fingerprint appears in your database and the timestamp is
less than 3 seconds ago, discard the request
4. Otherwise, store the current timestamp and fingerprint in the databas

For a database, I might recommend something like memcached or another
in-memory-style database. An in-memory key-value store is really what
you are looking for. Memcached has a nice feature where values can
automatically time-out (e.g. they are invalid after 3 seconds), so you
can make your application code a bit simpler because you'll never have
a value in the database that is not valid.

Hope that helps,
- -chris
Version: GnuPG v2
Comment: GPGTools -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message