Comments (10)
Sounds good, can you elaborate a little bit more about what you have in mind?
from spring-cloud-zuul-ratelimit.
I was thinking of a new parameter to the Policy
class called "quota" which will behave as follow:
- The user will define the quota (optional), limit will be optional as well, one of them has to be defined
- In the
RateLimitFilter
will save the current time to the request attributes (if quota is defined) - A new "post" filter will be added, the filter will check if the attribute of the start time exists, if so the filter will calculate the elapsed time and reduce it from the quota
- If the quota exceeded it will reject the new requests
This will help us differentiate the requests weight on the system.
The only issue is that the the time is calculated at the end of each request, so meantime new requests can enter the system.
I think it will add some power to the rate limit mechanism that can be enhanced further
from spring-cloud-zuul-ratelimit.
Thanks for the info @lchayoun.
It's clear for me now, the only concern that I've you already pointed it's about the calculation being done in a later phase meaning new requests can jump in even thou the rate limit capacity has already being reached.
from spring-cloud-zuul-ratelimit.
I agree, but with a solid timeout I think it will be strong enough, do you want me to create a pull request on it?
from spring-cloud-zuul-ratelimit.
@lchayoun if you have time it would be awesome :)
from spring-cloud-zuul-ratelimit.
@lchayoun were you able to compile the project locally with your changes?
I'm facing some issues regarding consul
implementation.
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'eyJrZXkiOiJyYXRlLWxpbWl0LWFwcGxpY2F0aW9uOnNlcnZpY2VEOi9zZXJ2aWNlRC9mNzA1NjI2NS1hNThiLTRjNmUtOTliMi04NTI3ZjIxMTM4NDAiLCJyZW1haW5pbmciOjEsInJlbWFpbmluZ1F1b3RhIjpudWxsLCJyZXNldCI6NjAwMDAsImV4cGlyYXRpb24iOiIyMC0wOS0yMDE3IDA4OjAyOjE4In0': was expecting ('true', 'false' or 'null')
at [Source: eyJrZXkiOiJyYXRlLWxpbWl0LWFwcGxpY2F0aW9uOnNlcnZpY2VEOi9zZXJ2aWNlRC9mNzA1NjI2NS1hNThiLTRjNmUtOTliMi04NTI3ZjIxMTM4NDAiLCJyZW1haW5pbmciOjEsInJlbWFpbmluZ1F1b3RhIjpudWxsLCJyZXNldCI6NjAwMDAsImV4cGlyYXRpb24iOiIyMC0wOS0yMDE3IDA4OjAyOjE4In0=; line: 1, column: 232]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702) ~[jackson-core-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558) ~[jackson-core-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:2839) ~[jackson-core-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1903) ~[jackson-core-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:749) ~[jackson-core-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3850) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3799) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2858) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.repository.ConsulRateLimiter.getRate(ConsulRateLimiter.java:49) ~[spring-cloud-zuul-ratelimit-core-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.repository.AbstractRateLimiter.create(AbstractRateLimiter.java:31) [spring-cloud-zuul-ratelimit-core-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.repository.AbstractRateLimiter.consume(AbstractRateLimiter.java:24) [spring-cloud-zuul-ratelimit-core-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.filters.RateLimitPreFilter.lambda$run$0(RateLimitPreFilter.java:75) [spring-cloud-zuul-ratelimit-core-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at java.util.Optional.ifPresent(Optional.java:159) ~[na:1.8.0_131]
I believe it's related to ConsulRateLimiter#getRate(String)
at this line:
rate = this.objectMapper.readValue(value.getValue(), Rate.class);
from spring-cloud-zuul-ratelimit.
forked it again, seeing the same issue, taking a look
from spring-cloud-zuul-ratelimit.
@lchayoun thanks in a bunch
from spring-cloud-zuul-ratelimit.
@lchayoun do you have time to work on few tests for post
filter? It seems that the whole #run()
method has no test.
If you don't have time let me know.
from spring-cloud-zuul-ratelimit.
@lchayoun here we go v1.3.3.RELEASE.
from spring-cloud-zuul-ratelimit.
Related Issues (20)
- Rate Limit for List of Users HOT 4
- JDK 8 compatibility HOT 6
- Rate Limit by multiple types : Origin and HTTP_HEADER HOT 1
- How to use url_pattern ? HOT 9
- url_pattern in v.2.42.0 HOT 2
- Consul repository not working with URL_PATTERN HOT 2
- Fix Travis-CI Integration
- High Performance degradation happen because of method synchronization HOT 3
- How do you pass REDIS configs for REDIS based ratelimit HOT 8
- URL Pattern key HOT 2
- Working example using bucket4j HOT 8
- Migrate from Travis CI to Circle CI HOT 1
- Visibility on the usage of Log4j HOT 1
- Recent Spring Boot Support? HOT 2
- General Question for better understanding HOT 10
- Configuration "zuul.ratelimit.enable=false" failed to start the service HOT 3
- Rate Limited consistently though refresh interval is crossed HOT 13
- Query regarding MatchType And breakOnMatch HOT 11
- How can set the zuul ratelimit filter for group of users other than the user with name xxxx HOT 2
- Not able to make policy with url_pattern 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 spring-cloud-zuul-ratelimit.