Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav — full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with ❤️ & By - Anubhav

© 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 04 · Storage, Queues & Event StreamingChapter 19 of 33
18.
Phase 04Read time ~27 minDifficulty advanced

Storage Systems

In this chapter
  • 01Introduction
  • 02What Is a Storage System?
  • 03Storage Hierarchy
  • 04Local Storage
  • 05Network Storage
  • 06Block Storage
  • 07Block Storage Use Cases
  • 08File Storage
  • 09Object Storage
  • 10Object Storage Architecture
  • 11Block vs File vs Object Storage
  • 12HDD vs SSD
  • 13HDD
  • 14SSD
  • 15NVMe
  • 16Latency
  • 17Throughput
  • 18IOPS
  • 19IOPS vs Throughput
  • 20Workload A
  • 21Workload B
  • 22Sequential vs Random I/O
  • 23Storage Durability
  • 24Durability vs Availability
  • 25Durability
  • 26Availability
  • 27Replication in Storage
  • 28Replication Factor
  • 29Erasure Coding
  • 30Replication vs Erasure Coding
  • 31Checksums
  • 32Object Storage Metadata
  • 33Buckets and Object Keys
  • 34Large File Storage
  • 35Direct-to-Object-Storage Upload
  • 36Pre-Signed URLs
  • 37Secure Upload Architecture
  • 38Upload Processing Pipeline
  • 39Multipart Upload
  • 40Resumable Uploads
  • 41Download Architecture
  • 42CDN + Object Storage
  • 43Media Storage Architecture
  • 44Storage Tiers
  • 45Hot data
  • 46Warm data
  • 47Cold data
  • 48Archive
  • 49Lifecycle Management
  • 50Data Retention
  • 51Garbage Collection and Cleanup
  • 52Metadata Database vs Object Storage
  • 53Should We Store Images in a Database?
  • 54Storage and Database Backups
  • 55Cross-Region Storage
  • 56Storage Consistency
  • 57Storage Availability
  • 58Storage Cost
  • 59Storage Throughput Planning
  • 60Storage Backpressure
  • 61Storage and Queues
  • 62Distributed File Systems
  • 63Metadata Is Often the Hard Part
  • 64Small Files Problem
  • 65Large Files Problem
  • 66Range Reads
  • 67Storage Security
  • 68Encryption at rest
  • 69Encryption in transit
  • 70Access control
  • 71Least privilege
  • 72Audit logging
  • 73Object Key Security
  • 74Object Storage and Access Control
  • 75Storage Failure Scenarios
  • 76Disk failure
  • 77Node failure
  • 78Rack failure
  • 79Region failure
  • 80Corruption
  • 81Accidental deletion
  • 82Credential compromise
  • 83Replication Does Not Protect Against Everything
  • 84Versioning
  • 85Soft Delete
  • 86Storage Lifecycle Architecture
  • 87Real-World Architecture: Photo Sharing App
  • 88Real-World Architecture: Video Platform
  • 89Practical Exercise
  • 90Raw data
  • 91Mini Project
  • 92Interview Questions
  • 93Beginner
  • 94Intermediate
  • 95Advanced
  • 96Interview Scenario
  • 97Question
  • 98Production Storage Checklist
  • 99Storage choice
  • 100Capacity
  • 101Reliability
  • 102Performance
  • 103Security
  • 104Lifecycle
  • 105Application architecture
  • 106Master Mental Model
  • 107Chapter Summary
  • 108Final Interview Checklist
  • 109What's Next?
  • 110Chapter 18 — File Upload & Media Systems
