πŸ”§ DevOps

Uptime

Uptime

The time a system operates normally. Guaranteed by SLA. 99.99% = 52 minutes of downtime per year.

Detailed Explanation

Uptime is the percentage of time that a system operates normally and provides service. It is usually expressed as a percentage and is a key metric of an SLA (Service Level Agreement). 99.9% ("three nines") is a common target, and 99.99% ("four nines") is the standard for high availability.

The allowed downtime for each Uptime percentage is as follows: 99% (two nines) allows 3.65 days per year, 99.9% (three nines) allows 8.76 hours per year, 99.99% (four nines) allows 52.6 minutes per year, and 99.999% (five nines) allows 5.26 minutes per year. A difference of one digit actually means a 10-fold difference in stability.

Strategies for increasing Uptime include redundancy, load balancing, automatic failover, canary deployment, and circuit breakers. Planned maintenance is also counted as downtime, so zero-downtime deployment and rolling updates are important.

In practice, Uptime is measured continuously with monitoring tools such as Uptime Robot, Pingdom, and Datadog. A status page is operated to disclose real-time availability to customers, and when an outage occurs, a post-mortem is conducted to prevent recurrence. An Error Budget is the budget of downtime available relative to the SLO.

Code Example

# Prometheus + Grafana둜 Uptime λͺ¨λ‹ˆν„°λ§

# prometheus-rules.yaml - SLO/SLI μ •μ˜
groups:
  - name: slo-rules
    rules:
      # 성곡 μš”μ²­ λΉ„μœ¨ (SLI)
      - record: http_request_success_rate:5m
        expr: |
          sum(rate(http_requests_total{status!~"5.."}[5m]))
          /
          sum(rate(http_requests_total[5m]))

      # 99.9% SLO μœ„λ°˜ μ—¬λΆ€
      - alert: HighErrorRate
        expr: http_request_success_rate:5m < 0.999
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "μ„œλΉ„μŠ€ κ°€μš©μ„± SLO μœ„λ°˜"
          description: "ν˜„μž¬ 성곡λ₯ : {{ $value | humanizePercentage }}"

      # Error Budget μ†Œμ§„μœ¨
      - record: error_budget_remaining:30d
        expr: |
          1 - (
            (1 - avg_over_time(http_request_success_rate:5m[30d]))
            /
            (1 - 0.999)  # 99.9% SLO
          )

---
# Kubernetes Liveness/Readiness Probe μ„€μ •
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-server
spec:
  replicas: 3  # κ³ κ°€μš©μ„±μ„ μœ„ν•œ 볡제본
  template:
    spec:
      containers:
      - name: api
        image: myapp/api:v1.0.0
        ports:
        - containerPort: 8080
        # Liveness: μ»¨ν…Œμ΄λ„ˆκ°€ μ‚΄μ•„μžˆλŠ”μ§€ 확인
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 10
          failureThreshold: 3
        # Readiness: νŠΈλž˜ν”½μ„ 받을 μ€€λΉ„κ°€ λ˜μ—ˆλŠ”μ§€ 확인
        readinessProbe:
          httpGet:
            path: /ready
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
          failureThreshold: 2
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 512Mi

---
# PodDisruptionBudget - μ—…κ·Έλ ˆμ΄λ“œ 쀑 κ°€μš©μ„± 보μž₯
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: api-pdb
spec:
  minAvailable: 2  # μ΅œμ†Œ 2개 Pod μœ μ§€
  selector:
    matchLabels:
      app: api-server

---
# μƒνƒœ νŽ˜μ΄μ§€ API 예제 (Node.js)
# GET /status 응닡 μ˜ˆμ‹œ
{
  "status": "operational",
  "uptime": "99.98%",
  "uptime_30d": "99.95%",
  "components": {
    "api": { "status": "operational", "latency_p99": "45ms" },
    "database": { "status": "operational", "latency_p99": "12ms" },
    "cache": { "status": "degraded", "message": "Redis failover in progress" }
  },
  "incidents": [
    {
      "id": "inc-2024-001",
      "title": "API 응닡 μ§€μ—°",
      "status": "resolved",
      "duration_minutes": 15,
      "resolved_at": "2024-01-15T10:30:00Z"
    }
  ]
}

How It's Said in Practice

Senior: "We've almost used up this month's error budget. The SLO is 99.9%, and we've already been down for nearly 8 hours."

Junior: "Then should we hold off on deploying new features this month?"

Senior: "Yes, let's focus on stability work and push risky changes to next month. Once the error budget recovers, we'll pick the pace back up."

Interviewer: "What architecture would you design to achieve 99.99% availability?"

Candidate: "I would eliminate single points of failure with a Multi-AZ deployment and respond to load with autoscaling. For the database, I would configure read replicas and automatic failover, and at the application level, I would implement circuit breakers and retry logic. For zero-downtime deployment, I would use blue-green or canary deployment."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

Reviewer: "There's no readinessProbe. If the pod receives traffic even when the DB connection is down, errors will flood in."

Developer: "I'll add a check of the DB and Redis connection status at the /ready endpoint. I'll also set failureThreshold appropriately."

Cautions

Learn More