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

profile browser fixes: better resource usage + load retry (main) #1604

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions backend/btrixcloud/operator/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ def __init__(self):

self.has_pod_metrics = False
self.compute_crawler_resources()
self.compute_profile_resources()

def compute_crawler_resources(self):
"""compute memory / cpu resources for crawlers"""
p = self.shared_params
num = max(int(p["crawler_browser_instances"]) - 1, 0)
print("crawler resources")
if not p.get("crawler_cpu"):
base = parse_quantity(p["crawler_cpu_base"])
extra = parse_quantity(p["crawler_extra_cpu_per_browser"])
Expand All @@ -63,6 +65,23 @@ def compute_crawler_resources(self):
else:
print(f"memory = {p['crawler_memory']}")

def compute_profile_resources(self):
"""compute memory /cpu resources for a single profile browser"""
p = self.shared_params
# if no profile specific options provided, default to crawler base for one browser
profile_cpu = parse_quantity(
p.get("profile_browser_cpu") or p["crawler_cpu_base"]
)
profile_memory = parse_quantity(
p.get("profile_browser_memory") or p["crawler_memory_base"]
)
p["profile_cpu"] = profile_cpu
p["profile_memory"] = profile_memory

print("profile browser resources")
print(f"cpu = {profile_cpu}")
print(f"memory = {profile_memory}")

async def async_init(self):
"""perform any async init here"""
self.has_pod_metrics = await self.is_pod_metrics_available()
Expand Down
6 changes: 3 additions & 3 deletions chart/app-templates/profilebrowser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ spec:

resources:
limits:
memory: "{{ crawler_memory }}"
memory: "{{ profile_memory }}"

requests:
cpu: "{{ crawler_cpu }}"
memory: "{{ crawler_memory }}"
cpu: "{{ profile_cpu }}"
memory: "{{ profile_memory }}"
5 changes: 5 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ crawler_extra_memory_per_browser: 768Mi
# crawler_memory = crawler_memory_base + crawler_memory_per_extra_browser * (crawler_browser_instances - 1)
# crawler_memory:

# optional: defaults to crawler_memory_base and crawler_cpu_base if not set
# profile_browser_memory:
#
# profile_browser_cpu:

# Other Crawler Settings
# ----------------------

Expand Down
12 changes: 12 additions & 0 deletions frontend/src/features/browser-profiles/profile-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,18 @@ export class ProfileBrowser extends LiteElement {

return;
} else if (result.url) {
// check that the browser is actually available
// if not, continue waiting
// (will not work with local frontend due to CORS)
try {
const resp = await fetch(result.url, { method: "HEAD" });
if (!resp.ok) {
return;
}
} catch (e) {
// ignore
}

if (this.initialNavigateUrl) {
await this.navigateBrowser({ url: this.initialNavigateUrl });
}
Expand Down