[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,93 +2,289 @@
id: wiki-2026-0508-availability-and-persistence
title: Availability and Persistence
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-AVPE-001]
aliases: [HA, durability, ACID, replication, SLA, 99.999, distributed system, RPO, RTO]
duplicate_of: none
source_trust_level: A
confidence_score: 0.95
tags: [auto-reinforced, availability, persistence, _system-Reliability, data-engineering, cloud-Architecture]
verification_status: applied
tags: [availability, persistence, distributed-systems, replication, sla, acid, durability, rpo-rto, sre]
raw_sources: []
last_reinforced: 2026-04-20
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
language: distributed systems
framework: Kubernetes / Postgres / Kafka / S3
---
# [[Availability-and-Persistence|Availability-and-Persistence]]
# Availability and Persistence
## 📌 한 줄 통찰 (The Karpathy Summary)
> "언제나 그곳에 있으며 잊지 않는 시스템: 필요할 때 즉시 응답할 수 있는 '가용성'과, 한 번 저장된 정보가 어떤 충격에도 유실되지 않고 영구히 보존되는 '지속성'이라는 데이터의 생존 공식."
## 📌 한 줄 통찰
> **"매 always there + 매 never forget"**. 매 availability = 매 즉시 응답 가능. 매 persistence (durability) = 매 한번 commit 의 절대 lose X. 매 distributed system 의 두 base. 매 SLA 의 currency.
## 📖 구조화된 지식 (Synthesized Content)
가용성과 지속성은 안정적인 시스템 운영과 지식 관리를 지탱하는 두 가지 핵심 기술 지표입니다.
## 📖 핵심
1. **Availability (가용성)**:
* 시스템이 장애 없이 정상적으로 서비스를 제공하는 상태.
* **High Availability (HA)**: 99.9% (Three Nines) 이상의 가동 시간을 목표로 함. 이중화(Redundancy)와 자동 장애 조치가 필수.
2. **Persistence (지속성/영속성)**:
* 프로세스가 종료되거나 시스템 전원이 꺼져도 데이터가 사라지지 않고 저장 매체에 안전하게 유지되는 성질.
* **Durability**: 트랜잭션이 성공하면 어떤 사고에도 결과가 보존되어야 함 (ACID 원칙).
3. **지식 관리에서의 의의**:
* 개인의 뇌(망각하기 쉬움) 대신 디지털 위키나 지식 그래프를 사용하는 이유는 높은 지속성을 확보하기 위함임 (Knowledge-Persistence).
### 매 Availability (가용성)
- 매 system 의 의도된 service 의 가능 시간 비율.
- 매 measure: uptime / total time.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌**: 과거에는 단일 거대 서버의 '안정성' 정책에 의존했으나, 현대의 분산 시스템 정책은 '개별 구성 요소는 언제든 실패할 수 있다'는 전제 하에 시스템 전체의 가용성을 유지하는 '회복 탄력성([[Resilience|Resilience]]) 정책'으로 진화함(RL Update).
- **정책 변화(RL Update)**: 클라우드 거버넌스 정책에서, 단순히 데이터를 저장하는 것을 넘어 100년 이상의 장기 보존을 보장하는 '아카이빙 전용 지속성 정책'과 법적 증거 보존 의무(Legal Hold)가 핵심 보안 요건이 됨.
| Nines | Downtime / year |
|---|---|
| 99% | 3.65 일 |
| 99.9% (3 nines) | 8.76 시간 |
| 99.99% (4 nines) | 52.6 분 |
| 99.999% (5 nines) | 5.26 분 |
| 99.9999% (6 nines) | 31.5 초 |
## 🔗 지식 연결 (Graph)
- [[Safety & Reliability|Safety & Reliability]], [[Robustness|Robustness]], [[Antifragility|Antifragility]], [[Standardization vs Innovation|Standardization vs Innovation]], [[Technical-Architecture|Technical-Architecture]]
- **Modern Tech/Tools**: Cloud [[Storage|Storage]] (S3), RAID, Database replication, [[Blockchain|Blockchain]] (Immutable persistence).
---
→ 매 nines 의 매 cost 의 exponential.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### 매 Durability (지속성)
- 매 commit 후 의 data 의 lose 의 probability.
- 매 S3: 11 nines (99.999999999%).
- 매 disk MTBF: 매 100 만 hour.
**언제 이 지식을 쓰는가:**
- *(TODO)*
### 매 RPO / RTO
- **RPO** (Recovery Point Objective): 매 잃을 수 있는 data 의 max age.
- **RTO** (Recovery Time Objective): 매 service restore 까지의 max time.
**언제 쓰면 안 되는가:**
- *(TODO)*
| RPO/RTO | 매 strategy |
|---|---|
| 0 / 0 | 매 sync replication, multi-region |
| min / min | 매 hot standby |
| hour / hour | 매 daily backup |
| day / day | 매 cold backup |
## 🧪 검증 상태 (Validation)
### 매 Availability 의 design
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
#### Redundancy
- 매 N+1 / N+2 (active-passive / active-active).
- 매 multi-AZ / multi-region.
- 매 load balancer + health check.
## 🧬 중복 검사 (Duplicate Check)
#### Fault tolerance
- 매 graceful degradation.
- 매 circuit breaker.
- 매 bulkhead.
- 매 retry with backoff.
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
#### Auto-recovery
- 매 self-healing (k8s).
- 매 auto-scaling.
- 매 chaos engineering 의 verify.
## 🕓 변경 이력 (Changelog)
### 매 Persistence 의 design
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
#### ACID (RDBMS)
- **Atomicity**: 매 all-or-nothing.
- **Consistency**: 매 invariant 보존.
- **Isolation**: 매 concurrent ↛ 매 interference.
- **Durability**: 매 commit 의 persistent.
## 💻 코드 패턴 (Code Patterns)
#### Replication
- **Sync**: 매 N replica 의 ack 후 commit (latency cost).
- **Async**: 매 leader commit 후 propagate (data loss risk).
- **Quorum** (Paxos / Raft): 매 majority ack.
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
#### Backup
- **Full / incremental / differential**.
- **3-2-1 rule**: 3 copies, 2 different media, 1 offsite.
- **Test restore** (매 critical, 매 자주 무시).
```text
# TODO
#### Storage tier
- **Hot** (S3 Standard): 매 ms access.
- **Warm** (Standard-IA): 매 cheaper, 매 retrieval fee.
- **Cold** (Glacier): 매 hours retrieval.
- **Deep archive**: 매 12 hour, 매 cheapest.
### 매 CAP / PACELC
- **CAP**: Consistency + Availability + Partition tolerance — 매 2 만 pick.
- **PACELC**: 매 partition 시 PA / PC, 매 else EL / EC.
### 매 modern best practice
1. **Multi-AZ / multi-region** (depending on cost).
2. **Health check + auto-failover**.
3. **Database replica + read slave**.
4. **CDN / cache** (availability proxy).
5. **Backup + test restore**.
6. **SLO / SLI / error budget** (Google SRE).
7. **Chaos engineering**.
8. **Postmortem culture**.
## 💻 패턴
### Health check
```yaml
# k8s deployment
livenessProbe:
httpGet: { path: /health, port: 8080 }
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet: { path: /ready, port: 8080 }
periodSeconds: 5
```
## 🤔 의사결정 기준 (Decision Criteria)
### Circuit breaker (retry 한도)
```ts
class CircuitBreaker {
state: 'closed' | 'open' | 'half-open' = 'closed';
failures = 0;
lastFailure = 0;
async call<T>(fn: () => Promise<T>): Promise<T> {
if (this.state === 'open') {
if (Date.now() - this.lastFailure > 30_000) this.state = 'half-open';
else throw new ServiceUnavailable();
}
try {
const result = await fn();
this.state = 'closed';
this.failures = 0;
return result;
} catch (e) {
this.failures++;
this.lastFailure = Date.now();
if (this.failures >= 5) this.state = 'open';
throw e;
}
}
}
```
**선택 A를 써야 할 때:**
- *(TODO)*
### Postgres replication (sync)
```sql
-- 매 primary
ALTER SYSTEM SET synchronous_standby_names = 'replica1, replica2';
ALTER SYSTEM SET synchronous_commit = on;
SELECT pg_reload_conf();
**선택 B를 써야 할 때:**
- *(TODO)*
-- 매 replica 의 streaming replication 의 시작
-- 매 transaction 의 commit 의 매 replica ack 후.
```
**기본값:**
> *(TODO)*
### S3 lifecycle (storage tier)
```json
{
"Rules": [{
"Status": "Enabled",
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" },
{ "Days": 90, "StorageClass": "GLACIER" },
{ "Days": 365, "StorageClass": "DEEP_ARCHIVE" }
],
"Expiration": { "Days": 2555 } // 7 years
}]
}
```
## ❌ 안티패턴 (Anti-Patterns)
### SLO / Error budget
```python
def error_budget(sli_target=0.999, period_days=30):
"""매 SLI 의 99.9% → 매 0.1% 의 error budget."""
total_minutes = period_days * 24 * 60
budget = total_minutes * (1 - sli_target)
return budget # 매 분
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
def burn_rate(actual_errors, budget, elapsed_fraction):
expected = budget * elapsed_fraction
return actual_errors / expected if expected > 0 else 0
# burn_rate > 1 → 매 budget 의 빠르게 burn.
# burn_rate > 14.4 → 매 critical (1 hour 에 1 day budget).
```
### Backup test restore
```bash
#!/bin/bash
# 매 매주 자동 restore test
LATEST=$(aws s3 ls s3://backups/db/ | tail -1 | awk '{print $4}')
aws s3 cp "s3://backups/db/$LATEST" /tmp/
# 매 staging DB 의 restore
pg_restore -d staging_test /tmp/$LATEST
# 매 sample query 의 verify
psql staging_test -c "SELECT count(*) FROM users;" > /tmp/result
diff /tmp/result expected.txt || alert "Backup restore failed!"
```
→ 매 backup 의 가치 = 매 restore 의 verify.
### Multi-region failover (DNS)
```python
# 매 Route53 health check + failover routing
{
'primary': {'region': 'us-east-1', 'health_check': 'http://primary/health'},
'secondary': {'region': 'us-west-2', 'health_check': 'http://secondary/health'},
'failover': 'PRIMARY_FAILS_TO_SECONDARY',
}
```
### Distributed lock (Redis Redlock)
```python
import redis
import time
import uuid
def acquire_lock(client, key, ttl=10000):
token = str(uuid.uuid4())
if client.set(key, token, nx=True, px=ttl):
return token
return None
def release_lock(client, key, token):
script = """
if redis.call('get', KEYS[1]) == ARGV[1] then
return redis.call('del', KEYS[1])
end
return 0
"""
return client.eval(script, 1, key, token)
```
## 🤔 결정 기준
| 요구 | Strategy |
|---|---|
| 99.9% (3 nines) | Multi-AZ + auto-failover |
| 99.99% (4 nines) | Multi-region + sync replica |
| 99.999% (5 nines) | Active-active multi-region + chaos |
| Critical durability | S3 + cross-region replication |
| Long-term archive | Glacier Deep Archive |
| Hot path | RDS + read replica + cache |
| Eventual OK | DynamoDB + async |
**기본값**: Multi-AZ + replica + backup test + SLO + chaos.
## 🔗 Graph
- 부모: [[Distributed-Systems]] · [[SRE]] · [[Reliability]]
- 변형: [[High-Availability]] · [[Durability]] · [[Replication]] · [[Backup-Strategy]]
- 응용: [[ACID]] · [[CAP-Theorem]] · [[PACELC]] · [[Raft]] · [[Paxos]]
- 응용 (cloud): [[S3]] · [[Multi-Region]] · [[Auto-Scaling]] · [[Chaos-Engineering]]
- Adjacent: [[SLO-SLI]] · [[Error-Budget]] · [[Circuit-Breaker]] · [[Postmortem]]
## 🤖 LLM 활용
**언제**: 매 system design. 매 SLA negotiation. 매 incident response. 매 backup strategy review.
**언제 X**: 매 prototype (over-engineering). 매 single-user app.
## ❌ 안티패턴
- **No backup test**: 매 fake durability.
- **5-nines 의 demand 의 single-region**: 매 impossible.
- **Sync replication cross-region** (high latency): 매 user 의 slow.
- **Health check 의 deep dependency**: 매 cascade.
- **Retry without backoff**: 매 thundering herd.
- **No SLO**: 매 over-engineer or 매 under-deliver.
- **Single point of failure**: 매 invisible.
## 🧪 검증 / 중복
- Verified (Google SRE book, AWS Well-Architected, CAP / PACELC).
- 신뢰도 A.
- Related: [[CAP-Theorem]] · [[Replication]] · [[SLO-SLI]] · [[Chaos-Engineering]] · [[ACID]].
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — nines + RPO/RTO + replication + SLO + 매 K8s / Postgres / S3 / Redis code |