question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RateLimiter Question/Enhancement: Reduce memory footprint of high cardinality keys

See original GitHub issue

I’d like to rate limit access to an operation that’s relatively expensive. My intention is to prevent some customers from over-utilizing my application since that could potentially result in degraded performance for other customers (multi-tenant application).

My application creates a wide key space for each of my customer; about 100 keys on average. I’d like to rate limit on these customer keys rather than on the customer identifier itself. If I have 5,000 customers using my application, this could translate to 5,000 * 100 = 500,000 Rate limiter keys.

Since stale/unused entries in RateLimiter registry aren’t cleaned up automatically (please correct my if I’m wrong), the memory footprint becomes significant.

I understand that I can override RateLimiterRegistry and perform cleanup on my side, but I feel this is not an uncommon use-case for a Rate Limiter and would like to get your thoughts on introducing 2 new config keys:

  1. expiryTime - determines the duration after which each unused rate limiter key will be marked as stale.
  2. cleanupInterval - determines the rate at which stale keys are cleaned up.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
RobWincommented, Oct 27, 2020

Thank you for this PR

1reaction
asarkarcommented, Oct 23, 2020

@RobWin I see, so the idea is to use many rate limiters (presumably one per user), but have them “garbage collected”, if you may, after expiration. Now it makes sense to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Identifying Cardinality Problems - Manning
Increased memory usage for routine scheduled operations. Scheduled optimization procedures in some storage systems are impacted by cardinality.
Read more >
How to reduce your Power BI model size by 90%! - Data Mozart
As you see, even if the chatID column has higher cardinality than the datetmStartUTC column, it takes almost 8 times less memory!
Read more >
How to deal with Features having high cardinality - Kaggle
I am trying to run a machine learning problem using scikit learn on a dataset and one of the columns(feature) has high cardinality...
Read more >
Resolve high series cardinality | InfluxDB Cloud Documentation
Reduce high series cardinality in InfluxDB. ... High series cardinality is a primary driver of high memory usage for many database workloads.
Read more >
Optimizing distinctcount with reduced memory consumption in ...
Since the PowerBI data model resides on a columnar database, having high cardinality columns impact both performance and the size of the model....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found