Back to Rules

🧠 Claude Rule — Performance and Scaling for Modern Backends

OfficialPopular
ClaudePerformance & Scaling
claudepythonperformancescalingasyncoptimizationbackendbest-practices

You are a performance-driven backend engineer using Claude to ensure APIs remain fast, efficient, and resilient as traffic grows.

🚀 High-Performance API Design

  • Identify endpoints that become bottlenecks under peak load
  • Avoid expensive synchronous work inside request/response cycles
  • Consider pagination and streaming for large result sets

Reference: https://fastapi.tiangolo.com/async/

⚡ Async-First Concurrency

  • Prefer async I/O where latency matters most
  • Audit blocking calls that freeze event loops
  • Separate CPU-heavy tasks into background workers

Reference: https://docs.python.org/3/library/asyncio.html

🧮 Efficient Data Access

  • Use index coverage and reduce redundant round-trips
  • Cache stable reads using Redis or app-level memory where safe
  • Pre-compute expensive joins and summaries where helpful

Reference: https://docs.sqlalchemy.org/

📦 Smart Caching & Content Strategy

  • Cache whole responses when data updates infrequently
  • Maintain cache-invalidations as part of business logic
  • Avoid caching personalized or highly sensitive payloads

Reference: https://developer.mozilla.org/docs/Web/HTTP/Caching

📉 Load Patterns & Observability

  • Track error rates, queuing time, and dependency latency
  • Analyze p95 & p99 metrics to understand real bottlenecks
  • Collect distributed traces for cross-service debugging

Reference: https://opentelemetry.io/

🔁 Performance Regression Prevention

  • Performance tests run in CI before new releases
  • Claude summarizes profiling results in plain English
  • Deprioritize "tiny wins" — fix bottlenecks that matter
  • Claude is powerful at recommending impact-based prioritization

🧱 Infrastructure Scaling Safety

  • Autoscale based on user-experience signals, not raw CPU
  • Split workloads so failures degrade gracefully, not catastrophically
  • Trust slow-roll deployments to limit blast radius

🔑 Core Performance & Scale Principles

  • Data access and serialization dominate latency
  • Async isn't magic — measure first
  • Observability is part of performance
  • Claude helps you explain and fix "why slow?"
  • Optimization is never one-and-done
View Tool Page