实施 Web API 请求限制/速率限制的常见方法有哪些?
实现Web API请求限制的常见方法有哪些?是否有适用于常见 Web 框架(Rails、Django、Java 等)的库可以为您提供此功能并暂时禁止?
一个相关的问题表明,速率限制是在 Web 服务器上通过限制 IP 请求来完成的,但这意味着所有请求都会受到同等对待。似乎限制需要由应用程序处理,因为:
- 某些 API 调用可能有不同的速率限制(例如,自动完成 API 的限制会比其他调用更高)
- Web 服务器无法处理 API 密钥的临时禁止
- 请求来自代理后面的问题会被处理相同的(?)
What are common ways of implementing web API request throttling? Are there any libraries for common web frameworks (Rails, Django, Java, etc.) that give you this along with temporary banning?
A related question suggests that the rate limiting is done at the web server by limiting requests by IP, but that would mean that all requests are treated equally. It seems like throttling needs to be handled by the application because:
- Some API calls may have different rate limits (e.g. an autocompletion API would have a higher limit than other calls)
- Temporary banning by API key can't be handled by the web server
- Requests coming from behind a proxy are treated the same (?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
姜戈活塞有一些巧妙的节流装置。查看源代码 http://bitbucket.org/jespern/django-piston/wiki/首页
Django-Piston has some neat throttling in there. Check out the source http://bitbucket.org/jespern/django-piston/wiki/Home
您可能还想使用 IPtables (linux) 等工具来硬限制某些传入流量。还有第三方服务,例如 3scale (http://www.3scale.net - 免责声明 - 我为它们 :-) ) 允许跟踪和管理您想要在每个用户的基础上应用于流量的所有使用限制。
You might also want to use tools like IPtables (linux) to hard limit some of the incoming traffic. There are also third party services like 3scale (http://www.3scale.net - disclaimer - I work for them :-) ) which allow to keep track of and manage all the usage limits you want to apply to traffic on a per-user basis.