In this chapter (110 sections)
01Introduction02What Is a Storage System?03Storage Hierarchy04Local Storage05Network Storage06Block Storage07Block Storage Use Cases08File Storage09Object Storage10Object Storage Architecture11Block vs File vs Object Storage12HDD vs SSD13HDD14SSD15NVMe16Latency17Throughput18IOPS19IOPS vs Throughput20Workload A21Workload B22Sequential vs Random I/O23Storage Durability24Durability vs Availability25Durability26Availability27Replication in Storage28Replication Factor29Erasure Coding30Replication vs Erasure Coding31Checksums32Object Storage Metadata33Buckets and Object Keys34Large File Storage35Direct-to-Object-Storage Upload36Pre-Signed URLs37Secure Upload Architecture38Upload Processing Pipeline39Multipart Upload40Resumable Uploads41Download Architecture42CDN + Object Storage43Media Storage Architecture44Storage Tiers45Hot data46Warm data47Cold data48Archive49Lifecycle Management50Data Retention51Garbage Collection and Cleanup52Metadata Database vs Object Storage53Should We Store Images in a Database?54Storage and Database Backups55Cross-Region Storage56Storage Consistency57Storage Availability58Storage Cost59Storage Throughput Planning60Storage Backpressure61Storage and Queues62Distributed File Systems63Metadata Is Often the Hard Part64Small Files Problem65Large Files Problem66Range Reads67Storage Security68Encryption at rest69Encryption in transit70Access control71Least privilege72Audit logging73Object Key Security74Object Storage and Access Control75Storage Failure Scenarios76Disk failure77Node failure78Rack failure79Region failure80Corruption81Accidental deletion82Credential compromise83Replication Does Not Protect Against Everything84Versioning85Soft Delete86Storage Lifecycle Architecture87Real-World Architecture: Photo Sharing App88Real-World Architecture: Video Platform89Practical Exercise90Raw data91Mini Project92Interview Questions93Beginner94Intermediate95Advanced96Interview Scenario97Question98Production Storage Checklist99Storage choice100Capacity101Reliability102Performance103Security104Lifecycle105Application architecture106Master Mental Model107Chapter Summary108Final Interview Checklist109What's Next?110Chapter 18 — File Upload & Media Systems

1. Introduction#

Applications eventually need to store data.

So far, we studied:

  • databases
  • replication
  • sharding
  • caching

But databases are not the only storage systems.

Modern applications often use several storage layers:

                         Application
                              |
          +-------------------+-------------------+
          |                   |                   |
          v                   v                   v
      Database             Object Storage       Cache
          |                   |                   |
     Structured          Files / Media       Fast Temporary
        Data                  Data               Data

A large production system may store:

  • user profiles in a database
  • images in object storage
  • videos in object storage
  • logs in distributed storage
  • backups in archival storage
  • temporary files on local disks
  • cached data in memory

The key idea is:

Different types of data require different storage characteristics.


2. What Is a Storage System?#

A storage system provides a way to persist and retrieve data.

At a high level:

Application
    |
    v
Storage
    |
    +---- Write
    |
    +---- Read

A storage system can be evaluated using:

  • latency
  • throughput
  • capacity
  • durability
  • availability
  • consistency
  • cost
  • scalability

There is no single storage technology that is optimal for every workload.


3. Storage Hierarchy#

A simplified storage hierarchy looks like:

Fastest
   |
   v
CPU Cache
Memory / RAM
Local NVMe SSD
SSD
HDD
Network Storage
Object Storage
Archival Storage
   |
   v
Slowest / Cheapest

Generally:

  • faster storage costs more
  • slower storage can provide much larger capacity
  • storage durability and availability depend on the system architecture

This is why large systems use storage tiers.


4. Local Storage#

Local storage is directly attached to the machine.

Example:

Application Server
      |
      v
Local SSD

Advantages:

  • low latency
  • high throughput
  • no network hop
  • simple architecture

Disadvantages:

  • tied to one machine
  • machine failure can cause data loss if not replicated
  • difficult to share across many servers
  • migration can be harder

Local storage is often useful for:

  • temporary files
  • local caches
  • processing scratch space
  • databases with appropriate replication
  • intermediate computation

5. Network Storage#

Network storage is accessed over a network.

Application Server
       |
       | Network
       v
Storage System

Advantages:

  • shared access
  • centralized management
  • easier capacity management
  • can survive application-server replacement

Disadvantages:

  • network latency
  • network failures
  • bandwidth constraints
  • additional infrastructure

6. Block Storage#

Block storage exposes storage as blocks that an operating system can treat like a disk.

Conceptually:

Application
    |
    v
Operating System
    |
    v
Block Device
    |
    v
Storage System

The application generally sees:

/dev/device

or an equivalent block device.

The operating system can place a filesystem on it.


7. Block Storage Use Cases#

Block storage is useful for workloads such as:

  • databases
  • virtual machine disks
  • application disks
  • transactional systems
  • filesystems requiring block-level access

Example:

Database Server
      |
      v
Filesystem
      |
      v
Block Storage

A database may depend heavily on predictable storage latency and IOPS.


8. File Storage#

File storage exposes files and directories.

Conceptually:

/
├── users
│   ├── user1
│   └── user2
├── uploads
└── reports

Applications interact using filesystem-like operations:

open
read
write
rename
delete

File storage is useful when applications need:

  • shared directories
  • hierarchical paths
  • traditional filesystem semantics
  • multiple machines accessing shared files

9. Object Storage#

Object storage stores data as objects.

Conceptually:

Bucket
  |
  +-- object-1
  +-- object-2
  +-- image.jpg
  +-- video.mp4

An object usually consists of:

