perf(brain): upgrade to 4 CPU / 4 GiB / 20 instances + rate limit WET injector

- 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 <ruv@ruv.net>
This commit is contained in:
rUv 2026-03-23 13:22:53 +00:00
parent 0e645302d1
commit e6e282f1d3
2 changed files with 8 additions and 3 deletions

View file

@ -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 \

View file

@ -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`, {