Comments (9)
Sure!
from limiter.
Hello,
Do you have any suggestions by any chances ?
Also, have you tried using redis store ? The in-memory store was more or less designed for debug and/or development.
Cheers,
from limiter.
Could I have an example of your expiration duration ?
from limiter.
Hello,
Do you have any suggestions by any chances ?
Also, have you tried using redis store ? The in-memory store was more or less designed for debug and/or development.Cheers,
I think redis store would remove the the bottleneck since there is no cleaner on the app but for a single deployment it would create unneeded latency.
For the in-memroy the deletion of expired records could be done like this https://github.com/gadelkareem/cachita/blob/master/memory.go#L82 because of this issue golang/go#20135 but that would not be the best solution yet since cleaner will block again. I am not sure how to tackle the in-memory cleaner but maybe if there is a replica of the counters hash map that is used only for reading and the writing could be done through channels in go routines. But I am not sure how to do increment in this way.
Could I have an example of your expiration duration ?
generalLimiter = newLimiter("4-S")
apiLimiter = newLimiter("50-M")
searchLimiter = newLimiter("30-M")
func newLimiter(rate string) *limiter.Limiter {
r, err := limiter.NewRateFromFormatted(rate)
h.PanicOnError(err)
return limiter.New(memory.NewStore(), r, limiter.WithTrustForwardHeader(true))
}
from limiter.
I may have a solution using a ring buffer, would you like to experiment it ?
from limiter.
@gadelkareem Could I have an example on how many keys you have in your store, so I could have a good telemetry on how my idea improve (or not) things ?!
Thank you.
from limiter.
@novln I am afraid that would be hard to calculate because it is production data but we can estimate it through the number of requests which is around 1.2 Million request per day.
from limiter.
Hello,
Could you try this commit 3cd0e5a?
I haven't done a benchmark nor a ring buffer in order to try to keep the initial architecture.
Also, it was quicker to try this and find a quick and good enough solution for your problem.
from limiter.
I tested it with stack impact and I do not see that blocker anymore but i made a PR so you can test it more intensely.
from limiter.
Related Issues (20)
- Feature Request: Please can you add rqlite as store HOT 2
- Limit for every 5 minute HOT 1
- Please consider adding SkipList option HOT 1
- Rate limiting based on custom identity HOT 2
- ERR bad lua script for redis cluster HOT 1
- Which time windows does this limiter use? HOT 1
- Custom keys? HOT 1
- limit of dynamic route HOT 1
- Should use the rightmost ip in x-forwarded-for, if used at all HOT 7
- another dynamic limit need HOT 9
- Limiters with momery store are not working as expected HOT 3
- A key can be limited forever HOT 2
- About algorithms HOT 2
- Consider changing the in memory cache library HOT 1
- I plan to consider using limiter middleware in the management system
- Gin Middleware Limiter with momery store are not working
- Consider support long time connection rate limit (Websocket) HOT 1
- Add custom Header value for limiter Option
- Feature Request: Please support goframe framework HOT 1
- Add ruedis support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from limiter.