[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-en-1-1-all-websocket-compression-delta-updates-all--*":3,"academy-blog-translations-f2bwyhhfkxqaii0":85},{"data":4,"page":72,"perPage":72,"totalItems":72,"totalPages":72},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":80,"keywords":81,"locale":54,"published_at":82,"scheduled_at":13,"school_blog":76,"short_description":83,"status":74,"title":6,"updated":84,"updated_by":13,"slug":77,"views":79},"EP.104 Using WebSocket Compression and Delta Updates","sclblg987654321","school_blog_translations","\u003Cp>When a WebSocket system needs to handle a large amount of real-time data such as in chat systems, online games, or live dashboards the performance of data transmission becomes the key factor.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Techniques that help the system run faster while using less bandwidth are:\u003C\u002Fp>\u003Cul>\u003Cli>✅ Data compression (WebSocket Compression)\u003C\u002Fli>\u003Cli>✅ Updating only the parts that have changed (Delta Updates)\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>These two techniques combined will make your system “light but powerful” truly suitable for production-grade workloads. 🚀\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🧩 1. What is WebSocket Compression?\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Normally, WebSocket sends raw data every time, even if only one character changes. Enabling the Compression Extension (permessage-deflate) compresses the data before sending, significantly reducing the payload size.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>🔹 Example of enabling Compression in Go:\u003C\u002Fh3>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">package main\n\nimport (\n\t\"log\"\n\t\"net\u002Fhttp\"\n\n\t\"github.com\u002Fgorilla\u002Fwebsocket\"\n)\n\nvar upgrader = websocket.Upgrader{\n\tEnableCompression: true, \u002F\u002F enable compression\n\tCheckOrigin: func(r *http.Request) bool { return true },\n}\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tconn, _ := upgrader.Upgrade(w, r, nil)\n\tdefer conn.Close()\n\n\tconn.EnableWriteCompression(true) \u002F\u002F enable compression for message\n\n\tfor {\n\t\tmt, msg, err := conn.ReadMessage()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tlog.Printf(\"Received: %s\", msg)\n\t\tconn.WriteMessage(mt, []byte(\"Compressed response OK!\"))\n\t}\n}\n\nfunc main() {\n\thttp.HandleFunc(\"\u002Fws\", handler)\n\tlog.Println(\"WebSocket Server running on :8080\")\n\thttp.ListenAndServe(\":8080\", nil)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>✅ Result:\u003C\u002Fh3>\u003Cul>\u003Cli>Data size reduced by 30–80%\u003C\u002Fli>\u003Cli>Save bandwidth, especially on mobile networks\u003C\u002Fli>\u003Cli>Latency is reduced when data has repeated patterns\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⚙️ 2. What is Delta Updates?\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Delta Update means sending only the parts of the data that have changed, instead of sending the entire object every time.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-json\">\u002F\u002F Regular method\n{\n  \"user_id\": 101,\n  \"score\": 4200\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>If only the score changes, sending the full object repeatedly is wasteful. So we send only the “delta,” like:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-json\">{ \"score\": 4300 }\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Or in Binary Protocol, only the changed fields are encoded.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>🔹 Example of Delta Update in Go:\u003C\u002Fh3>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">type UserData struct {\n\tID    int    `json:\"id\"`\n\tName  string `json:\"name\"`\n\tScore int    `json:\"score\"`\n}\n\nvar oldData = UserData{ID: 1, Name: \"Alice\", Score: 4200}\nvar newData = UserData{ID: 1, Name: \"Alice\", Score: 4300}\n\nfunc getDelta(old, new UserData) map[string]interface{} {\n\tdelta := make(map[string]interface{})\n\tif old.Score != new.Score {\n\t\tdelta[\"score\"] = new.Score\n\t}\n\tif old.Name != new.Name {\n\t\tdelta[\"name\"] = new.Name\n\t}\n\treturn delta\n}\n\nfunc main() {\n\td := getDelta(oldData, newData)\n\tfmt.Println(\"Delta Update:\", d)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Result:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">Delta Update: map[score:4300]\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Then we can send this delta through WebSocket to the client immediately.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🔧 3. Combining Compression + Delta Updates\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>When combining WebSocket Compression with Delta Updates, it results in communication that is “both fast and light.”\u003C\u002Fp>\u003Cul>\u003Cli>Compression reduces payload size\u003C\u002Fli>\u003Cli>Delta reduces the amount of data sent\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Suitable for systems like:\u003C\u002Fp>\u003Cul>\u003Cli>Real-time dashboards\u003C\u002Fli>\u003Cli>Multiplayer game\u003C\u002Fli>\u003Cli>IoT data stream\u003C\u002Fli>\u003Cli>Live trading platform\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>💡 4. Best Practices\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cul>\u003Cli>Enable \u003Ccode inline=\"\">EnableCompression\u003C\u002Fcode> only when necessary, because there is overhead from compressing\u002Fdecompressing data\u003C\u002Fli>\u003Cli>Use Binary + Delta Encoding together for best results\u003C\u002Fli>\u003Cli>Store the latest snapshot of data on the server side for accurate delta calculation\u003C\u002Fli>\u003Cli>Verify that the client supports delta logic before enabling it\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🚀 Give it a try!\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Try enabling Compression + Delta Updates in your WebSocket Server and test how much bandwidth is saved and how much latency is improved 💪\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Chr>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🌟 Next EP:\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp data-start=\"3924\" data-end=\"4114\">In \u003Cstrong data-start=\"3927\" data-end=\"3937\">EP.105\u003C\u002Fstrong>, we’ll talk about: \u003Cstrong data-start=\"3959\" data-end=\"4027\">\"Event Queue Management and Prioritization in WebSocket Systems\" \u003C\u002Fstrong>How to organize, prioritize, and efficiently dispatch real-time events at scale ⚙️\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp data-start=\"498\" data-end=\"834\">\u003Cstrong>Read more\u003C\u002Fstrong>\u003C\u002Fp>\u003Cul>\u003Cli>\u003Cp data-start=\"498\" data-end=\"834\">\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdev.school\u002Fblogs\u002Fcategories\u002FGolang\">\u003Cstrong>Golang The Series\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp data-start=\"498\" data-end=\"834\">\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdev.school\u002Fblogs\u002Fcategories\u002FJS2GO\">\u003Cstrong>JS2GO\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp data-start=\"498\" data-end=\"834\">\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdev.school\u002Fen\u002Fblogs\u002Fcategories\u002FTailwind%20CSS\">\u003Cstrong>10 Eps That Will Make You a Pro Tailwind CSS Overnight\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003C\u002Ful>\u003Cp>\u003Cstrong>🔵 Facebook: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.facebook.com\u002Fsuperdev.academy.th\">\u003Cstrong>Superdev Academy\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003Cp>\u003Cstrong>🔴 YouTube: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.youtube.com\u002Fchannel\u002FUC2eI2RxcA2zbTqZyHyWIfRg\">\u003Cstrong>Superdev Academy\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003Cp>\u003Cstrong>📸 Instagram: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.instagram.com\u002Fsuperdevschool\u002F\">\u003Cstrong>Superdev Academy\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003Cp>\u003Cstrong>🎬 TikTok: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.tiktok.com\u002F@superdevacademy?lang=th-TH\">\u003Cstrong>https:\u002F\u002Fwww.tiktok.com\u002F@superdevacademy?lang=th-TH\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003Cp>\u003Cstrong>🌐 Website: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdevacademy.com\u002Fen\">\u003Cstrong>https:\u002F\u002Fwww.superdevacademy.com\u002Fen\u003C\u002Fstrong>\u003C\u002Fa>\u003Cstrong>&nbsp;\u003C\u002Fstrong>\u003C\u002Fp>","180_11zon_yb61shjlrg.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002Frbwy4pd2q7zk19b\u002F180_11zon_yb61shjlrg.webp","2026-03-04 08:45:43.310Z","",{"keywords":15,"locale":48,"school_blog":58},[16,23,28,33,38,43],{"collectionId":17,"collectionName":18,"created":19,"created_by":13,"id":20,"name":21,"updated":22,"updated_by":13},"sclkey987654321","school_keywords","2026-03-04 08:44:49.054Z","vbjgbr5ah0kh43p","Real-time System","2026-04-10 16:12:50.311Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-04 08:45:42.303Z","qkl7bo7npif1kol","Data Optimization","2026-04-10 16:13:02.047Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-03-04 08:45:42.529Z","ecerocgj9i627rc","Delta Updates","2026-04-10 16:13:02.145Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-03-04 08:45:42.906Z","j7q46g7i692c0mw","WebSocket Compression","2026-04-10 16:13:02.240Z",{"collectionId":17,"collectionName":18,"created":39,"created_by":13,"id":40,"name":41,"updated":42,"updated_by":13},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","Go","2026-04-10 16:07:25.893Z",{"collectionId":17,"collectionName":18,"created":44,"created_by":13,"id":45,"name":46,"updated":47,"updated_by":13},"2026-03-04 08:44:11.932Z","8sanh9jytfatsgk","Performance Optimization","2026-04-10 16:12:41.404Z",{"code":49,"collectionId":50,"collectionName":51,"created":52,"flag":53,"id":54,"is_default":55,"label":56,"updated":57},"en","pbc_1989393366","locales","2026-01-22 11:00:02.726Z","twemoji:flag-united-states","qv9c1llfov2d88z",false,"English","2026-04-10 15:42:46.825Z",{"category":59,"collectionId":60,"collectionName":61,"created":13,"expand":62,"id":76,"slug":77,"updated":78,"views":79},"wqxt7ag2gn7xcmk","pbc_2105096300","school_blogs",{"category":63},{"blogIds":64,"collectionId":65,"collectionName":66,"created":67,"created_by":13,"id":59,"image":68,"image_alt":13,"image_path":69,"label":70,"name":71,"priority":72,"publish_at":73,"scheduled_at":13,"status":74,"updated":75,"updated_by":13},[],"sclcatblg987654321","school_category_blogs","2026-03-04 08:33:53.210Z","59ty92ns80w_15oc1implw.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fwqxt7ag2gn7xcmk\u002F59ty92ns80w_15oc1implw.png",{"en":71,"th":71},"Golang The Series",1,"2026-03-16 04:39:38.440Z","published","2026-04-25 02:32:15.470Z","f2bwyhhfkxqaii0","websocket-compression-delta-updates","2026-05-11 11:37:30.329Z",225,"rbwy4pd2q7zk19b",[20,25,30,35,40,45],"2025-10-31 02:33:46.208Z","Learn how to optimize your WebSocket Server performance by compressing data and sending only the changed parts (Delta Updates) making your system faster, lighter, and production-ready.","2026-04-25 02:47:56.212Z",{"th":77,"en":77}]