- Alert Name: HighCPUUsage
- Severity: Warning
- Threshold: CPU > 80% for 10 minutes
- Slow application response times
- Increased latency
- Potential service degradation
# Check current CPU usage
docker stats nova-backend --no-stream
# System-wide CPU
top -bn1 | head -20
# Per-process CPU
ps aux --sort=-%cpu | head -10# Inside container
docker exec -it nova-backend top -bn1
# Node.js process details
docker exec -it nova-backend ps aux | grep node# Recent logs
docker logs nova-backend --tail 200 --follow
# Look for infinite loops or heavy operations
docker logs nova-backend 2>&1 | grep -i "processing\|computing\|calculating"# Generate CPU profile (if profiling enabled)
docker exec -it nova-backend node --prof server.js
# Or use clinic.js
docker exec -it nova-backend clinic doctor -- node server.jsSymptoms: Single process consuming 100% CPU
Solution:
# Identify the problematic code from logs
# Restart service immediately
docker restart nova-backend
# Deploy hotfix to resolve infinite loopSymptoms: CPU spikes during specific operations
Solution:
# Identify expensive operations
# Move to background job queue
# Optimize algorithm
# Add cachingSymptoms: CPU increases with request rate
Solution:
# Scale horizontally
docker-compose up -d --scale backend=3
# Or on AWS
aws autoscaling set-desired-capacity \
--auto-scaling-group-name nova-rewards-asg \
--desired-capacity 4
# Enable rate limiting
# Optimize hot pathsSymptoms: High CPU with increasing memory
Solution:
# Check memory usage
docker stats nova-backend
# Restart to free memory
docker restart nova-backend
# Investigate memory leak
# Take heap snapshot for analysisSymptoms: CPU high during database operations
Solution:
# Check slow queries
docker exec -it nova-postgres psql -U nova -d nova_rewards -c "
SELECT query, calls, total_time, mean_time
FROM pg_stat_statements
ORDER BY mean_time DESC
LIMIT 10;"
# Optimize queries
# Add indexes
# Use query result caching# Add more instances
docker-compose up -d --scale backend=4// Reduce rate limits temporarily
const limiter = rateLimit({
windowMs: 60 * 1000,
max: 50 // Reduce from 100
});# Disable background jobs temporarily
# Disable analytics
# Reduce logging verbosity- CPU > 95% for more than 15 minutes
- Service becoming unresponsive
- Unable to identify root cause
- Scaling doesn't help
- Backend Team Lead: [Contact info]
- DevOps Team: [Contact info]
- Performance Engineer: [Contact info]
- Profile application code
- Identify bottlenecks
- Review algorithm efficiency
- Optimize hot code paths
- Add caching where appropriate
- Improve query performance
- Consider async processing
- Review auto-scaling thresholds
- Plan for traffic growth
- Consider instance upgrades