Server Sent Events

Somesh Singh
Jul 21 · 5 min read
Tokopedia, Server Sent Events reducing upload time
Tokopedia, Server Sent Events reducing upload time
SSE @ Tokopedia

Introduction

Typical File Upload Process

Upload File Progress Bar High Level Flow
Upload File Progress Bar High Level Flow

High-level Architecture

High Level Upload file and Progress Bar API Server Sent Event Architecture
High Level Upload file and Progress Bar API Server Sent Event Architecture

How to make Go handler ready for SSE?

func ProgressHandler(w http.ResponseWriter, r *http.Request)(interface{}, error) {
w.Header().Set(“Connection”, “keep-alive”)
w.Header().Set(“Content-Type”, “text/event-stream”)
w.Header().Set(“Cache-Control”, “no-cache”)
w.Header().Set(“X-Accel-Buffering”, “no”)
:
:
}

Tuning Nginx

location /progress {
proxy_set_header Connection '';
proxy_http_version 1.1;
proxy_cache off;

proxy_pass http://localhost:1991;
}

Don’t add these modules in Streaming API location block

Unknown Territory

Server Sent Event and Server Push Event

References

Tokopedia Engineering

Story from people who build Tokopedia

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store