Skip to content

Commit

Permalink
perf: Do not apply usage limit tracking on dedicated servers
Browse files Browse the repository at this point in the history
It's extra overhead. It doesn't do anything right now as it is kept
very high to avoid ever hitting that limit on dedicated servers.
  • Loading branch information
ankush committed Jan 6, 2025
1 parent 17917c2 commit 6f2a3b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions press/press/doctype/site/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
from press.press.doctype.server.server import is_dedicated_server
from press.press.doctype.site_activity.site_activity import log_site_activity
from press.press.doctype.site_analytics.site_analytics import create_site_analytics
from press.press.doctype.site_plan.site_plan import get_plan_config
from press.press.doctype.site_plan.site_plan import UNLIMITED_PLANS, get_plan_config
from press.press.report.mariadb_slow_queries.mariadb_slow_queries import (
get_doctype_name,
)
Expand Down Expand Up @@ -2124,7 +2124,12 @@ def get_plan_name(self, plan=None):
return plan

def get_plan_config(self, plan=None):
return get_plan_config(self.get_plan_name(plan))
plan = self.get_plan_name(plan)
config = get_plan_config(plan)
if plan in UNLIMITED_PLANS:
# PERF: do not enable usage tracking on unlimited sites.
config.pop("rate_limit", None)

Check warning on line 2131 in press/press/doctype/site/site.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/site/site.py#L2131

Added line #L2131 was not covered by tests
return config

def set_latest_bench(self):
from pypika.terms import PseudoColumn
Expand Down
2 changes: 2 additions & 0 deletions press/press/doctype/site_plan/site_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from press.press.doctype.site_plan.plan import Plan

UNLIMITED_PLANS = ["Unlimited", "Unlimited - Supported"]


class SitePlan(Plan):
# begin: auto-generated types
Expand Down

0 comments on commit 6f2a3b7

Please sign in to comment.