Object
  |
  +-- Data
  +-- Metadata
  +-- Identifier / Key

Unlike a traditional filesystem, object storage is generally accessed through APIs rather than arbitrary filesystem operations.


10. Object Storage Architecture#

A simplified architecture:

Application
     |
     | API
     v
Object Storage
     |
     +---- Object
     +---- Metadata
     +---- Replication

Common object-storage characteristics include:

  • very large capacity
  • high durability
  • horizontal scalability
  • API-based access
  • metadata
  • lifecycle management

Object storage is extremely useful for large unstructured data.


11. Block vs File vs Object Storage#

Property Block File Object
Interface Blocks Files/directories Objects/API
Typical use Databases/VM disks Shared files Media/backups/data lakes
Hierarchical filesystem Usually via filesystem Yes Not traditionally
Scalability High High Extremely high
Access model Low-level Filesystem API
Large unstructured data Possible Good Excellent

Choosing storage depends on the application's access pattern.


12. HDD vs SSD#

Two important storage media are:

  • HDD
  • SSD

HDD#

Hard Disk Drive.

Uses spinning magnetic disks.

Advantages:

  • lower cost per GB
  • high capacity

Disadvantages:

  • mechanical components
  • higher latency
  • lower random I/O performance

SSD#

Solid State Drive.

Uses flash memory.

Advantages:

  • low latency
  • high IOPS
  • no moving mechanical parts

Disadvantages:

  • generally more expensive per GB
  • endurance characteristics need consideration

13. NVMe#

NVMe is a protocol designed for high-speed access to non-volatile memory, commonly SSDs.

A simplified hierarchy:

HDD
  |
  v
SSD
  |
  v
NVMe SSD

NVMe devices can provide very high throughput and low latency.

They are useful for:

  • high-performance databases
  • analytics
  • caching
  • local scratch workloads
  • high-throughput applications

14. Latency#

Storage latency is the time required to complete a storage operation.

Example:

Application
    |
    v
Storage
    |
    v
Response

If:

Storage latency = 5 ms

then a storage operation takes approximately that amount of time under the relevant measurement conditions.

Latency matters heavily for transactional workloads.


15. Throughput#

Throughput measures how much data can be transferred over time.

Example:

500 MB/sec

means approximately 500 megabytes of data can be transferred per second under the relevant conditions.

High throughput is important for:

  • video processing
  • backups
  • analytics
  • large file transfers
  • batch processing

16. IOPS#

IOPS means:

Input/Output Operations Per Second

Suppose a storage system provides:

100,000 IOPS

It can handle a large number of individual I/O operations per second under the relevant workload.

IOPS is especially important for workloads involving many small random operations.


17. IOPS vs Throughput#

Consider two workloads.

Workload A#

1,000,000 tiny operations/sec

Needs high IOPS.

Workload B#

1 large sequential file/sec

May be dominated by throughput.

Therefore:

IOPS ≠ Throughput

A storage system can have:

  • high throughput but poor small-random I/O
  • high IOPS but limited total bandwidth

Workload characteristics matter.


18. Sequential vs Random I/O#

Sequential:

Block 1
Block 2
Block 3
Block 4
Block 5

Random:

Block 7
Block 100
Block 2
Block 900
Block 41

Sequential workloads often achieve higher throughput.

Random workloads generally depend more heavily on IOPS and latency.


19. Storage Durability#

Durability answers:

What is the probability that stored data remains available over time despite failures?

Example:

Data written
   |
   v
Storage
   |
   +---- Disk failure
   +---- Node failure
   +---- Rack failure
   +---- Region failure

A durable storage system uses techniques such as:

  • replication
  • erasure coding
  • checksums
  • redundancy
  • geographically distributed copies

20. Durability vs Availability#

These concepts are related but different.

Durability#

Data is not lost.

Availability#

The system can serve requests.

Example:

Data still exists
but
storage service is temporarily unreachable

Then:

Durability = preserved
Availability = temporarily reduced

A strong architecture considers both.


21. Replication in Storage#

Storage systems may replicate data:

Object
  |
  +---- Copy A
  +---- Copy B
  +---- Copy C

If one copy fails:

Copy A -> FAILED
Copy B -> available
Copy C -> available

The system can continue operating.

Replication consumes additional storage capacity.


22. Replication Factor#

Suppose:

Replication factor = 3

A logical dataset of:

100 TB

could require roughly:

300 TB

of raw replicated capacity before accounting for metadata and other overhead.

Replication improves redundancy but increases cost.


23. Erasure Coding#

Instead of storing complete copies, storage can use erasure coding.

Conceptually:

Original Data
     |
     v
