[erlang-questions] Throttling HTTP requests

Tobias Schlager Tobias.Schlager@REDACTED
Fri Sep 21 09:02:35 CEST 2018


Hi Frank,

I've implemented a simple form of rate limiting in this [1] little project (module http2smtp_rate). The module is probably not what you need but the idea behind it, could be used as a starting point. The basic idea is the following:

Everytime a request comes in, the request process makes a gen_server call to this server (you could also spawn the limiter processes per source IP address for sharding). This request will increment and return a counter (specific for this IP address). If the counter exceeds the limit, the request gets terminated immediately. The server has an internal timer that fires once per desired interval and resets all counters.

Regards
Tobias

[1] https://github.com/lindenbaum/http2smtp

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180921/6e948fae/attachment.htm>


More information about the erlang-questions mailing list