Back to explorer
Core Fundamentals• 30 Min

Handling Large Blobs & File Uploads at Scale

MEDIUM

Handling Large Blobs & File Uploads at Scale

Streaming a 5 GB video file through your API Gateway consumes backend thread pools, eats memory buffers, and is vulnerable to complete failure if a cell tower disconnects at 99%.


1. Direct-to-Storage with Presigned URLs

Never pipe massive file payloads through your microservice containers!

  1. Client requests upload ticket: POST /api/v1/uploads { filename: "vid.mp4", size: 5GB }.
  2. Backend generates a cryptographically signed Amazon S3 / GCS Presigned URL with a 15-minute expiration.
  3. Client uploads directly to the S3 bucket using HTTP PUT.
  4. S3 fires an event notification (SNS / SQS) to trigger asynchronous transcoding pipelines.

2. Multipart & Resumable Uploads

  • Splits the file into 5 MB–20 MB binary chunks on the client.
  • Uploads chunks in parallel over multiple TCP streams.
  • If Chunk #42 fails due to packet loss, only that 10 MB chunk is retried, not the entire 5 GB video.

Key Architecture Trade-Offs & Decision Matrix

Decision FactorChoice AChoice BSelected Architectural Rationale
Communication ProtocolREST over HTTP/2WebSockets / gRPCUse REST for stateless CRUD APIs; use WebSockets for low-latency bidirectional streaming.
State ManagementCentralized Distributed StoreLocal Memory with Sticky SessionsCentralized Redis / Database state allows seamless container auto-scaling and zero-downtime rolling deploys.
Concurrency ControlOptimistic Locking (version column)Pessimistic Locking (SELECT FOR UPDATE)Optimistic locking delivers superior throughput for low-conflict consumer operations.