1---
2name: server-management
3description: Server management principles and decision-making. Process management, monitoring strategy, and scaling decisions. Teaches thinking, not commands.
4allowed-tools: Read, Write, Edit, Glob, Grep, Bash
5metadata:
6 source: https://skillmd.com/skills/whd4/server-management
7---
8
9# Server Management
10
11> Server management principles for production operations.
12> **Learn to THINK, not memorize commands.**
13
14---
15
16## 1. Process Management Principles
17
18### Tool Selection
19
20| Scenario | Tool |
21|----------|------|
22| **Node.js app** | PM2 (clustering, reload) |
23| **Any app** | systemd (Linux native) |
24| **Containers** | Docker/Podman |
25| **Orchestration** | Kubernetes, Docker Swarm |
26
27### Process Management Goals
28
29| Goal | What It Means |
30|------|---------------|
31| **Restart on crash** | Auto-recovery |
32| **Zero-downtime reload** | No service interruption |
33| **Clustering** | Use all CPU cores |
34| **Persistence** | Survive server reboot |
35
36---
37
38## 2. Monitoring Principles
39
40### What to Monitor
41
42| Category | Key Metrics |
43|----------|-------------|
44| **Availability** | Uptime, health checks |
45| **Performance** | Response time, throughput |
46| **Errors** | Error rate, types |
47| **Resources** | CPU, memory, disk |
48
49### Alert Severity Strategy
50
51| Level | Response |
52|-------|----------|
53| **Critical** | Immediate action |
54| **Warning** | Investigate soon |
55| **Info** | Review daily |
56
57### Monitoring Tool Selection
58
59| Need | Options |
60|------|---------|
61| Simple/Free | PM2 metrics, htop |
62| Full observability | Grafana, Datadog |
63| Error tracking | Sentry |
64| Uptime | UptimeRobot, Pingdom |
65
66---
67
68## 3. Log Management Principles
69
70### Log Strategy
71
72| Log Type | Purpose |
73|----------|---------|
74| **Application logs** | Debug, audit |
75| **Access logs** | Traffic analysis |
76| **Error logs** | Issue detection |
77
78### Log Principles
79
801. **Rotate logs** to prevent disk fill
812. **Structured logging** (JSON) for parsing
823. **Appropriate levels** (error/warn/info/debug)
834. **No sensitive data** in logs
84
85---
86
87## 4. Scaling Decisions
88
89### When to Scale
90
91| Symptom | Solution |
92|---------|----------|
93| High CPU | Add instances (horizontal) |
94| High memory | Increase RAM or fix leak |
95| Slow response | Profile first, then scale |
96| Traffic spikes | Auto-scaling |
97
98### Scaling Strategy
99
100| Type | When to Use |
101|------|-------------|
102| **Vertical** | Quick fix, single instance |
103| **Horizontal** | Sustainable, distributed |
104| **Auto** | Variable traffic |
105
106---
107
108## 5. Health Check Principles
109
110### What Constitutes Healthy
111
112| Check | Meaning |
113|-------|---------|
114| **HTTP 200** | Service responding |
115| **Database connected** | Data accessible |
116| **Dependencies OK** | External services reachable |
117| **Resources OK** | CPU/memory not exhausted |
118
119### Health Check Implementation
120
121- Simple: Just return 200
122- Deep: Check all dependencies
123- Choose based on load balancer needs
124
125---
126
127## 6. Security Principles
128
129| Area | Principle |
130|------|-----------|
131| **Access** | SSH keys only, no passwords |
132| **Firewall** | Only needed ports open |
133| **Updates** | Regular security patches |
134| **Secrets** | Environment vars, not files |
135| **Audit** | Log access and changes |
136
137---
138
139## 7. Troubleshooting Priority
140
141When something's wrong:
142
1431. **Check if running** (process status)
1442. **Check logs** (error messages)
1453. **Check resources** (disk, memory, CPU)
1464. **Check network** (ports, DNS)
1475. **Check dependencies** (database, APIs)
148
149---
150
151## 8. Anti-Patterns
152
153| ❌ Don't | ✅ Do |
154|----------|-------|
155| Run as root | Use non-root user |
156| Ignore logs | Set up log rotation |
157| Skip monitoring | Monitor from day one |
158| Manual restarts | Auto-restart config |
159| No backups | Regular backup schedule |
160
161---
162
163> **Remember:** A well-managed server is boring. That's the goal.