From 50cef50289b5a291d82846cff1ba32e0a1dce402 Mon Sep 17 00:00:00 2001 From: Semih Yesilyurt Date: Sun, 21 Jun 2026 10:05:31 +0300 Subject: [PATCH] =?UTF-8?q?feat(prefetch):=20backfill=20BFS=20derinli?= =?UTF-8?q?=C4=9Fini=205=E2=86=922'ye=20indir=20(s=C4=B1=C4=9F=20pre-warm?= =?UTF-8?q?=20+=20tembel=20derin)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exhaustive depth-5 pre-warm ~460k'lık sınırsız BFS fan-out üretiyordu, hiç drenaj olmuyor ve faydalı sığ + reactive işi açlığa düşürüyordu. Üst ~2 seviyeyi her decode edilmiş araç için pre-warm etmek sınırlı iş (günlerde biter), boş katalog sayfasını öldürür, ilk tıklamaları anında yapar. Derin kategoriler on-view (getCategoryTree) tembel çekilip kalıcı cache'lenir. Env-tunable: PREFETCH_MAX_DEPTH. MAX_DEPTH guard mevcut derin job'ları no-op'a çevirir (PL24'e yük yok). Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/api/src/jobs/prefetch-worker.service.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/api/src/jobs/prefetch-worker.service.ts b/apps/api/src/jobs/prefetch-worker.service.ts index d66fa52..6650811 100644 --- a/apps/api/src/jobs/prefetch-worker.service.ts +++ b/apps/api/src/jobs/prefetch-worker.service.ts @@ -26,7 +26,18 @@ import { import { PrefetchCategoryJobData, PrefetchInitJobData } from "./prefetch.types"; import { CATALOG_PREFETCH_QUEUE } from "./queues/catalog-prefetch.queue"; -const MAX_DEPTH = 5; +/** + * How deep the background prefetch BFS drills the category tree. + * + * Kept SHALLOW (2) on purpose: pre-warming the top ~2 levels for every decoded + * vehicle is bounded work that finishes in days, kills empty catalog pages, and + * makes the first clicks instant. Deeper categories are fetched lazily on-view + * (getCategoryTree in CategoriesService) and cached permanently — so the long + * tail nobody opens never costs an upstream request. Exhaustive depth-5 + * pre-warm produced an unbounded BFS fan-out (~460k jobs) that never drained + * and starved the useful shallow + reactive work. Env-tunable. + */ +const MAX_DEPTH = Number(process.env.PREFETCH_MAX_DEPTH) || 2; // ── Backfill scan (hourly cron) tuning ── /**