Skip to content

perf: cut Vercel GB-Hours/CPU — bound hosted MCP crawl + disable PostHog - #18

Merged
abrahamperz merged 1 commit into
mainfrom
fix/disable-posthog-analytics
Oct 9, 2026
Merged

abrahamperz merged 1 commit into
mainfrom
fix/disable-posthog-analytics

Conversation

@abrahamperz

@abrahamperz abrahamperz commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Contexto

Las gráficas de Provisioned Memory y Active CPU de Vercel subieron a una meseta desde finales de septiembre. Observability mostró que el gasto viene casi todo de /web/mcp/mcp_app.py (el MCP hospedado): ~526 inv / 15 GB-Hrs / 20% de timeouts en 12h. El landing es despreciable (24 inv / 0.0038 GB-Hrs).

En plan Hobby la memoria está fija en 1 GB, así que la única palanca de costo es la duración (y el nº de llamadas).

Causa de los timeouts

focused_crawl baja hasta 10 páginas con 10s de timeout por página → peor caso 100s → muere en el límite de 60s, facturando el máximo.

Cambios

MCP (lo que mueve la factura):

  • mcp_server.focused_crawl / compare_strategies: se threadea un parámetro timeout hasta el crawler/compare (default 10s intacto para uso local).
  • mcp_http: el server hospedado pasa HOSTED_TIMEOUT = 5s por página y baja los topes MAX_PAGES 10→8, MAX_COMPARE_PAGES 6→5. Peor caso ~8×5 = 40s, dentro del presupuesto.
  • vercel.json: maxDuration landing 60→10, MCP 60→45.
  • tests: verifican que los handlers hospedados reenvían el timeout corto.

Higiene (no mueve la factura, pero quita un hilo de fondo):

  • web/landing/analytics.py: PostHog con disabled=True + enable_exception_autocapture=False.

Tradeoff

Los crawls hospedados devuelven máx. 8 páginas (antes 10) y se rinden en páginas lentas a los 5s (antes 10s). Sano para un server público.

Esperado tras merge + redeploy

  • Timeouts del MCP se desploman (ya no se pega a 60s).
  • Duración media ↓ → GB-Hours y Active CPU ↓.
  • Confirmar mirando la gráfica ~24h después.

Nota: también conviene revisar por qué 526 inv/12h al MCP (¿agente en loop / bots?). Eso es aparte de este PR.

🤖 Generated with Claude Code

The posthog-python consumer runs a background thread that, under Fluid,
kept the serverless instance warm — billing provisioned memory and
Active CPU 24/7 (the flat plateau from late Sep onward). Disable the
client so track()/flush() are no-ops and the instance can idle. Events
stop flowing; re-enable by removing disabled=True.

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

vercel Bot commented Oct 9, 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 9, 2026 11:27pm UTC

@abrahamperz
abrahamperz merged commit e9d76f8 into main Oct 9, 2026
8 checks passed
@abrahamperz abrahamperz changed the title perf: disable PostHog client to stop continuous memory/CPU billing perf: cut Vercel GB-Hours/CPU — bound hosted MCP crawl + disable PostHog Oct 9, 2026
abrahamperz added a commit that referenced this pull request Oct 10, 2026
…20->5 (#19)

* perf: bound hosted MCP crawl time to stop 60s timeouts and cut GB-Hours

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>

* perf: lower hosted MCP rate limit 20 -> 5 req/min per IP

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>

* fix: keep landing maxDuration at 60s (its analyzer crawls 20 pages)

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>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 1c0f328a Deployed Oct 9, 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