profile browser fixes: better resource usage + load retry (main) (#1604)
- Backend: Use separate resource constraints for profiles: default profile browser resources to either 'profile_browser_cpu' / 'profile_browser_memory' or single browser 'crawler_memory_base' / 'crawler_cpu_base', instead of scaled to the number of browser workers - Frontend: check that profile html page is loading, keep retrying if still getting nginx error instead of loading an iframe with the error. Fixes #1598 (Copy of #1599 from 1.9.4)
This commit is contained in:
parent
960f54bf4e
commit
e7af081af1
@ -36,11 +36,13 @@ class K8sOpAPI(K8sAPI):
|
|||||||
|
|
||||||
self.has_pod_metrics = False
|
self.has_pod_metrics = False
|
||||||
self.compute_crawler_resources()
|
self.compute_crawler_resources()
|
||||||
|
self.compute_profile_resources()
|
||||||
|
|
||||||
def compute_crawler_resources(self):
|
def compute_crawler_resources(self):
|
||||||
"""compute memory / cpu resources for crawlers"""
|
"""compute memory / cpu resources for crawlers"""
|
||||||
p = self.shared_params
|
p = self.shared_params
|
||||||
num = max(int(p["crawler_browser_instances"]) - 1, 0)
|
num = max(int(p["crawler_browser_instances"]) - 1, 0)
|
||||||
|
print("crawler resources")
|
||||||
if not p.get("crawler_cpu"):
|
if not p.get("crawler_cpu"):
|
||||||
base = parse_quantity(p["crawler_cpu_base"])
|
base = parse_quantity(p["crawler_cpu_base"])
|
||||||
extra = parse_quantity(p["crawler_extra_cpu_per_browser"])
|
extra = parse_quantity(p["crawler_extra_cpu_per_browser"])
|
||||||
@ -63,6 +65,23 @@ class K8sOpAPI(K8sAPI):
|
|||||||
else:
|
else:
|
||||||
print(f"memory = {p['crawler_memory']}")
|
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):
|
async def async_init(self):
|
||||||
"""perform any async init here"""
|
"""perform any async init here"""
|
||||||
self.has_pod_metrics = await self.is_pod_metrics_available()
|
self.has_pod_metrics = await self.is_pod_metrics_available()
|
||||||
|
|||||||
@ -78,8 +78,8 @@ spec:
|
|||||||
|
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: "{{ crawler_memory }}"
|
memory: "{{ profile_memory }}"
|
||||||
|
|
||||||
requests:
|
requests:
|
||||||
cpu: "{{ crawler_cpu }}"
|
cpu: "{{ profile_cpu }}"
|
||||||
memory: "{{ crawler_memory }}"
|
memory: "{{ profile_memory }}"
|
||||||
|
|||||||
@ -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 = crawler_memory_base + crawler_memory_per_extra_browser * (crawler_browser_instances - 1)
|
||||||
# crawler_memory:
|
# crawler_memory:
|
||||||
|
|
||||||
|
# optional: defaults to crawler_memory_base and crawler_cpu_base if not set
|
||||||
|
# profile_browser_memory:
|
||||||
|
#
|
||||||
|
# profile_browser_cpu:
|
||||||
|
|
||||||
# Other Crawler Settings
|
# Other Crawler Settings
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|
||||||
|
|||||||
@ -301,6 +301,18 @@ export class ProfileBrowser extends LiteElement {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (result.url) {
|
} 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) {
|
if (this.initialNavigateUrl) {
|
||||||
await this.navigateBrowser({ url: this.initialNavigateUrl });
|
await this.navigateBrowser({ url: this.initialNavigateUrl });
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user