Repository navigation
perf: cut Vercel GB-Hours/CPU — bound hosted MCP crawl + disable PostHog - #18
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_crawlbaja 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ámetrotimeouthasta el crawler/compare (default 10s intacto para uso local).mcp_http: el server hospedado pasaHOSTED_TIMEOUT = 5spor página y baja los topesMAX_PAGES 10→8,MAX_COMPARE_PAGES 6→5. Peor caso ~8×5 = 40s, dentro del presupuesto.vercel.json:maxDurationlanding 60→10, MCP 60→45.Higiene (no mueve la factura, pero quita un hilo de fondo):
web/landing/analytics.py: PostHog condisabled=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
🤖 Generated with Claude Code