agentleFS
contactandrewchl-wqcontactandrewchl-wq/turtle-mcp/skills/backend-performance/SKILL.md

backend-performance

Skill2 starsChanged 5 months agoMITView on GitHub

Diagnóstico y optimización de performance backend: medir antes de optimizar, cachés correctas, batching, índices, conexiones, async, perfiles de CPU/IO. Cargá cuando hay un cuello reportado o un endpoint crítico.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test de carga reproducible (k6 script en repo) antes y después.

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Backend performance

Cuándo usar

  • Latencia o throughput por debajo del SLO.
  • Endpoint nuevo en ruta crítica.
  • Antes de un evento de tráfico alto.

No cargar para optimizaciones especulativas sin medición.

Disciplina

  1. Medí primero. Sin perfil, no hay diagnóstico, hay opinión.
  2. Optimizá el cuello. Mejorar lo que ya es rápido es trabajo perdido.
  3. Comprobá el efecto. Si no medís después, no sabés si ayudó.

Mediciones base

  • Latencia p50/p95/p99 por endpoint.
  • Throughput (req/s) sostenido sin degradar.
  • Recursos: CPU, memoria, IO, conexiones a BD, cola.
  • Distribución: ¿es lento siempre o por colas? Histograma > promedio.

Herramientas

CapaHerramienta
CPU/IO/lockperf, pprof, py-spy, clinic.js, async-profiler
QueriesEXPLAIN ANALYZE, pg_stat_statements, slow query log
TrazasOpenTelemetry + Jaeger/Tempo (ver [[backend-observability]])
HTTPk6, vegeta, wrk para carga
Memoriaheap dump + analizador del runtime

Patrones que suelen pagar

Base de datos (suele ser el 80%)

  • N+1 → eager loading / JOIN. Detectá con conteo de queries por request.
  • Índice faltante en WHERE/JOIN/ORDER BY frecuente. EXPLAIN para confirmar uso.
  • SELECT * → seleccioná solo lo que usás (menos IO, menos transferencia).
  • Pool de conexiones del tamaño correcto (no infinito). (núcleos * 2) + spindles es una base.
  • Read replicas para queries pesadas de lectura, si la consistencia eventual sirve.

Caché

Niveles, del más barato al más caro:

  1. Memoization del proceso — para cálculos puros, invalida con LRU.
  2. Caché distribuida (Redis) — para datos compartidos. TTL razonable.
  3. CDN / edge — para respuestas idempotentes públicas.

Toda caché necesita estrategia de invalidación. Sin esa, es bug en cámara lenta. Cache stampede → single-flight o lock corto.

Batching y bulk

  • Operaciones en N items en una sola query, no N queries.
  • INSERT ... VALUES (...), (...), (...) o COPY en Postgres.
  • Para HTTP: agrupá calls a APIs externas en uno cuando lo permite.

Async y colas

  • Tareas que no necesitan respuesta inmediata → cola (BullMQ, Sidekiq, Celery, Tigris, jobs propios).
  • Reintentos exponenciales con tope; DLQ para los que fallan persistente.
  • Timeouts en toda llamada a red (HTTP, BD, cache). Sin timeout = hang propagado.

Concurrencia

  • Limitá la concurrencia entrante (rate limit, semáforo) para no inundar el downstream.
  • En Node/Python async: cuidá CPU-bound dentro del event loop → worker threads / multiprocess.
  • En Go/Rust: cuidá bloqueos largos en pools de goroutines/tasks.

Reglas duras

  • Sin optimización sin perfil. Microbench ≠ producción.
  • Sin caché sin TTL e invalidación pensadas.
  • Sin llamada de red sin timeout.
  • Sin retry sin backoff y tope. Tormenta de retries = autoataque.

Validación

  • Test de carga reproducible (k6 script en repo) antes y después.
  • p95 dentro de SLO bajo carga objetivo.
  • Sin regresión de error rate ni de uso de recursos en el ambiente de stress.

Relacionadas

[[backend-data-modeling]] · [[backend-observability]] · [[backend-api-design]]

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.