Systems & WebSockets · 7 min read · May 2024

Architecting SocketDrop: Real-Time Hybrid HTTP + WebSocket File Distribution

Why mixing WebSockets with chunked HTTP uploads is the optimal architecture for concurrent ephemeral file sharing rooms.

Prince Pal

Prince Pal

Software Engineer

The Problem with Pure WebSockets for Large File Transfers

While WebSockets excel at full-duplex, low-overhead messaging, pushing 50MB binary payloads directly down a WebSocket frame can clog the TCP pipeline, starve critical control packets (like heartbeats and chat notifications), and cause head-of-line blocking.

For SocketDrop, we adopted a hybrid architecture:

  • 1.HTTP Multi-part Endpoints handle large file streaming, disk persistence, and SHA-256 integrity checks.
  • 2.WebSockets (STOMP over SockJS) handle instant room notifications, participant presence, and one-click download URLs with cryptographic UUID tokens.
  • code
    [Client A] --(HTTP POST /upload)--> [Spring Boot Server] --(Store & Tokenize)--> [Disk Storage]
                                                |
                                      (WebSocket Broadcast)
                                                v
    [Client B] <======================= [Room Event Notification]
    [Client B] --(HTTP GET /download/token)--> [Download Stream]

    This separation enables SocketDrop to smoothly handle up to 50 concurrent room participants without lagging the UI or dropping websocket connections.

    Technologies & Concepts Covered:
    WebSockets
    Java
    Spring Boot
    Networking
    Concurrency
    Prince Pal

    Written by Prince Pal

    Full Stack & Backend Engineer · 7x Hackathon Winner · Open source mentor

    Shoot an Email ↗
    @princepal