Skip to content

Commit d4aff1a

Browse files
committed
Pre-load offers catalog periodically
1 parent 2b942c6 commit d4aff1a

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/dstack/_internal/server/background/scheduled_tasks/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def start_scheduled_tasks() -> AsyncIOScheduler:
4141
"""
4242
# DateTrigger() to run one-time init tasks immediately.
4343
_scheduler.add_job(init_gateways_in_background, DateTrigger(), max_instances=1)
44+
# Pre-load catalog offers both on server start and before catalog needs reload (15m).
4445
_scheduler.add_job(preload_offers_catalog, DateTrigger(), max_instances=1)
46+
_scheduler.add_job(preload_offers_catalog, IntervalTrigger(minutes=10), max_instances=1)
4547
_scheduler.add_job(process_probes, IntervalTrigger(seconds=3, jitter=1))
4648
_scheduler.add_job(collect_metrics, IntervalTrigger(seconds=10), max_instances=1)
4749
_scheduler.add_job(delete_metrics, IntervalTrigger(minutes=5), max_instances=1)

src/dstack/_internal/server/background/scheduled_tasks/offers_catalog.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88

99
async def preload_offers_catalog():
10-
"""Pre-load the `gpuhunt` offers catalog so the first offer request doesn't pay the S3 download cost."""
11-
logger.debug("Pre-loading `gpuhunt` offers catalog")
12-
await run_async(gpuhunt.default_catalog)
13-
logger.debug("`gpuhunt` offers catalog pre-loaded")
10+
"""Pre-load the `gpuhunt` offers catalog so the get offer requests do not pay the catalog download cost."""
11+
logger.debug("Pre-loading offers catalog")
12+
catalog = gpuhunt.default_catalog()
13+
await run_async(catalog.load)
14+
logger.debug("Pre-loaded offers catalog")

0 commit comments

Comments
 (0)