From e6e282f1d3f4e01b52dc28870cf57eab29a75663 Mon Sep 17 00:00:00 2001 From: rUv Date: Mon, 23 Mar 2026 13:22:53 +0000 Subject: [PATCH] perf(brain): upgrade to 4 CPU / 4 GiB / 20 instances + rate limit WET injector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Cloud Run: 2 CPU → 4 CPU, 2 GiB → 4 GiB, max 10 → 20 instances - WET injector: 1s delay between batch injects to prevent brain saturation - Deploy script updated to match new resource allocation Co-Authored-By: claude-flow --- crates/mcp-brain-server/cloud/deploy-all.sh | 6 +++--- scripts/wet-filter-inject.js | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/mcp-brain-server/cloud/deploy-all.sh b/crates/mcp-brain-server/cloud/deploy-all.sh index 1fde8590..02b2e572 100755 --- a/crates/mcp-brain-server/cloud/deploy-all.sh +++ b/crates/mcp-brain-server/cloud/deploy-all.sh @@ -34,10 +34,10 @@ gcloud run deploy ruvbrain \ --region="$REGION" \ --project="$PROJECT_ID" \ --platform=managed \ - --memory=2Gi \ - --cpu=2 \ + --memory=4Gi \ + --cpu=4 \ --min-instances=1 \ - --max-instances=10 \ + --max-instances=20 \ --timeout=300 \ --concurrency=80 \ --session-affinity \ diff --git a/scripts/wet-filter-inject.js b/scripts/wet-filter-inject.js index b9ed97cf..f862efea 100755 --- a/scripts/wet-filter-inject.js +++ b/scripts/wet-filter-inject.js @@ -222,9 +222,14 @@ function generateTags(url, content) { return [...new Set(tags)].slice(0, 10); } +function sleep(ms) { return new Promise(r => setTimeout(r, ms)); } + async function flushBatch() { if (batch.length === 0) return; + // Rate limit: 1 batch per second to avoid saturating the brain + await sleep(1000); + const items = batch.splice(0); try { const res = await fetch(`${BRAIN_URL}/v1/pipeline/inject/batch`, {