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