Encode
     |
     +---- Data Chunk A
     +---- Data Chunk B
     +---- Data Chunk C
     +---- Parity Chunk P
     +---- Parity Chunk Q

If some chunks are lost, the original data can be reconstructed from the remaining chunks.

Erasure coding can provide redundancy with less storage overhead than full replication for some workloads.


24. Replication vs Erasure Coding#

Property Replication Erasure Coding
Simplicity Higher More complex
Storage overhead Higher Often lower
Read/rebuild complexity Lower Higher
Failure recovery Straightforward Requires reconstruction
Common use Hot/critical data Large durable datasets

The exact trade-offs depend on the implementation.


25. Checksums#

Storage systems need to detect corrupted data.

A checksum can be computed:

Data
 |
 v
Checksum

Later:

Stored Data
     |
     v
Recalculate checksum
     |
     v
Compare

If they differ:

Possible corruption

Checksums are important because storage failures are not always obvious.


26. Object Storage Metadata#

An object may contain:

Key
Size
Content-Type
Creation Time
Version
Custom Metadata
Checksum

Example:

Key:
users/123/profile.jpg
 
Metadata:
Content-Type = image/jpeg
Size = 2 MB

Metadata enables systems to locate, classify, and process objects efficiently.


27. Buckets and Object Keys#

Object storage commonly organizes data into buckets/containers and keys.

Example:

bucket:
nextgen-assets
 
key:
users/123/photos/profile.jpg

The key acts as the object's identifier.

Although the key may contain /, object storage does not necessarily implement a traditional filesystem hierarchy.

This distinction matters.


28. Large File Storage#

Suppose a user uploads:

5 GB video

A bad architecture may send the entire file through application servers:

Client
   |
   v
Application Server
   |
   v
Object Storage

Now the application server handles:

  • bandwidth
  • connection duration
  • memory/buffering
  • upload reliability

This can be inefficient.

A better architecture often allows direct upload to object storage.


29. Direct-to-Object-Storage Upload#

Architecture:

Client
   |
   | 1. Request upload authorization
   v
Application
   |
   | 2. Signed upload URL
   v
Client
   |
   | 3. Upload directly
   v
Object Storage

The application does not carry the full file payload.

Benefits:

  • reduced application bandwidth
  • better scalability
  • simpler server workload
  • easier large-file handling

30. Pre-Signed URLs#

A pre-signed URL gives a client temporary permission to access an object-storage operation.

Simplified flow:

Client
  |
  | "I want to upload file"
  v
Application
  |
  | Generate signed URL
  v
Client
  |
  | PUT file
  v
Object Storage

The signed URL can have:

  • expiration
  • allowed operation
  • object key
  • constraints

The exact capabilities depend on the object-storage provider.


31. Secure Upload Architecture#

A production upload flow might be:

1. Authenticate user
2. Validate file metadata
3. Generate unique object key
4. Generate short-lived signed upload URL
5. Client uploads directly
6. Storage event generated
7. Processing worker validates/processes file
8. Database records file metadata

This separates:

File bytes

from:

Application metadata

32. Upload Processing Pipeline#

Suppose a user uploads an image.

Client
  |
  v
Object Storage
  |
  v
Storage Event
  |
  v
Processing Queue
  |
  v
Image Worker
  |
  +---- resize
  +---- thumbnail
  +---- validation
  +---- metadata extraction
  |
  v
Processed Objects

This is an event-driven storage architecture.


33. Multipart Upload#

Large files can be split into parts.

Example:

10 GB file
 
Part 1
Part 2
Part 3
...
Part N

The client uploads parts independently.

Advantages:

  • parallel upload
  • resume failed parts
  • better reliability for large files
  • improved throughput

After all parts arrive:

Parts
 |
 v
Object Storage
 |
 v
Complete Object

34. Resumable Uploads#

Suppose:

5 GB upload

fails at:

4.7 GB

Without resumability:

Start again

With resumability:

Resume from 4.7 GB

This is especially important for:

  • videos
  • backups
  • large datasets
  • unreliable networks

35. Download Architecture#

For large objects:

Client
  |
  v
CDN
  |
  v
Object Storage

The CDN can cache popular content.

This prevents every download from reaching the origin storage.


36. CDN + Object Storage#

A common architecture:

                     Users
                       |
                       v
                      CDN
                    /     \
                 HIT       MISS
                  |          |
                  v          v
               Response   Object Storage
                              |
                              v
                           Response

On a cache miss:

Object Storage -> CDN -> User

Future requests may be served directly from the CDN.


37. Media Storage Architecture#

For a video platform:

User
 |
 | Upload
 v
Object Storage
 |
 v
