`CL.THROTTLE` implemented in DragonflyDB

MarΒ 12,Β 2023

Way back when Redis Modules were first introduced I wrote one called redis-cell. I wrote it because in my experience you couldn’t invent a more perfect fit for Redis than rate limiting, and we’d used it for such at practically every job I’d ever had.

The command provides easy limiting in a single Redis call:

CL.THROTTLE user123 15 30 60 1
               β–²     β–²  β–²  β–² β–²
               |     |  |  | └───── apply 1 token (default if omitted)
               |     |  └──┴─────── 30 tokens / 60 seconds
               |     └───────────── 15 max_burst
               └─────────────────── key "user123"

I’d still contend that it’s useful, but haven’t been maintaining it well. It picked up a few users, but one could make the argument that using a Redis Module for this isn’t enough of advantage to be worthwhile. You might gain a little speed, but have added overhead in configuration hassle and a non-standard Redis set up.

But here’s something that’s cool: CL.THROTTLE was recently implemented in DragonflyDB by Daria Sukhonina. DragonflyDB is a Redis-compatible DB written for speed, and seems to be more open about what kind of default utilities they include. Having it available out of the box is a better fit for CL.THROTTLE because you get access to it without configuring anything, and you won’t have to worry about its availability across different cloud hosts. It also gives you better protection against delinquent maintainers like me.

Did I make a mistake? Please consider sending a pull request.