C.W.K.
Stream
Lesson 08 of 10 · published

Litestream + Cloud-Backed SQLite

~12 min · litestream, replication, edge

Level 0Scout
0 XP0/80 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

2021 전엔 없던 HA 스토리

Litestream (Ben Johnson, 2021) 가 unmodified SQLite 위 continuous streaming replication 추가. WAL tail + S3 (또는 sftp/GCS/Azure/file) 로 incremental 변경 ship. 재해 시 latest replica 에서 restore — 초 단위 데이터 손실.

LiteFS (Fly.io) 가 synchronous write 의 클러스터 filesystem 으로 확장 — 강한 일관성의 multi-node SQLite.

Turso 가 libSQL fork + multi-region 매니지드 서비스 빌드. Cloudflare D1 이 SQLite 를 Workers runtime 에 번들. Litesync 등이 인접 niche.

핵심: SQLite 의 'no replication' objection 이 20 년간 진짜였고 오늘 더 이상 진짜 X. Single-region 웹 앱이면 Litestream 단독으로 보통 충분. Multi-region write 면 Turso 또는 LiteFS.

Tip: 비용 이유로 RDS Postgres 고려 중인데 앱이 SQLite 배포 모양 맞으면 Litestream-on-Fly 또는 Turso 숫자 돌려봐. 피파-shaped '한 머신 앱 + daily 클라우드 백업' setup 이 매니지드 Postgres 에 $50+ 들 state 를 한 자리수 달러/월.

Code

Litestream — 설치 + 실행·bash
# macOS
brew install benbjohnson/litestream/litestream

# Linux 는 binary release
curl -L https://github.com/benbjohnson/litestream/releases/download/v0.5.0/litestream-v0.5.0-linux-amd64.tar.gz | tar xz

# Continuous replicate
litestream replicate /var/lib/myapp/myapp.db s3://myapp-backups/prod/myapp

# Latest replica 에서 restore
litestream restore -o /var/lib/myapp/myapp.db s3://myapp-backups/prod/myapp

External links

Exercise

테스트 SQLite DB 를 S3 (또는 NAS sftp) 로 replicate 하는 Litestream setup. 몇 분 row insert/update. 그 다음 원본 'lose' (삭제), replica 에서 restore, row count 매치 확인. Recovery 시간 + 데이터 손실 window 기록.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.