CommandOpen
profile-api
Profile an API endpoint to identify performance bottlenecks and optimization opportunities.
Front matter
name: profile-api
description: Profile an API endpoint to identify performance bottlenecks and optimization opportunities.Profile an API endpoint to identify performance bottlenecks and optimization opportunities.
Steps
- Identify the target endpoint (URL, method, and payload).
- Analyze the handler code path:
- Map all database queries executed per request.
- Identify external API calls and their expected latency.
- Check for synchronous blocking operations.
- Look for N+1 query patterns.
- Measure baseline performance:
- Send sample requests and measure response time.
- Check memory allocation during request handling.
- Identify the slowest operations in the call chain.
- Check for common performance issues:
- Missing database indexes for frequently queried columns.
- Unbounded result sets without pagination.
- Redundant data fetching (loading full objects when only IDs needed).
- Missing caching for expensive computations.
- Large response payloads without compression.
- Suggest optimizations ranked by expected impact:
- Add database indexes.
- Implement caching layer.
- Batch database queries.
- Add pagination.
- Enable response compression.
- Estimate performance improvement for each suggestion.
Format
Profile: <METHOD> <endpoint>
Baseline: <response time>ms (P50), <P99>ms (P99)
Bottlenecks:
1. [HIGH] <description> - estimated <N>ms savings
2. [MEDIUM] <description> - estimated <N>ms savings
Optimizations:
1. <specific action to take>
2. <specific action to take>
Expected improvement: <N>% faster response timeRules
- Profile with realistic data volumes, not empty databases.
- Measure P50, P95, and P99 latencies, not just averages.
- Identify the single biggest bottleneck before suggesting broad optimizations.
- Never suggest premature optimization for endpoints under 100ms.
- Consider read vs write path optimizations separately.
Author: rohitg00, Claude Code toolkit (rohitg00). License: Apache-2.0.
Shown here with formatting for the web. Keep the author and license notice when you reuse it.
Related entries
There are more like this in the members library
The Codex library holds 7,009 entries. Members can search all of them by meaning and read every one in full.