serialize batch image processing requests
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-03-11 09:25:17 +08:00
parent 82233b5f3a
commit 0a2b8b3045
2 changed files with 16 additions and 4 deletions

View File

@ -56,7 +56,8 @@ const SCENE_FUSION_MODEL_COOLDOWN_MS = 2 * 60 * 1000;
const SCENE_FUSION_MAX_ITEMS = 10;
const SCENE_FUSION_REQUEST_STAGGER_MS = 350;
const SCENE_FUSION_AGENT_TIMEOUT_MS = 20000;
const SCENE_FUSION_AGENT_MAX_WORKERS = 2;
const SCENE_FUSION_AGENT_MAX_WORKERS = 1;
const SCENE_FUSION_PROCESS_MAX_WORKERS = 1;
const SCENE_FUSION_PRE_RMBG_TIMEOUT_MS = 60_000;
const SCENE_FUSION_ECHO_HASH_TIMEOUT_MS = 20_000;
const SCENE_FUSION_ECHO_HASH_THRESHOLD = 8;
@ -1895,7 +1896,11 @@ export async function POST(request: Request) {
let nextSceneIndex = 0;
const workerCount = Math.max(
1,
Math.min(4, candidateModels.length, processedScenes.length)
Math.min(
SCENE_FUSION_PROCESS_MAX_WORKERS,
candidateModels.length,
processedScenes.length
)
);
const workers = Array.from({ length: workerCount }, async () => {

View File

@ -39,6 +39,7 @@ import { cn } from "@/lib/utils";
const fetcher = (url: string) => fetch(url).then((res) => res.json());
const MAX_BATCH_ITEMS = 10;
const BATCH_REQUEST_STAGGER_MS = 700;
const BATCH_SERIAL_WORKER_COUNT = 1;
const MULTI_PRODUCT_FAILOVER_MAX_ROUNDS = 5;
const MULTI_PRODUCT_FAILOVER_RETRY_DELAY_MS = 1500;
@ -977,7 +978,10 @@ export function SceneFusionView({
);
const queue = [...itemsToProcess];
const workerCount = Math.max(1, Math.min(2, queue.length));
const workerCount = Math.max(
1,
Math.min(BATCH_SERIAL_WORKER_COUNT, queue.length)
);
let successCount = 0;
let failedCount = 0;
@ -1148,7 +1152,10 @@ export function SceneFusionView({
);
const queue = [...itemsToProcess];
const workerCount = Math.max(1, Math.min(3, queue.length));
const workerCount = Math.max(
1,
Math.min(BATCH_SERIAL_WORKER_COUNT, queue.length)
);
let successCount = 0;
let failedCount = 0;