Processing Queue
 |
 v
Transcoding Workers
 |
 +---- 360p
 +---- 720p
 +---- 1080p
 +---- 4K
 |
 v
Object Storage
 |
 v
CDN
 |
 v
Users

This architecture separates:

  • upload
  • processing
  • storage
  • delivery

38. Storage Tiers#

Not all data needs the same performance.

A system may classify:

Hot
Warm
Cold
Archive

Hot data#

Frequently accessed.

Needs:

  • low latency
  • fast access

Warm data#

Occasionally accessed.

Can use lower-cost storage.

Cold data#

Rarely accessed.

Optimized for cost.

Archive#

Very rarely accessed.

Optimized heavily for long-term retention cost.


39. Lifecycle Management#

Data can automatically move between tiers.

Example:

Day 0
  |
  v
Hot Storage
 
Day 30
  |
  v
Warm Storage
 
Day 180
  |
  v
Cold Storage
 
Day 365
  |
  v
Archive

This can reduce storage costs.


40. Data Retention#

Every storage system should answer:

How long do we need to keep this data?

Examples:

Logs -> 30 days
Reports -> 1 year
Audit records -> several years
Temporary uploads -> 24 hours
Backups -> according to recovery policy

Retention policies prevent unlimited storage growth.


41. Garbage Collection and Cleanup#

Unused objects can accumulate.

Example:

Temporary upload
   |
   X processing failed
   |
   v
Orphaned object

A cleanup worker can find objects that are no longer referenced.

Object Storage
     |
     v
Cleanup Job
     |
     v
Delete Orphans

This is especially important when storage costs scale with data volume.


42. Metadata Database vs Object Storage#

A common architecture is:

PostgreSQL
   |
   +-- file_id
   +-- owner_id
   +-- object_key
   +-- size
   +-- status
   +-- created_at
 
Object Storage
   |
   +-- actual file bytes

The database stores metadata.

Object storage stores large binary content.

This separation is often much more scalable than storing huge blobs directly in the application database.


43. Should We Store Images in a Database?#

Small binary objects can sometimes be stored in databases.

But for large media workloads, object storage is often a better fit.

A common design is:

Database:
metadata
 
Object Storage:
binary content

This keeps transactional metadata separate from large file payloads.

The correct choice depends on workload and database capabilities.


44. Storage and Database Backups#

Backups themselves require storage.

Architecture:

Database
   |
   v
Backup Process
   |
   v
Object Storage
   |
   v
Archive Tier

A backup strategy should define:

  • frequency
  • retention
  • encryption
  • storage location
  • restoration procedure
  • RPO
  • RTO

A backup that has never been restored successfully should not be treated as proven recovery capability.


45. Cross-Region Storage#

For disaster recovery:

Region A
   |
   v
Object Storage A
   |
   | Replication
   v
Object Storage B
   |
   v
Region B

This can protect against regional failures.

But cross-region replication can involve:

  • latency
  • bandwidth cost
  • replication delay
  • consistency considerations

46. Storage Consistency#

Storage systems can have different consistency semantics.

Questions include:

After writing an object,
when should a read see it?
 
After deleting an object,
when should the deletion become visible?
 
If two clients update metadata,
which value wins?

The exact behavior depends on the storage technology.

For system design, always identify the consistency guarantees required by the application.


47. Storage Availability#

Suppose a storage system has:

99.9% availability

That means downtime can still occur.

Applications should consider:

  • retries
  • timeouts
  • fallback
  • replication
  • asynchronous processing
  • graceful degradation

For critical files, redundant storage locations may be appropriate.


48. Storage Cost#

Storage architecture is also a cost problem.

Suppose:

100 TB data

With replication factor 3:

~300 TB raw capacity

With erasure coding, the raw overhead may be lower depending on the coding scheme.

Then add:

  • backups
  • replicas
  • metadata
  • network transfer
  • request costs
  • retrieval costs
  • processing costs

Therefore:

Capacity planning must include total lifecycle cost, not just disk size.


49. Storage Throughput Planning#

Suppose:

10,000 users

each upload:

10 MB/sec

Peak ingest:

10,000 × 10 MB/sec
= 100,000 MB/sec
≈ 100 GB/sec

This is an enormous ingest workload.

The system needs to consider:

  • client bandwidth
  • network ingress
  • object storage capacity
  • metadata throughput
  • processing workers
  • queue capacity

Back-of-the-envelope estimation is essential.


50. Storage Backpressure#

Suppose uploads arrive faster than processing can handle them.

Uploads
   |
   v
Queue
   |
   v
Workers

If:

Incoming = 10,000 files/sec
Processing = 5,000 files/sec

