Operating Production Infrastructure and Managing Outages
System DesignModel answerLast updated
A guide on managing production servers, diagnosing performance degradation, conducting structured incident response, and using Linux inspection utilities.
Assume you are assigned as the primary on-call engineer for a critical service infrastructure cluster. Walk through your methodology for the following operational scenarios:
- Shift Preparation & Health Maintenance: What proactive measures and operational checks do you perform to ensure cluster stability during your shift?
- Incident Response Lifecycle: Detail your step-by-step framework when responding to an active production incident from detection to post-incident review.
- Debugging High Latency & Hung Requests: If client requests are timing out or hanging, what are the potential root causes across the stack, and how do you systematically isolate them?
- System Inspection: What commands and techniques do you use to quickly audit active processes, scheduled tasks, and open network sockets on an unfamiliar Linux host?
- Resource Bottlenecks: Identify the primary finite hardware and OS-level resources that lead to performance degradation, along with their key metrics.
- Operational Best Practices: What foundational operational principles and architectural guidelines would you recommend to a team looking to improve system reliability and observability?
Hints
Hint 1
Structure your incident handling process around restoring service functionality before attempting to determine the deep root cause.
Hint 2
Categorize latency issues into system-level saturation, application logic bugs, external dependency stalls, and networking bottlenecks.
Hint 3
Apply standard observability framework concepts such as Google's Four Golden Signals (Latency, Traffic, Errors, Saturation) and Brendan Gregg's USE Method (Utilization, Saturation, Errors).
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Standard Observability Frameworks
When managing production systems, two foundational mental models guide monitoring and troubleshooting:
- The Four Golden Signals: Latency, Traffic, Errors, and Saturation.
- The USE Method: For every hardware/software resource, check Utilization (% time busy), Saturation (backlog/queue length), and Errors (error counts).
1. Shift Preparation & Health Maintenance
Proactive on-call management prevents avoidable fires and ensures readiness when incidents occur.
Handoff & Context Gathering
- Review Active State: Check existing tickets, ongoing incidents, and flappy alerts with the outgoing engineer.
- Track Imminent Changes: Identify scheduled deployments, feature flag toggles, maintenance windows, or database migrations occurring during the shift.
- Verify Escalation Paths: Confirm who is secondary on-call and ensure point-of-contact info is updated for dependent component teams (e.g., DBA, Network, Platform).
Monitoring & Alert Verification
- Check SLO/SLA Dashboards: Ensure baseline metrics for the Four Golden Signals are healthy.
- Validate Paging Channels: Confirm alert routing functions properly and verify that alerts page on user-impacting symptoms (e.g., elevated HTTP 5xx rates, high tail latency) rather than noisy low-severity causes.
- Check Slow-Burning Indicators:
- Disk space consumption rates and inode exhaustion.
- Memory leak trends over multiple days.
- Upcoming TLS certificate expiration dates.
- Automated backup and cron job status.
Mitigation Readiness
- Confirm access to runbooks, rollback scripts, rate-limiting knobs, and traffic draining controls (e.g., removing a node from load balancer pools).
2. Incident Response Lifecycle Framework
[1. Detect & Ack] ──> [2. Triage & Scope] ──> [3. Mitigate & Stabilize] ──> [4. Root Cause Analysis] ──> [5. Postmortem]
- Detection & Acknowledgement:
- Acknowledge the alert immediately to signal ownership and prevent duplicate effort.
- Impact Assessment & Triage:
- Quantify impact: What proportion of users are affected? Which endpoints, regions, or customer segments?
- Classify Severity (e.g., SEV-1 for complete outage, SEV-2 for degraded feature).
- Communication:
- Open a dedicated incident communication channel (e.g., Slack
#incident-123). - Broadcast status updates internally at regular intervals (e.g., every 15–30 minutes) and update public status pages if appropriate.
- Open a dedicated incident communication channel (e.g., Slack
- Mitigation First (Restore Service Before In-Depth Debugging):
- Focus on returning the system to a healthy state before finding the deep root cause.
- Ask: What changed recently? (Deployments, config changes, infrastructure updates, traffic surges).
- Common Mitigations:
- Roll back recent software or configuration changes.
- Scale out replicas or add capacity.
- Shed load via rate limiting or shedding non-critical traffic.
- Toggle off non-essential feature flags.
- Restart unresponsive worker processes (after capturing diagnostic artifacts like thread dumps or core dumps).
- Drain traffic away from unhealthy instances or regions.
- Verification:
- Validate via telemetry that error rates drop and latency normalizes before declaring the incident mitigated.
- Post-Incident Analysis & Blameless Postmortem:
- Document the incident timeline, root cause, impact, what went well, and what failed.
- Assign actionable preventions with owners (e.g., adding automated guardrails, refining alert thresholds, fixing retry policies).
3. Debugging High Latency and Hung Requests
Potential Root Causes Across Layers
| Layer | Potential Root Causes |
|---|---|
| System Resources | CPU saturation (run queue backlogs); memory exhaustion causing swap thrashing or OOM pauses; high I/O wait (iowait) from disk latency. |
| Application Layer | Application thread pool exhaustion; database connection pool starvation; thread deadlocks or lock contention; long Garbage Collection (GC) pauses; unhandled infinite loops. |
| Dependencies | Slow or unindexed database queries; blocked lock wait queues on DB tables; external API calls hanging due to missing client timeouts; cache miss storms (thundering herd). |
| Network & Transport | DNS resolution timeouts; packet loss causing TCP retransmissions; filled connection tracking tables (conntrack); socket backlog overflow; ephemeral port exhaustion. |
Systematic Isolation Strategy
-
Isolate Scope:
- Determine whether the issue is global or isolated to specific endpoints, client subnets, or hosts.
- Check if latency correlates with a recent code release or configuration deploy.
-
Measure Request Timing Breakdown:
- Measure breakdown across components using distributed tracing or timing headers:
curl -w "DNS: %{time_namelookup}s | Connect: %{time_connect}s | TTFB: %{time_starttransfer}s | Total: %{time_total}s\n" \ -o /dev/null -s https://example.com/api/v1/resource
- Measure breakdown across components using distributed tracing or timing headers:
-
Execute 60-Second Linux Triage:
uptime: Check load average relative to logical CPU core count.dmesg -T | tail -n 30: Inspect kernel ring buffer for Out-Of-Memory (OOM) kills or hardware/filesystem errors.vmstat 1 5: Monitor run queue (r), free/swapped memory (swpd,free), and I/O wait (wa).mpstat -P ALL 1: Detect single-core saturation or high system/steal CPU usage.pidstat 1 5: Identify specific processes driving CPU or disk I/O load.iostat -xz 1 5: Evaluate disk utilization (%util) and average request response time (await).free -h&df -h&df -i: Verify available RAM, disk space, and inode availability.ss -s&ss -tulpn: Check socket allocations, listening ports, and queue backlogs.
-
Deep Process Diagnostics:
- Inspect System Calls: Run
strace -p <PID> -f -cto see where time is spent in syscalls (e.g., blocked onread,epoll_wait,futex). - Capture Runtime Dumps: Capture thread dumps using language-specific tooling (
jstackfor JVM,py-spy dumpfor Python,gdbfor C/C++ binaries) to isolate blocked code paths.
- Inspect System Calls: Run
4. Auditing Running Processes and Services on Linux
When logging into an unfamiliar Linux server during an outage, use these core commands to audit system state:
# Process Tree & Active Resource Usage
ps auxf # Full process tree listing with arguments
top -b -n 1 | head -n 30 # Snapshot of top resource-consuming processes
htop # Interactive real-time process viewer (if available)
# Service & Daemon Inspection
systemctl list-units --type=service --state=running # List all running systemd services
systemctl list-timers # List active scheduled systemd timers
# Scheduled Tasks
crontab -l # Current user's crontab
cat /etc/crontab /etc/cron.*/ # System-wide cron configurations
# Network Listeners and Connections
ss -tulpn # Show TCP/UDP listening ports with associated PIDs
ss -tan state established # List active established TCP connections
lsof -i :8080 # List process using a specific port
# Containerized Environments
docker ps # Active Docker containers
crictl ps # Active Kubernetes CRI containers
# System Logs
journalctl -u <service_name> --since "10 minutes ago" --no-pager
5. Critical Finite Server Resources
When auditing host performance under stress, evaluate these finite resources:
| Resource | Bottleneck Indicator | Metrics / Tools | Impact |
|---|---|---|---|
| CPU | High load average relative to CPU core count; high run queue (r > cores). | uptime, mpstat, vmstat | Request queuing, elevated processing latency. |
| Memory (RAM) | High swap activity (si/so), rising RSS, OOM invocation. | free -m, dmesg, vmstat | Extreme latency spikes due to disk swapping, process termination. |
| Disk Space | Partition usage approaching 100%. | df -h | Database writes fail, logging stops, application crashes. |
| Disk Inodes | Usage at 100% despite free megabytes remaining. | df -i | Inability to create new files or temporary files. |
| Disk I/O | High %util (near 100%) and elevated await time. | iostat -xz 1 | Threads block on file/DB I/O operations. |
| Network Bandwidth / PPS | Saturation of NIC bandwidth or high Packets Per Second limit. | sar -n DEV 1 | Packet drops, TCP window throttling, increased retransmits. |
| File Descriptors | max-file limit reached for process or system wide. | lsof, /proc/sys/fs/file-nr | Too many open files errors, failure to accept new sockets. |
| Socket Queues | Non-zero Recv-Q or Send-Q on listening sockets. | ss -lnt | Connection timeouts, dropped SYN packets. |
6. Operational Best Practices for Maintainability
To design systems that are easy to monitor, debug, and maintain, implement the following operational guidelines:
- Observability First:
- Implement structured JSON logging containing correlation identifiers (e.g.,
trace_id,request_id) across all microservices. - Emit standardized metrics (counter, gauge, histogram) for request counts, error rates, and duration distributions (p50, p95, p99).
- Implement structured JSON logging containing correlation identifiers (e.g.,
- Defensive Software Design:
- Set explicit read, write, and connection timeouts on every outbound HTTP/RPC request and database client.
- Implement circuit breakers and fallback mechanisms for non-critical dependencies.
- Enforce client rate limiting and load shedding to prevent resource exhaustion under unexpected load spikes.
- Standardized Operational Runbooks:
- Maintain runbooks linked directly from alerts detailing explicit validation commands and mitigation steps.
- Safe Deployment Strategies:
- Use automated canary releases and health-check driven auto-rollbacks.
- Decouple code deployment from feature exposure using feature flags.
- Infrastructure as Code & Immutable Deployments:
- Provision infrastructure and configuration deterministically (e.g., via Terraform, Ansible, or Kubernetes manifests) to avoid configuration drift across environments.