Skip to content

perf: land the MCP cost fix (never merged in #18) + lower rate limit 20->5 - #19

Merged
abrahamperz merged 3 commits into
mainfrom
fix/lower-mcp-rate-limit
Oct 10, 2026
Merged

abrahamperz merged 3 commits into
mainfrom
fix/lower-mcp-rate-limit

Conversation

@abrahamperz

Copy link
Copy Markdown
Owner

⚠️ Importante

El PR #18 solo mergeó el cambio de PostHog (analytics.py). El commit grande que de verdad corta el gasto (acotar el crawl del MCP) se pusheó a la rama después del merge y quedó huérfano — nunca entró a main ni se desplegó. Este PR lo recupera (cherry-pick) y además baja el rate limit.

Qué incluye

1. El fix de costo que faltaba (lo que mueve la gráfica):

  • mcp_http: HOSTED_TIMEOUT = 5s por página; topes MAX_PAGES 10→8, MAX_COMPARE_PAGES 6→5. Peor caso ~8×5 = 40s, dentro del presupuesto.
  • mcp_server.focused_crawl / compare_strategies: se threadea timeout (default 10s intacto para local).
  • vercel.json: maxDuration landing 60→10, MCP 60→45.
  • tests actualizados.

2. Nuevo — bajar el rate limit:

  • RATE_LIMIT 20 → 5 req/min por IP. Corta el volumen que una sola IP puede meter al /mcp. Best-effort (en memoria, por instancia caliente), así que frena una IP martillando sin ser tope duro.

Contexto

En Hobby la memoria está fija en 1 GB, así que las únicas palancas de costo son duración (fix 1) y volumen (fix 2). El MCP era el 99% del gasto con ~20% de timeouts de 60s.

Tras merge + redeploy

  • Timeouts del MCP deberían desplomarse; duración media ↓ → GB-Hours y Active CPU ↓.
  • Verificar con la barra del día completo ~24h después.

🤖 Generated with Claude Code

abrahamperz and others added 2 commits October 10, 2026 09:01
The hosted MCP (web/mcp) was the real cost driver: ~20% of invocations
hit the 60s wall because focused_crawl fetches up to 10 pages at a 10s
per-page timeout (worst case 100s). On Hobby memory is fixed at 1 GB, so
duration is the only lever.

- mcp_server.focused_crawl/compare_strategies: thread a `timeout` param
  down to the strategy/compare calls (default 10s unchanged for local).
- mcp_http: pass HOSTED_TIMEOUT=5s per page; lower caps MAX_PAGES 10->8
  and MAX_COMPARE_PAGES 6->5. Worst case now ~8*5=40s, inside budget.
- vercel.json: maxDuration landing 60->10, MCP 60->45.
- tests: assert the hosted handlers forward the tighter timeout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cuts the volume a single client can push at the hosted /mcp endpoint,
which is the main remaining cost driver. Best-effort (in-memory, per
warm instance), so it throttles a hammering IP without being a hard cap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bytecrawl Ready Ready Preview Oct 10, 2026 3:05pm UTC

The landing /crawl demo fetches up to 20 pages and needs ~60s; 10s would
kill it mid-crawl. Landing cost is negligible (~0.0038 GB-Hrs), so lowering
it saves nothing while breaking a feature. Only the MCP is capped (45s).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@abrahamperz
abrahamperz merged commit 63e2b98 into main Oct 10, 2026
8 checks passed

This branch was successfully deployed

1 active deployment
Preview — 9696c86e Deployed Oct 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant