posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat: chron job to rate limit orgs based on usage

Open kappa90 opened this issue 3 years ago • 1 comments

Problem

We want to check if orgs are above their usage limit, and add them to a list of rate limited organizations.

To be released together with https://github.com/PostHog/posthog/pull/13519

Changes

Add a chron job to check if organization's stored usage (saved after talking to the billing service), which is relevant up to the day before, plus today's unreported usage, is bigger than the billing limit. If yes, we add the org_id to a set in redis, one for event rate limiting, one for recordings rate limiting.

Small edge case: this won't fully work if in the future we'll want to rate limit orgs across different environments (EU + US), as the unreported usage will only be related to one instance, which means we might rate limit with a delay of one day in that case.

How did you test this code?

Added tests for the rate limiting task

kappa90 avatar Dec 30 '22 13:12 kappa90

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Jan 11 '23 07:01 posthog-bot

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

posthog-bot avatar Jan 18 '23 07:01 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Jan 26 '23 07:01 posthog-bot