Systematically identify and resolve performance issues to improve latency, throughput, and resource usage.
Profiling Approach
- Identify hot paths: database queries, external API calls, CPU-intensive computations, and I/O operations.
- Use language-specific profilers (cProfile, Node.js --inspect, Go pprof) to gather baseline metrics.
- Focus on the 80/20 rule: optimize the small fraction of code causing most of the delay.
Caching Strategies
- Application cache: In-memory (Redis, Memcached) for frequently accessed, rarely changing data.
- HTTP cache: ETag, Cache-Control headers for static and semi-static responses.
- Query cache: Cache expensive DB queries with appropriate TTL and invalidation.
- Computation cache: Memoize pure functions with deterministic inputs.
- Document cache invalidation rules to avoid stale data.