the queue grows.

Eventually:

Queue
###########
###########
###########

The system needs backpressure mechanisms such as:

  • rate limiting
  • upload limits
  • queue-based buffering
  • autoscaling
  • admission control

51. Storage and Queues#

Large file processing is often asynchronous.

Upload
  |
  v
Object Storage
  |
  v
Event
  |
  v
Queue
  |
  v
Workers

The queue decouples:

Upload speed

from:

Processing speed

This prevents temporary processing slowdowns from immediately blocking uploads.


52. Distributed File Systems#

A distributed file system spreads files across multiple machines.

Conceptually:

                 Client
                   |
                   v
             Metadata Service
                   |
        +----------+----------+
        |          |          |
        v          v          v
     Node A     Node B     Node C
      data        data       data

The system may maintain:

  • file metadata
  • block placement
  • replication
  • failure detection

Distributed file systems are useful when applications need filesystem-like semantics at large scale.


53. Metadata Is Often the Hard Part#

Suppose:

10 billion files

The data bytes may be distributed easily enough, but metadata such as:

file -> location
file -> permissions
file -> owner
file -> timestamps

can become a bottleneck.

Therefore large storage systems often design metadata services carefully.

Potential techniques include:

  • metadata partitioning
  • caching
  • replication
  • batching
  • hierarchical namespaces

54. Small Files Problem#

Suppose object storage contains:

1 billion files

each only:

1 KB

The total payload is only about:

1 TB

but metadata overhead can be enormous.

Many tiny files can create:

  • metadata pressure
  • request overhead
  • inefficient storage
  • slower listing operations

Sometimes applications bundle small records into larger objects or use specialized storage formats.


55. Large Files Problem#

The opposite problem is:

1 file = 10 TB

Challenges include:

  • upload reliability
  • transfer time
  • recovery from partial failure
  • replication bandwidth
  • processing
  • range access

Solutions include:

  • multipart uploads
  • chunking
  • parallel transfer
  • resumability
  • checksums
  • range reads

56. Range Reads#

For large objects, clients may need only part of the file.

Example:

10 GB video

Client requests:

Bytes 100 MB - 110 MB

Instead of downloading the entire object.

Range reads are useful for:

  • video streaming
  • large document access
  • resumable downloads
  • partial processing

57. Storage Security#

Storage often contains sensitive data.

Security measures can include:

Encryption at rest#

Stored data -> encrypted

Encryption in transit#

Client <--- encrypted connection ---> Storage

Access control#

Only authorized identities can access objects.

Least privilege#

Applications should receive only the permissions they require.

Audit logging#

Record:

  • who accessed data
  • what was accessed
  • when
  • what operation occurred

58. Object Key Security#

Avoid putting sensitive information directly into object keys.

Bad:

users/987654321/medical-record.pdf

if keys can be exposed.

A safer design may use opaque identifiers:

objects/7f3a91c2...

and keep sensitive metadata in the protected database.


59. Object Storage and Access Control#

A secure architecture may use:

Private Bucket
     |
     X
Direct public access disabled
 
Application
     |
     v
Authorization
     |
     v
Short-lived signed URL
     |
     v
User

This allows temporary access without making the entire bucket public.


60. Storage Failure Scenarios#

Production systems should consider:

Disk failure#

Disk -> FAILED

Node failure#

Storage Node -> DOWN

Rack failure#

Multiple nodes may fail.

Region failure#

Entire regional infrastructure may become unavailable.

Corruption#

Data may exist but be incorrect.

Accidental deletion#

Valid data may be removed.

Credential compromise#

Unauthorized access may occur.

Each requires different protection.


61. Replication Does Not Protect Against Everything#

Suppose:

User accidentally deletes file

If deletion is replicated:

Primary
  |
  v
DELETE
  |
  +---- Replica A
  +---- Replica B

All copies may disappear.

Therefore we still need:

  • versioning
  • backups
  • soft delete
  • retention
  • recovery procedures

Replication is not a substitute for backup.


62. Versioning#

Object versioning can preserve previous versions.

Example:

file.pdf
  |
  +-- Version 1
  +-- Version 2
  +-- Version 3

If Version 3 is accidentally deleted or corrupted, an earlier version may remain recoverable.

Versioning increases storage consumption, so lifecycle policies are important.


63. Soft Delete#

Instead of immediately deleting:

DELETE file

the system can mark it as deleted:

deleted = true

and physically remove it later.

This creates a recovery window.

Example:

Day 0:
Deleted
 
Day 1:
Recoverable
 
Day 30:
Permanent deletion

This is useful for user-facing recovery and operational safety.


