GithubHelp home page GithubHelp logo

Comments (10)

marcosbarbero avatar marcosbarbero commented on May 23, 2024

Sounds good, can you elaborate a little bit more about what you have in mind?

from spring-cloud-zuul-ratelimit.

lchayoun avatar lchayoun commented on May 23, 2024

I was thinking of a new parameter to the Policy class called "quota" which will behave as follow:

  1. The user will define the quota (optional), limit will be optional as well, one of them has to be defined
  2. In the RateLimitFilter will save the current time to the request attributes (if quota is defined)
  3. 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
  4. 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.

marcosbarbero avatar marcosbarbero commented on May 23, 2024

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.

lchayoun avatar lchayoun commented on May 23, 2024

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.

marcosbarbero avatar marcosbarbero commented on May 23, 2024

@lchayoun if you have time it would be awesome :)

from spring-cloud-zuul-ratelimit.

marcosbarbero avatar marcosbarbero commented on May 23, 2024

@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.

lchayoun avatar lchayoun commented on May 23, 2024

forked it again, seeing the same issue, taking a look

from spring-cloud-zuul-ratelimit.

marcosbarbero avatar marcosbarbero commented on May 23, 2024

@lchayoun thanks in a bunch

from spring-cloud-zuul-ratelimit.

marcosbarbero avatar marcosbarbero commented on May 23, 2024

@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.

marcosbarbero avatar marcosbarbero commented on May 23, 2024

@lchayoun here we go v1.3.3.RELEASE.

from spring-cloud-zuul-ratelimit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.