oslabs-beta / GraphQL-Gate

A GraphQL rate limiting library with query complexity analysisfor Node.js
http://graphqlgate.io
MIT License
57 stars 2 forks source link

Implement Sliding Window Counter Algorithm #65

Closed jondeweydev closed 2 years ago

shalarewicz commented 2 years ago

This algorithm can be implemented using two separate approaches:

  1. Calculating a rolling average (Requests in current window + requests in the previous window * overlap percentage of the rolling window and previous window) Pros:

    • This smooths out spikes in traffic since rate is based on average rate of previous window
    • memory efficient Cons:
    • Works for not-so-strick lookback window.
    • Approximation of the actual rate (maybe only 0.003%) of requests incorrectly limited.
  2. https://medium.com/@saisandeepmopuri/system-design-rate-limiter-and-data-modelling-9304b0d18250

shalarewicz commented 2 years ago

Should implement spec in #68 and pass tests in #70