64. Storage Lifecycle Architecture#

A mature storage system may look like:

Upload
  |
  v
Hot Storage
  |
  | after 30 days
  v
Warm Storage
  |
  | after 180 days
  v
Cold Storage
  |
  | after 1 year
  v
Archive
  |
  | after retention period
  v
Delete

This controls cost while preserving required retention.


65. Real-World Architecture: Photo Sharing App#

Suppose users upload photos.

Architecture:

                Mobile/Web Client
                       |
                       v
                  API Server
                       |
              Generate upload URL
                       |
                       v
                 Object Storage
                       |
                  Storage Event
                       |
                       v
                     Queue
                       |
             +---------+---------+
             |         |         |
             v         v         v
          Resize    Thumbnail  Metadata
             |         |         |
             +---------+---------+
                       |
                       v
                 Object Storage
                       |
                       v
                      CDN
                       |
                       v
                     Users

Database stores:

photo_id
user_id
object_key
thumbnail_key
status
created_at

Object storage stores:

original photo
processed photo
thumbnail

This separates metadata from large binary content.


66. Real-World Architecture: Video Platform#

Uploader
   |
   v
Signed Upload URL
   |
   v
Object Storage
   |
   v
Event
   |
   v
Queue
   |
   v
Transcoding Workers
   |
   +---- 360p
   +---- 720p
   +---- 1080p
   +---- 4K
   |
   v
Object Storage
   |
   v
CDN
   |
   v
Viewers

Database stores:

video_id
owner_id
title
status
duration
object references

The video bytes remain in object storage.


67. Practical Exercise#

Design a file-storage service with:

10 million users
100 million files
Average file = 5 MB

Requirements:

  • upload
  • download
  • delete
  • sharing
  • thumbnails
  • high durability
  • CDN delivery for public files

Estimate:

Raw data#

100 million × 5 MB
= 500 million MB
≈ 500 TB

Then consider:

  • replication
  • thumbnails
  • versions
  • backups
  • metadata
  • growth

Your actual storage requirement will be significantly larger than the raw 500 TB.


68. Mini Project#

Build a local file-storage service.

Features:

POST /upload
GET /files/:id
DELETE /files/:id
GET /files/:id/download

Architecture:

Client
  |
  v
Node.js / Next.js API
  |
  +---- Metadata DB
  |
  +---- Local Object Directory

Implement:

  • unique object IDs
  • metadata records
  • file size validation
  • content-type validation
  • upload/download
  • soft delete
  • file expiration
  • checksum
  • simple authorization
  • cleanup worker

Then extend it with:

Storage
  |
  v
Queue
  |
  v
Thumbnail Worker

This prepares you for real media-storage architectures.


69. Interview Questions#

Beginner#

  1. What is a storage system?
  2. What is block storage?
  3. What is file storage?
  4. What is object storage?
  5. What is the difference between HDD and SSD?
  6. What is IOPS?
  7. What is throughput?
  8. What is storage latency?

Intermediate#

  1. Why is object storage useful for media?
  2. Why use pre-signed URLs?
  3. What is multipart upload?
  4. What is storage replication?
  5. What is erasure coding?
  6. What is storage durability?
  7. Durability vs availability?
  8. How would you store user-uploaded images?
  9. How would you handle large video uploads?
  10. How would you design storage lifecycle policies?

Advanced#

  1. How would you design object storage for billions of objects?
  2. How would you design cross-region storage?
  3. How would you protect against accidental deletion?
  4. How would you design storage for 100 GB uploads?
  5. How would you prevent application servers from becoming upload bottlenecks?
  6. How would you design media processing asynchronously?
  7. How would you handle a storage-region failure?
  8. How would you estimate storage capacity and cost?
  9. How would you design a distributed file system?
  10. How would you solve the small-files problem?

70. Interview Scenario#

Question#

Users upload videos up to 20 GB. Your application servers are becoming overloaded. How would you redesign the upload architecture?

A strong approach:

Client
  |
  | Request upload authorization
  v
Application
  |
  | Short-lived signed URL
  v
Client
  |
  | Multipart upload
  v
Object Storage
  |
  | Event
  v
Queue
  |
  v
Processing Workers

Benefits:

  • application servers do not proxy the entire file
  • uploads can be parallel
  • failed parts can be retried
  • processing is asynchronous
  • storage scales independently

71. Production Storage Checklist#

Storage choice#

  • Block vs file vs object selected appropriately
  • Access pattern understood
  • Latency requirements defined
  • Throughput requirements defined

Capacity#

  • Current data size estimated
  • Growth rate estimated
  • Replication overhead included
  • Backup capacity included
  • Metadata overhead included

