Linux Performance Optimization Guide
Expert template for diagnosing and tuning Linux server performance with benchmarks, exact commands, and safe rollback guidance.
// prompt
You are a senior Linux performance engineer with deep expertise in kernel tuning, observability, and capacity planning across production fleets. Produce a precise, actionable optimization plan for the server below — not generic advice.
## Context
- **Distribution & Version:** {{linux_distribution}}
- **Server Role / Workload:** {{server_role}}
- **Hardware:** {{cpu_cores_ram_storage_type}}
- **Reported Symptom:** {{performance_symptom}}
- **Performance Goal:** {{target_metric}}
## What To Deliver
**1. Triage & Baseline**
- List the exact commands to capture a baseline (CPU, memory, disk I/O, network) and what "normal" vs "concerning" values look like for this workload.
- Tools to cover: `top`/`htop`, `vmstat`, `iostat`/`iotop`, `sar`, `ss`, `dmesg`.
**2. Bottleneck Diagnosis**
- Walk through a decision tree that isolates whether the issue is CPU-, memory-, I/O-, or network-bound based on the symptom above.
- For each resource, name the key metric and threshold that confirms saturation.
**3. Optimization Actions**
- Recommend concrete changes ordered by impact-to-risk: kernel/sysctl parameters, scheduler and I/O queue settings, filesystem/mount options, service and `systemd` limits, and network stack tuning.
- For every change, give the exact config line or command, the file it lives in, and a one-line rationale.
**4. Validation**
- Define a before/after benchmark for {{target_metric}} and the load-testing method to prove the gain.
## Output Format
- Use the headings above with command blocks in fenced code.
- Flag any change that requires a reboot or risks downtime with a **⚠ Caution** note.
- End with a prioritized checklist (quick wins first) and a brief rollback note for each major change.
If the context is too thin to be specific, ask for the missing detail before recommending changes.
Fill in the variables
Example response
System Performance Analysis
1. CPU Monitoring
# Check current CPU usage
top -bn1 | grep "Cpu(s)"
htop # Interactive process viewer
2. Memory Optimization
# Free up memory cache
echo 3 > /proc/sys/vm/drop_caches
# Check memory usage
free -h
3. Disk I/O Performance
# Monitor disk activity
iotop -ao
iostat -x 1
Key Recommendations
- Set up monitoring with
sarfor historical data - Optimize kernel parameters in
/etc/sysctl.conf - Configure proper swap settings
Related prompts
IT & Administration
Docker Container Builder
Generates production-ready, optimized Dockerfiles with multi-stage builds, caching, and tagging for any application.
IT & Administration
Kubernetes Resource Diagnostics
Diagnoses a failing Kubernetes resource and returns root cause plus a step-by-step fix.
IT & Administration
Server Monitoring and Alerting Setup
Designs a complete server monitoring, alerting, and dashboard plan tailored to your specific infrastructure.
IT & Administration
Cloud Infrastructure Architect
Design a scalable, secure, cost-optimized cloud architecture with IaC, diagrams, and a phased rollout plan.