Tomcat为什么缺少内置的限速过滤器? [英] Why does Tomcat lack built-in rate-limit filters?
问题描述
从一些来源( 1 3 ),给我的印象是,每当人们想要对限制请求进行评分时,这种趋势似乎是将Tomcat封装在Apache后面,并对Apache进行限制".还有iptables解决方案,但是不能回答HTTP 429(请求太多").
From a few sources (1 2 3), I'm getting the impression that whenever people wants to rate limit requests, the tendency seems to be "wrap Tomcat behind Apache, and rate-limit on Apache". There's also the iptables solution, but that won't answer HTTP 429 ("Too many requests").
Apache很好,但是有时候,如果我们可以即兴地小型部署一个小型servlet,那将是很好的选择,但是仍然要求我们对限制请求进行评分,并且设置一个Apache层似乎有点过度杀伤(至少与克隆web.xml文件相比,无论如何我们都已经这样做了).
Apache is fine, but sometimes it will be nice if we can improvise small-scale deployments of a small servlet we have, but we're still being asked to rate limit requests, and setting up an Apache layer seems like a bit of overkill (at least compared to cloning a web.xml file, which we're already doing anyway).
因此,我正在考虑编写一个小型过滤器来做到这一点(这似乎是不费吹灰之力的一种),然后将其与servlet打包在一起,但是在Tomcat中,缺乏精心设计的Tomcat速率限制过滤器开放表明这种方法可能是幼稚的.我的意思是,这感觉是如此通用,而且如今开放源代码可用的东西太多了...........................................................因此,也许有一个很好的理由证明Apache解决方案是合理的. Apache有很多选择,而Tomcat似乎没有.
So I'm thinking of coding a small filter to do just that (as it seems like a significant amount of non-effort) and package it with the servlet, but the eerie absence of elaborate Tomcat rate limit filters out in the open suggests that this approach might be naive. I mean, this feels so generic and so much is Open-Source-available these days. So maybe there is a really good reason that justifies the Apache solution. Apache has so many options while Tomcat seems to have none.
(Jetty does seem to ship with one such filter though, despite being a servlet container.)
为什么Tomcat缺少内置的限速过滤器?
Why does Tomcat lack built-in rate-limit filters?
推荐答案
Tomcat sure does have a rate-limit filter valve built-in. You just have to modify it to suit your needs.
这篇关于Tomcat为什么缺少内置的限速过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!