Blob Storage là storage chuyên biệt cho unstructured data (images, video, docs) — dùng thay vì database để tránh làm DB backup lớn và ảnh hưởng query performance. AWS S3, Google Cloud Storage, Azure Blob Storage là các giải pháp phổ biến. Pattern đúng: lưu file lên Blob Storage, chỉ lưu metadata (URL, size, type, owner) trong database.
Thiết kế hệ thống upload file: Client → generate pre-signed URL từ backend → upload trực tiếp lên S3 (bypass server, tránh bandwidth bottleneck) → backend nhận callback/event để cập nhật DB. Tối ưu: dùng CDN (CloudFront) trước S3 để serve files nhanh cho users globally, enable S3 Transfer Acceleration cho upload quốc tế, dùng multipart upload cho files lớn (>100MB). Security: pre-signed URLs với expiration time, bucket policy không public, virus scanning với Lambda trigger. Storage tiers: S3 Standard → S3 IA (Infrequent Access) → S3 Glacier cho archival – giảm cost đáng kể.
Blob Storage (Binary Large Object storage) is specialized storage for unstructured data such as images, videos, audio, and documents — examples include AWS S3, Google Cloud Storage, and Azure Blob Storage.
- Storing files directly in a database is inadvisable because it bloats backups, degrades query performance, wastes RAM in the buffer pool, and scales poorly.
- The correct pattern: upload files to Blob Storage and store only metadata (URL, size, type, owner) in the database.
- File upload system design: Client → backend generates a pre-signed URL → client uploads directly to S3 (bypassing the server to avoid a bandwidth bottleneck) → backend receives a callback/event and updates the database.
- Optimizations: use a CDN (CloudFront) in front of S3 to serve files quickly to global users; enable S3 Transfer Acceleration for international uploads; use multipart upload for large files (>100MB).
- Security: pre-signed URLs with expiration times, non-public bucket policies, virus scanning via Lambda triggers.
- Storage tiers: S3 Standard → S3 IA (Infrequent Access) → S3 Glacier for archival — significantly reduces cost.