Server Resource Limit Issues
What This Means
Resource limit issues occur when your server runs out of CPU, memory, disk space, or bandwidth. This causes slow performance, errors, or complete outages.
Impact
- Slow page loads from CPU/memory constraints
- 504 timeouts from exceeded processing limits
- 503 errors from exhausted worker processes
- Failed uploads from disk space issues
- Traffic throttling from bandwidth limits
How to Diagnose
Check Current Usage
Linux:
# CPU and Memory
top
htop
free -h
# Disk space
df -h
# I/O stats
iostat -x 1
# Network usage
iftop
nethogs
Common Indicators
| Resource | Warning Signs |
|---|---|
| CPU | Load average > CPU cores |
| Memory | Swap usage increasing |
| Disk | Usage > 85% |
| Bandwidth | Throttled responses |
| Connections | Connection refused errors |
General Fixes
1. CPU Optimization
Identify CPU-intensive processes:
ps aux --sort=-%cpu | head -10
Solutions:
- Optimize slow code paths
- Add caching to reduce processing
- Upgrade to faster CPU/more cores
- Implement horizontal scaling
2. Memory Optimization
Check memory usage:
free -h
ps aux --sort=-%mem | head -10
Solutions:
- Optimize application memory usage
- Reduce worker process memory footprint
- Add more RAM
- Implement memory caching (Redis/Memcached)
PHP-FPM tuning:
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
3. Disk Space Management
Find large files:
du -sh /* | sort -h
find / -type f -size +100M
Solutions:
- Clean up log files
- Remove old backups
- Compress or archive old data
- Increase disk size
4. Bandwidth Optimization
Reduce bandwidth usage:
5. Connection Limits
Check connection limits:
ulimit -n # Max open files
ss -s # Socket statistics
Increase limits:
# /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
Scaling Strategies
Vertical Scaling (Scale Up)
- Add more CPU cores
- Increase RAM
- Faster storage (SSD/NVMe)
Horizontal Scaling (Scale Out)
- Add more servers
- Load balancer distribution
- Database read replicas
Auto-Scaling Rules
# Example auto-scaling policy
scaling_policy:
min_instances: 2
max_instances: 10
scale_up:
cpu_threshold: 80%
duration: 5m
add_instances: 2
scale_down:
cpu_threshold: 30%
duration: 15m
remove_instances: 1
Monitoring Setup
Set up alerts for:
- CPU usage > 80% for 5 minutes
- Memory usage > 85%
- Disk usage > 80%
- High load average
- Swap usage increasing
Platform-Specific Considerations
| Platform | Resource Management |
|---|---|
| Shopify | Managed by Shopify |
| WordPress | Hosting-dependent |
| Squarespace | Managed by Squarespace |
| VPS/Dedicated | Full control |