3 ms·
rate-limiting -> nginx || iptables Never ask PHP/Node/Ruby/Python to do low-level network routing. Your throwing megabytes of memory at a simple connection dec
by Xeoncross 9y ago
rate-limiting -> nginx || iptables
Never ask PHP/Node/Ruby/Python to do low-level network routing. Your throwing megabytes of memory at a simple connection decision. If you need advanced logic for rate-limiting (not just access counting) then using nginx + memcached/redis as the marker. Have your app mark the ip in memcached/redis so nginx knows not to bother Node/PHP/Ruby/Python next time.
- always_good 9y agoWhat you propose is only a performance optimization at the expense of operational complexity. Like caching. "Never" doesn't make sense.
- Xeoncross 9y agoI guess you could simply rate-limit your login/signup if your not worried about a DoS and just want to keep people from brute-forcing a password. On the other hand, it's not simply "a performance optimization" as there is no way for node to handle a DDoS without crazy amounts of hardware relative to what iptables|nginx can handle.
- deleted 9y ago[deleted]
- always_good 9y agoYou're the one talking about DoS. Notice how "rate-limiting" is a much more generic concept. For example, Hacker News rate-limits the amount of posts you can make in a window of time. That's not because they think you're trying to DoS them.
- northvillage 9y agoThis is optimization, might as well go all out and call it caching. "never" won't even apply.