a minimal rate limiting package for Golang microservice. small weekend project. feedback and stars will be appreciated.
Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
11–20 of 30 posts
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#12> It is capabale to handle distributed workload with its redis database support sounds like this is limited by redis. For many organizations, this is fine. At my last gig, we used redis for deduplication and it required over 150 redis nodes with deterministic routing and consensus. Redis reportedly could support 200k rps per node, but in our case, we wouldn't see it get passed around 50k rps no matter how we tuned it…
RPS meaning reads or writes? What's the distribution of message sizes, and how large is your total dataset? What specs (core count, NIC) did each node have? I'm asking because without this info, RPS is not a particularly useful metric. As an extreme example, if your dataset is <1MB, you could likely serve read-heavy requests from your SmartNIC's dcache at close to line rate.
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#13a minimal rate limiting package for Golang microservice. small weekend project. feedback and stars will be appreciated.
There aren't any tests...? If folks are looking for a serious rate limiting package for Go, limiter is a good start: https://github.com/ulule/limiter
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#14Earlier quoted context omitted.
There aren't any tests...? If folks are looking for a serious rate limiting package for Go, limiter is a good start: https://github.com/ulule/limiter
I'm sure that the people needing a "serious" solution would realize that a weekend project is probably not that.
> For production use, fork it and made changes based on your need.
...instead of the standard "this is work in progress/just a prototype/weekend project, don't use it in production!" disclaimer (which of course won't reliably stop people from using it in production either, but at least they can't say they haven't been adequately warned).
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#15> It is capabale to handle distributed workload with its redis database support sounds like this is limited by redis. For many organizations, this is fine. At my last gig, we used redis for deduplication and it required over 150 redis nodes with deterministic routing and consensus. Redis reportedly could support 200k rps per node, but in our case, we wouldn't see it get passed around 50k rps no matter how we tuned it…
Thanks for the feedback. I'm gonna implement an in-mem Go instance for local dev, but not sure if that will be enough to use in prod. also, in the next release, I will make redis optional.
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#16Given most of the backends use round robin for loadbalancing, having in-memory counter should be enough. Removing redis as downstream dependency is a big win. For the redis implementation, there should be fallback to in-memory counting instead blocking altogether. Currently the redis is a SPOF for the entire service.
thanks for the feedback. planning to make redis optional in next release.
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#172. redis.go does not seem to be nessary it just changes signature of redis client constructor without much difference, might as well inline its contents
3. using fmt too much, if you don't need run time variables encoding, can do something more simpler. like writing to w.Write([]byte) directly. fmt uses reflect and runtime type detection, better avoid if not needed.
4. code comments do not follow godoc conventions. they should start from symbol name. did you run go fmt and some basic linters?
5. mutex is not used. and it should be pointer.
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#18Earlier quoted context omitted.
RPS meaning reads or writes? What's the distribution of message sizes, and how large is your total dataset? What specs (core count, NIC) did each node have? I'm asking because without this info, RPS is not a particularly useful metric. As an extreme example, if your dataset is <1MB, you could likely serve read-heavy requests from your SmartNIC's dcache at close to line rate.
It's been a number of years since I worked on it. I can try to answer your questions. The calls were nearly entirely INCR calls against keys that were typically around 150 bytes long and app logic was based on the return values. I believe each node took up around 20GB of memory when saturated. Redis uses a single CPU, so core count shouldn't matter, no? I'm not entirely sure what our NIC situation was, but it was tun…
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#191. some tests, over the wire preferably, would be nice 2. redis.go does not seem to be nessary it just changes signature of redis client constructor without much difference, might as well inline its contents 3. using fmt too much, if you don't need run time variables encoding, can do something more simpler. like writing to w.Write([]byte) directly. fmt uses reflect and runtime type detection, better avoid if not need…
Re: Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
#20Earlier quoted context omitted.
It's been a number of years since I worked on it. I can try to answer your questions. The calls were nearly entirely INCR calls against keys that were typically around 150 bytes long and app logic was based on the return values. I believe each node took up around 20GB of memory when saturated. Redis uses a single CPU, so core count shouldn't matter, no? I'm not entirely sure what our NIC situation was, but it was tun…
Did you tune the file descriptor limits?