Giter VIP home page Giter VIP logo

Comments (4)

scale-tone avatar scale-tone commented on June 1, 2024 1

whoever has a gold subscription will have 100 requests per second, silver will have 10 requests per second, and bronze will have 1 request per second

Oh, that can be achieved with a CostExtractor.

Set the limit to 100 coins, and then a bronze chap should be charged 100 coins per request, a silver guy should pay 10 coins and a gold fellow pays just 1.

Sounds good? :)

from throttlingtroll.

scale-tone avatar scale-tone commented on June 1, 2024

Alternatively, is there an easier way to implement this that I am not seeing?

Hi @kayhantolga, if you want each of your 100K clients to be throttled individually, you just need to provide an IdentityIdExtractor.

As per documentation:

When IdentityIdExtractor is specified and IdentityId is not - different identityIds will automatically get their own rate counters, one counter per each unique identityId.

Code example.

Let me know if I understood your usecase correctly.

from throttlingtroll.

kayhantolga avatar kayhantolga commented on June 1, 2024

Hi, thanks for the reply. I understand the sample and have already tried it. It works quite well with a small number of clients. But in practice, injecting 100k rules will be quite challenging in terms of performance. So, I was thinking of grouping these clients. As an example, whoever has a gold subscription will have 100 requests per second, silver will have 10 requests per second, and bronze will have 1 request per second. This way, I only need to inject 3 rules. Additionally, I need to decide the user's rule in the IdentityIdExtractor.

from throttlingtroll.

kayhantolga avatar kayhantolga commented on June 1, 2024

Weirdly, I thought about that before but couldn't figure out how to implement it. But when I looked again, now it looks quite easy. Thanks a lot.

from throttlingtroll.

Related Issues (18)

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.