Reliability#

  • Replication strategy
  • Failure domains
  • Backup strategy
  • Restore testing
  • Versioning/soft delete where needed

Performance#

  • IOPS estimated
  • Throughput estimated
  • Large-file strategy
  • Multipart uploads
  • Range reads

Security#

  • Encryption
  • Authentication
  • Authorization
  • Least privilege
  • Audit logs
  • Secure object access

Lifecycle#

  • Hot/warm/cold/archive tiers
  • Retention policy
  • Cleanup
  • Version expiration

Application architecture#

  • Direct-to-storage uploads
  • Signed URLs
  • Async processing
  • Queue/backpressure
  • CDN delivery

72. Master Mental Model#

Think of storage design in this order:

                STORAGE DESIGN
                      |
        +-------------+-------------+
        |             |             |
      ACCESS        PERFORMANCE   DURABILITY
        |             |             |
     Block/File     Latency       Replication
     Object         IOPS          Erasure Coding
                    Throughput    Backups
        |             |             |
        +-------------+-------------+
                      |
                   CAPACITY
                      |
             +--------+--------+
             |        |        |
           Size     Growth    Cost
                      |
                      v
                   LIFECYCLE
                      |
             Hot -> Warm -> Cold
                      |
                      v
                   SECURITY
                      |
        +-------------+-------------+
        |             |             |
     Encryption    IAM/Auth      Auditing

The core questions are:

1. What kind of data are we storing?
2. How will it be accessed?
3. How much data will we have?
4. How fast must reads/writes be?
5. What happens when storage fails?
6. How durable must the data be?
7. How long must we keep it?
8. How much will it cost?
9. How will users upload/download large objects?
10. How will we recover from accidental deletion?

73. Chapter Summary#

In this chapter, we learned:

  • storage system fundamentals
  • storage hierarchy
  • local storage
  • network storage
  • block storage
  • file storage
  • object storage
  • HDD vs SSD
  • NVMe
  • latency
  • throughput
  • IOPS
  • sequential vs random I/O
  • durability
  • availability
  • replication
  • replication factor
  • erasure coding
  • checksums
  • object metadata
  • buckets and object keys
  • large-file storage
  • direct uploads
  • pre-signed URLs
  • multipart uploads
  • resumable uploads
  • CDN + object storage
  • media storage architecture
  • hot/warm/cold/archive tiers
  • lifecycle management
  • retention
  • cleanup
  • metadata databases
  • distributed file systems
  • small-files problem
  • large-files problem
  • range reads
  • storage security
  • versioning
  • soft deletes
  • cross-region storage
  • storage backpressure
  • queues for file processing
  • capacity planning
  • storage cost
  • real-world photo/video architectures
  • interview questions
  • production storage checklist

The central idea is:

Storage architecture is about matching the data and access pattern to the right storage model while balancing latency, throughput, durability, availability, capacity, security, and cost.


74. Final Interview Checklist#

Make sure you can explain:

  • Block storage
  • File storage
  • Object storage
  • Local storage
  • Network storage
  • HDD vs SSD
  • NVMe
  • Latency
  • Throughput
  • IOPS
  • Sequential vs random I/O
  • Durability
  • Availability
  • Replication factor
  • Erasure coding
  • Checksums
  • Object metadata
  • Pre-signed URLs
  • Multipart uploads
  • Resumable uploads
  • CDN + object storage
  • Storage tiers
  • Lifecycle management
  • Retention
  • Versioning
  • Soft delete
  • Cross-region storage
  • Storage backpressure
  • Small-files problem
  • Large-files problem
  • Range reads
  • Storage security
  • Storage capacity planning
  • Media storage architecture

75. What's Next?#

Chapter 18 — File Upload & Media Systems#

Next we specialize the storage concepts into a complete production-grade file and media platform.

We will design:

  • File upload architecture
  • Large-file uploads
  • Multipart uploads
  • Resumable uploads
  • Upload sessions
  • Pre-signed URLs
  • File validation
  • Malware scanning
  • Image processing
  • Thumbnail generation
  • Video transcoding
  • Media pipelines
  • Async processing
  • Queues
  • Progress tracking
  • CDN delivery
  • Range requests
  • Download optimization
  • Storage metadata
  • Deduplication
  • Content hashing
  • Duplicate file detection
  • Access control
  • Private vs public files
  • Signed download URLs
  • Media processing failures
  • Retry strategies
  • Idempotent processing
  • Storage cleanup
  • Production media architecture
  • System-design interview case study

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 16 — Advanced CachingNext ChapterChapter 18 — File Upload & Media Systems
PrevNext