Files
2nd/10_Wiki/Topics/Architecture/Snapshots.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

4.8 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-snapshots Snapshots 10_Wiki/Topics verified self
State Snapshot
V8 Snapshot
GC Snapshot
Heap Snapshot
none A 0.9 applied
runtime
performance
debugging
memory
state
2026-05-10 pending
language framework
javascript v8

Snapshots

매 한 줄

"매 point-in-time 의 state freeze — 매 startup 의 accelerate, 매 leak 의 hunt, 매 recovery 의 enable.". 매 V8 startup snapshot, heap snapshot, filesystem snapshot (ZFS/Btrfs), DB snapshot, state snapshot (Redux time-travel) — 매 same primitive 의 different domain. 매 modern runtime 의 cold-start optimization 의 default tool.

매 핵심

매 종류

  • V8 startup snapshot: serialize heap → fast Node.js cold start.
  • Heap snapshot (.heapsnapshot): debug memory leak, retainer graph.
  • GC snapshot: generational scan checkpoint.
  • Filesystem snapshot: ZFS/Btrfs/LVM copy-on-write point-in-time.
  • DB snapshot: PITR base, transactional checkpoint.
  • State snapshot: Redux DevTools time-travel, game save.

매 properties

  • Copy-on-write (efficient diff storage).
  • Atomic (consistent point-in-time).
  • Restorable (full state reconstruction).
  • Immutable (snapshot itself never mutated).

매 응용

  1. Node.js bootup --snapshot-blob (200ms → 30ms startup).
  2. Chrome DevTools heap profiler — leak hunt.
  3. ZFS rollback before risky deploy.
  4. Postgres PITR base + WAL replay.
  5. Redux DevTools — time-travel debug.
  6. AWS EBS snapshot — disaster recovery.
  7. Container checkpoint/restore (CRIU).

💻 패턴

Node.js startup snapshot

node --snapshot-blob snapshot.blob --build-snapshot snapshot-init.js
node --snapshot-blob snapshot.blob app.js
# Cold start: 200ms → ~30ms

Chrome heap snapshot programmatic

const v8 = require('v8');
const fs = require('fs');
const stream = v8.getHeapSnapshot();
stream.pipe(fs.createWriteStream('heap.heapsnapshot'));
// Open in Chrome DevTools → Memory tab

ZFS snapshot + rollback

zfs snapshot tank/data@before-deploy
# ... risky operation ...
zfs rollback tank/data@before-deploy   # if failure
zfs destroy tank/data@before-deploy    # if success

Postgres base backup + PITR

pg_basebackup -D /backup/base -F tar -X stream -P
# Recover to point-in-time
restore_command = 'cp /archive/%f %p'
recovery_target_time = '2026-05-10 14:30:00'

Redux state snapshot

import { createStore } from 'redux';
const store = createStore(reducer);

const snapshot = store.getState();  // freeze
// ... actions ...
store.replaceReducer((state = snapshot) => state);  // restore

CRIU container checkpoint

criu dump --tree $PID --images-dir /checkpoints/svc-1 --leave-running
# Later, possibly on different host:
criu restore --images-dir /checkpoints/svc-1

EBS snapshot via AWS SDK

import { EC2Client, CreateSnapshotCommand } from '@aws-sdk/client-ec2';

await client.send(new CreateSnapshotCommand({
  VolumeId: 'vol-0abc',
  Description: 'pre-migration-2026-05-10',
  TagSpecifications: [{ ResourceType: 'snapshot', Tags: [{ Key: 'env', Value: 'prod' }] }],
}));

Heap diff analysis

// Take 2 snapshots, diff in DevTools to find leak
v8.writeHeapSnapshot('/tmp/before.heapsnapshot');
runSuspectCode();
v8.writeHeapSnapshot('/tmp/after.heapsnapshot');
// Load both → "Comparison" view → growing retainer chains

매 결정 기준

상황 Approach
Node.js cold start slow startup snapshot
Memory leak hunt heap snapshot diff
Pre-deploy rollback safety ZFS/EBS snapshot
DB recovery to time T PITR base + WAL
Container live migration CRIU checkpoint
Frontend bug repro Redux time-travel

기본값: heap snapshot for leaks, ZFS/EBS for storage, PITR for DB, CRIU for container.

🔗 Graph

🤖 LLM 활용

언제: cold-start optim, leak diag, DR planning, time-travel debug strategy. 언제 X: write-heavy hot path — snapshot overhead 의 measure 필요.

안티패턴

  • Snapshot as backup: 매 same disk 의 snapshot 의 disk failure 의 protect X.
  • No retention policy: 매 snapshot accumulate → storage explode.
  • Heap snapshot in prod under load: 매 GC pause spike — staging 에서.

🧪 검증 / 중복

  • Verified (V8 docs, Chrome DevTools docs, ZFS handbook, Postgres PITR docs).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — snapshot taxonomy, V8/heap/ZFS/PITR/CRIU patterns