Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completions: Switch to daily window for rate limiting #51200

Merged
merged 1 commit into from
Apr 27, 2023
Merged

Conversation

eseliger
Copy link
Member

After discussing the limits yesterday, we've decided to go with a daily cap vs a lower hourly cap to help most users have a productive, uninterrupted experience with cody.

Test plan

Tests, tried that the expiry is set correctly.

After discussing the limits yesterday, we've decided to go with a daily cap vs a lower hourly cap to help most users have a productive, uninterrupted experience with cody.
@sg-e2e-regression-test-bob

Bundle size report 📦

Initial size Total size Async size Modules
0.00% (0.00 kb) -0.00% (-0.00 kb) -0.00% (-0.00 kb) 0.00% (0)

Look at the Statoscope report for a full comparison between the commits 60ca36f and faf80a2 or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@eseliger eseliger requested a review from a team April 27, 2023 10:19
@@ -2086,8 +2086,8 @@
"default": "anthropic",
"enum": ["anthropic", "openai"]
},
"perUserHourlyLimit": {
"description": "If > 0, enables the maximum number of completions requests allowed to be made by a single user account in an hour. On instances that allow anonymous requests, the rate limit is enforced by IP.",
"perUserDailyLimit": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how we usually do site config structure migrations. What happens to the site config of existing deployments after this change? I see no migration, so if perUserHourlyLimit is set, the config state practically becomes invalid. Do we automatically disregard the old key?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it a day ago and didn’t put it anywhere so I think this time we‘re fine just changing it’s name. Usually it’d be good to fall back, agreed 🙂

// If it did exist before, it should have an expiry set already, so the TTL >= 0
// makes sure that we don't overwrite it and restart the 1h bucket.
ttl, err := rstore.TTL(key)
if err != nil {
return errors.Wrap(err, "failed to get TTL for rate limit counter")
}
if ttl < 0 {
if err := rstore.Expire(key, int(time.Hour/time.Second)); err != nil {
if err := rstore.Expire(key, int(24*time.Hour/time.Second)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked this from a migration perspective: the only caveat is that if a user already has a 1h window open then the daily limit will apply to it, but then in max. 1h, it'll expire, and the next 24h window will open with the correct limit. I think we can live with this. 🙂

Copy link
Contributor

@vdavid vdavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I checked if we mention rate limits in the docs to ensure that we update that as well, but I found no info about it. Just a mental note that it would be nice to document the rate limit info eventually.

@eseliger
Copy link
Member Author

LGTM. I checked if we mention rate limits in the docs to ensure that we update that as well, but I found no info about it. Just a mental note that it would be nice to document the rate limit info eventually.

Yep, we are going to roll this out tomorrow probably, and that should include documentation about it :)

@eseliger eseliger merged commit 8a3bc68 into main Apr 27, 2023
21 checks passed
@eseliger eseliger deleted the es/daily-limit branch April 27, 2023 11:13
camdencheek pushed a commit that referenced this pull request May 15, 2023
After discussing the limits yesterday, we've decided to go with a daily
cap vs a lower hourly cap to help most users have a productive,
uninterrupted experience with cody.

(cherry picked from commit 8a3bc68)
camdencheek pushed a commit that referenced this pull request May 16, 2023
After discussing the limits yesterday, we've decided to go with a daily
cap vs a lower hourly cap to help most users have a productive,
uninterrupted experience with cody.

(cherry picked from commit 8a3bc68)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants