我开发了一项服务,以减少自定义速率限制带来的困扰。
每次我在处理API时,我都会遇到同样的头疼问题:速率限制。<p>内置的解决方案要么过于死板(对所有请求施加相同的限制),要么过于 hacky,或者在负载下崩溃。实际上,我需要的是类似于:<p>“按用户ID限制请求”<p>“按API密钥限制请求”<p>甚至是“基于自定义字段(如订阅计划)限制请求”<p>我最终不得不多次编写自己的乱七八糟的代码……对此我非常厌恶。<p>于是我开发了Rately。这是一个服务(运行在Cloudflare之上),允许你根据自己的需求设置自定义限制,延迟约为25毫秒。这个想法是:将其放入,配置你的规则,然后就可以忘记它。<p>如果你正在运营一个SaaS或API,我很想知道——你今天是如何处理速率限制的?是自己开发的还是使用现成的解决方案?<p>(如果你感兴趣,可以在这里找到:rately.dev)
查看原文
Every time I’ve worked on an API, I ran into the same headache: rate limiting.<p>The built-in stuff was either way too rigid (limit everything the same), too hacky, or it fell over under load. What I actually needed was something like:<p>“Limit requests per user ID”<p>“Limit per API key”<p>Or even “limit based on custom fields like subscription plan”<p>I ended up writing my own spaghetti code more than once… and hated it<p>So I built Rately. It’s a service (runs on top of Cloudflare) that lets you set custom limits however you want, with ~25ms latency. The idea is: drop it in, configure your rules, and forget about it.<p>If you’re running a SaaS or an API, I’d love to hear — how are you handling rate limiting today? Did you build your own or use something off the shelf?<p>(If you’re curious, it’s here: rately.dev)