[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-en-1-1-all-websocket-scaling-redis-kubernetes-all--*":3,"academy-blog-translations-1idpw9dwit26mgw":105},{"data":4,"page":92,"perPage":92,"totalItems":92,"totalPages":92},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":100,"keywords":101,"locale":74,"published_at":102,"scheduled_at":13,"school_blog":96,"short_description":103,"status":94,"title":6,"updated":104,"updated_by":13,"slug":97,"views":99},"EP.39 Scaling WebSocket with Redis and Kubernetes","sclblg987654321","school_blog_translations","\u003Ch3 data-pm-slice=\"1 1 []\">\u003Cspan>\u003Cstrong>Why Scale WebSocket?\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh3>\u003Cp>\u003Cspan>WebSocket allows real-time communication, but as user numbers grow, \u003Cstrong>server load can increase beyond capacity\u003C\u002Fstrong>. \u003Cstrong>Redis Pub\u002FSub and Kubernetes\u003C\u002Fstrong> help scale WebSocket to handle high traffic efficiently.\u003C\u002Fspan>\u003C\u002Fp>\u003Ch3>\u003Cspan>\u003Cstrong>System Architecture for Scaling\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh3>\u003Col data-spread=\"false\">\u003Cli>\u003Cspan>\u003Cstrong>Client\u003C\u002Fstrong> - Connects to WebSocket\u003C\u002Fspan>\u003C\u002Fli>\u003Cli>\u003Cspan>\u003Cstrong>Load Balancer\u003C\u002Fstrong> - Distributes load to multiple WebSocket Servers\u003C\u002Fspan>\u003C\u002Fli>\u003Cli>\u003Cspan>\u003Cstrong>WebSocket Servers\u003C\u002Fstrong> - Handles real-time connections\u003C\u002Fspan>\u003C\u002Fli>\u003Cli>\u003Cspan>\u003Cstrong>Redis Pub\u002FSub\u003C\u002Fstrong> - Syncs data between multiple WebSocket Servers\u003C\u002Fspan>\u003C\u002Fli>\u003Cli>\u003Cspan>\u003Cstrong>Kubernetes Cluster\u003C\u002Fstrong> - Manages multiple WebSocket Servers\u003C\u002Fspan>\u003C\u002Fli>\u003C\u002Fol>\u003Ch3>\u003Cspan>\u003Cstrong>Using Redis Pub\u002FSub to Synchronize WebSocket Servers\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh3>\u003Cp>\u003Cspan>Redis Pub\u002FSub allows WebSocket Servers to exchange messages in real-time.\u003C\u002Fspan>\u003C\u002Fp>\u003Ch4>\u003Cspan>\u003Cstrong>Example: Implementing Redis Pub\u002FSub with WebSocket\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh4>\u003Cp>\u003Cspan>File: \u003C\u002Fspan>\u003Ccode>\u003Cspan>websocket_redis.go\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">package main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"github.com\u002Fgo-redis\u002Fredis\u002Fv8\"\n)\n\nvar ctx = context.Background()\n\nfunc main() {\n    client := redis.NewClient(&amp;redis.Options{\n        Addr: \"localhost:6379\",\n    })\n\n    pubsub := client.Subscribe(ctx, \"chat_channel\")\n    defer pubsub.Close()\n\n    for msg := range pubsub.Channel() {\n        fmt.Println(\"Received message:\", msg.Payload)\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3 data-pm-slice=\"1 1 []\">\u003Cspan>\u003Cstrong>Using Kubernetes for Scaling WebSocket Servers\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh3>\u003Cp>\u003Cspan>Kubernetes \u003Cstrong>Deployment\u003C\u002Fstrong> automates the management of multiple WebSocket Servers.\u003C\u002Fspan>\u003C\u002Fp>\u003Ch4>\u003Cspan>\u003Cstrong>Kubernetes Deployment YAML File\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext\">apiVersion: apps\u002Fv1\nkind: Deployment\nmetadata:\n  name: websocket-server\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: websocket-server\n  template:\n    metadata:\n      labels:\n        app: websocket-server\n    spec:\n      containers:\n      - name: websocket-server\n        image: my-websocket-server:latest\n        ports:\n        - containerPort: 8080\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3 data-pm-slice=\"1 1 []\">\u003Cspan>\u003Cstrong>Challenge!\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh3>\u003Cp>\u003Cspan>Try configuring \u003Cstrong>Kubernetes Horizontal Pod Autoscaler (HPA)\u003C\u002Fstrong> to dynamically adjust the number of WebSocket Servers based on user load!\u003C\u002Fspan>\u003C\u002Fp>\u003Chr>\u003Ch3>\u003Cspan>\u003Cstrong>Next Episode\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fh3>\u003Cp>\u003Cspan>In \u003Cstrong>EP.40\u003C\u002Fstrong>, we will explore \u003Cstrong>GraphQL Subscription with WebSocket in Kubernetes\u003C\u002Fstrong> to enhance real-time API performance 🚀\u003C\u002Fspan>\u003C\u002Fp>","50_11zon_1zy2q0i95h.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002F1dojf0v9s031vj3\u002F50_11zon_1zy2q0i95h.webp","2026-03-04 08:51:10.179Z","",{"keywords":15,"locale":68,"school_blog":78},[16,23,28,33,38,43,48,53,58,63],{"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:32.154Z","u0s66bjop3dljau","Horizontal Scaling","2026-04-10 16:12:46.399Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-04 08:44:32.713Z","b9jmymu9lbpj60c","High Availability","2026-04-10 16:12:46.701Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-03-04 08:44:29.876Z","ozn15duk6wovj6g","Microservices","2026-04-10 16:12:46.024Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-03-04 08:51:09.083Z","qnfn648h0o2s90l","Real-Time API","2026-04-10 16:14:33.342Z",{"collectionId":17,"collectionName":18,"created":39,"created_by":13,"id":40,"name":41,"updated":42,"updated_by":13},"2026-03-04 08:20:14.253Z","ah6lvy4x8qe08l5","Golang","2026-04-10 16:07:26.172Z",{"collectionId":17,"collectionName":18,"created":44,"created_by":13,"id":45,"name":46,"updated":47,"updated_by":13},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","Go","2026-04-10 16:07:25.893Z",{"collectionId":17,"collectionName":18,"created":49,"created_by":13,"id":50,"name":51,"updated":52,"updated_by":13},"2026-03-04 08:34:10.799Z","m3qoswhgnc4c38n","Kubernetes","2026-04-10 16:08:08.875Z",{"collectionId":17,"collectionName":18,"created":54,"created_by":13,"id":55,"name":56,"updated":57,"updated_by":13},"2026-03-04 08:34:10.254Z","rss87kgvhtvkri1","Redis Pub\u002FSub","2026-04-10 16:08:08.714Z",{"collectionId":17,"collectionName":18,"created":59,"created_by":13,"id":60,"name":61,"updated":62,"updated_by":13},"2026-03-04 08:48:01.322Z","qwms9vhmllldxj2","WebSocket Load Balancing","2026-04-10 16:13:38.951Z",{"collectionId":17,"collectionName":18,"created":64,"created_by":13,"id":65,"name":66,"updated":67,"updated_by":13},"2026-03-04 08:44:50.258Z","nrtw5001po78dez","WebSocket Scaling","2026-04-10 16:12:50.756Z",{"code":69,"collectionId":70,"collectionName":71,"created":72,"flag":73,"id":74,"is_default":75,"label":76,"updated":77},"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":79,"collectionId":80,"collectionName":81,"created":13,"expand":82,"id":96,"slug":97,"updated":98,"views":99},"wqxt7ag2gn7xcmk","pbc_2105096300","school_blogs",{"category":83},{"blogIds":84,"collectionId":85,"collectionName":86,"created":87,"created_by":13,"id":79,"image":88,"image_alt":13,"image_path":89,"label":90,"name":91,"priority":92,"publish_at":93,"scheduled_at":13,"status":94,"updated":95,"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":91,"th":91},"Golang The Series",1,"2026-03-16 04:39:38.440Z","published","2026-04-25 02:32:15.470Z","1idpw9dwit26mgw","websocket-scaling-redis-kubernetes","2026-05-07 18:52:13.131Z",311,"1dojf0v9s031vj3",[20,25,30,35,40,45,50,55,60,65],"2025-03-17 02:13:19.995Z","Learn how to scale WebSocket using Redis Pub\u002FSub and Kubernetes to handle high traffic and improve real-time system performance.","2026-05-06 08:38:39.278Z",{"th":97,"en":97}]