Files
2nd/10_Wiki/Topics/Architecture/Snapshots.md
T
koriweb d8a80f6272 chore(wiki): dangling 링크 canonical 정규화 (768파일/1200건)
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해
끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은
과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업.
도구: Datacollect/scripts/link_reconcile_apply.mjs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:24: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