[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-en-1-1-all-log-analysis-stress-testing-websocket-all--*":3,"academy-blog-translations-yu0wu97qcd95w66":139},{"data":4,"page":127,"perPage":127,"totalItems":127,"totalPages":127},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":134,"keywords":135,"locale":109,"published_at":136,"scheduled_at":13,"school_blog":131,"short_description":137,"status":129,"title":6,"updated":138,"updated_by":13,"slug":132,"views":133},"Ep.30 Go and Log Analysis After Stress Testing - Enhancing Your System!","sclblg987654321","school_blog_translations","\u003Cp class=\"p1\">\u003Cstrong>Go and Log Analysis After Stress Testing - Enhancing Your System!\u003C\u002Fstrong>\u003C\u002Fp>\u003Cp class=\"p2\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">In this episode, we will explore how to analyze logs and results from stress testing to identify bottlenecks in your WebSocket system, along with solutions to improve system performance!\u003C\u002Fp>\u003Cp class=\"p4\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">\u003Cstrong>Why Analyze Logs After Stress Testing?\u003C\u002Fstrong>\u003C\u002Fp>\u003Cp class=\"p3\">Logs are crucial data sources that help us :\u003C\u002Fp>\u003Col class=\"ol1\">\u003Cli class=\"li3\">Understand issues that arise, such as dropped connections or failed message deliveries.\u003C\u002Fli>\u003Cli class=\"li3\">Identify overutilized resources, such as CPU, RAM, or network.\u003C\u002Fli>\u003Cli class=\"li3\">Plan system improvements to accommodate more users.\u003C\u002Fli>\u003C\u002Fol>\u003Cp class=\"p4\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">\u003Cstrong>Types of Logs to Check\u003C\u002Fstrong>\u003C\u002Fp>\u003Cp class=\"p3\">1. Connection Log : Check the number of successful and failed connections.\u003C\u002Fp>\u003Cp class=\"p3\">2. Latency Log : Analyze the time taken to respond to requests.\u003C\u002Fp>\u003Cp class=\"p3\">3. Error Log : Review errors, such as disconnections or undeliverable messages.\u003C\u002Fp>\u003Cp class=\"p3\">4. Resource Log : Monitor resource usage, such as CPU, RAM, and bandwidth.\u003C\u002Fp>\u003Cp class=\"p4\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">\u003Cstrong>Example of Log Analysis in Go\u003C\u002Fstrong>\u003C\u002Fp>\u003Cp class=\"p3\">1. Increase Logging in WebSocket Server\u003C\u002Fp>\u003Cp class=\"p3\">In this example :\u003C\u002Fp>\u003Cp class=\"p3\">Log connections when new connections are made and when they end.\u003C\u002Fp>\u003Cp class=\"p3\">Log errors and messages received from users.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">package main\n\nimport (\n    \"log\"\n    \"net\u002Fhttp\"\n\n    \"github.com\u002Fgorilla\u002Fwebsocket\"\n)\n\nvar upgrader = websocket.Upgrader{\n    CheckOrigin: func(r *http.Request) bool {\n        return true\n    },\n}\n\nfunc handleConnections(w http.ResponseWriter, r *http.Request) {\n    conn, err := upgrader.Upgrade(w, r, nil)\n    if err != nil {\n        log.Printf(\"Error upgrading connection: %v\", err)\n        return\n    }\n    defer conn.Close()\n\n    log.Printf(\"New client connected: %s\", r.RemoteAddr)\n\n    for {\n        _, msg, err := conn.ReadMessage()\n        if err != nil {\n            log.Printf(\"Error reading message from %s: %v\", r.RemoteAddr, err)\n            break\n        }\n        log.Printf(\"Received from %s: %s\", r.RemoteAddr, msg)\n\n        if err := conn.WriteMessage(websocket.TextMessage, msg); err != nil {\n            log.Printf(\"Error writing message to %s: %v\", r.RemoteAddr, err)\n            break\n        }\n    }\n\n    log.Printf(\"Client disconnected: %s\", r.RemoteAddr)\n}\n\nfunc main() {\n    http.HandleFunc(\"\u002Fws\", handleConnections)\n    log.Println(\"WebSocket server started at :8080\")\n    log.Fatal(http.ListenAndServe(\":8080\", nil))\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">2. Use a Log Analyzer for Analysis\u003C\u002Fp>\u003Cp class=\"p3\">You can utilize tools like ELK Stack (Elasticsearch, Logstash, Kibana) to collect and analyze logs :\u003C\u002Fp>\u003Cp class=\"p3\">Elasticsearch : Stores log data.\u003C\u002Fp>\u003Cp class=\"p3\">Logstash : Sends data from the WebSocket server to Elasticsearch.\u003C\u002Fp>\u003Cp class=\"p3\">Kibana : Displays logs graphically.\u003C\u002Fp>\u003Cp class=\"p4\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">\u003Cstrong>Troubleshooting After Log Analysis\u003C\u002Fstrong>\u003C\u002Fp>\u003Cp class=\"p3\">1. Failed Connection Issues\u003C\u002Fp>\u003Cp class=\"p3\">Causes :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Server full (Connection Limit).\u003C\u002Fli>\u003Cli class=\"li3\">High Network Latency.\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p3\">Solutions :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Increase the number of WebSocket servers in the cluster.\u003C\u002Fli>\u003Cli class=\"li3\">Adjust the ulimit on the server.\u003C\u002Fli>\u003C\u002Ful>\u003Cpre>\u003Ccode class=\"language-plaintext\">ulimit -n 65535\n \u003C\u002Fcode>\u003C\u002Fpre>\u003Cp class=\"p3\">2. High Latency\u003C\u002Fp>\u003Cp class=\"p3\">Causes :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Time-consuming message processing.\u003C\u002Fli>\u003Cli class=\"li3\">Server overloaded.\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p3\">Solutions :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Use a Worker Pool to distribute processing.\u003C\u002Fli>\u003Cli class=\"li3\">Review and optimize code in resource-intensive areas, such as database access.\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p2\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">3. Message Sending Errors\u003C\u002Fp>\u003Cp class=\"p3\">Causes :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Dropped connections.\u003C\u002Fli>\u003Cli class=\"li3\">Sending messages to unresponsive clients.\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p3\">Solutions :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Increase timeout for message sending.\u003C\u002Fli>\u003C\u002Ful>\u003Cpre>\u003Ccode class=\"language-plaintext\">conn.SetWriteDeadline(time.Now().Add(10 * time.Second))\u003C\u002Fcode>\u003C\u002Fpre>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Use ping\u002Fpong to check connection health.\u003C\u002Fli>\u003C\u002Ful>\u003Cpre>\u003Ccode class=\"language-plaintext\">conn.SetPingHandler(func(appData string) error {\n    log.Println(\"Ping received\")\n    return conn.WriteControl(websocket.PongMessage, []byte(appData), time.Now().Add(10*time.Second))\n})\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp class=\"p2\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">4. Overutilized Resources\u003C\u002Fp>\u003Cp class=\"p3\">Causes :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Excessive number of connections.\u003C\u002Fli>\u003Cli class=\"li3\">Lack of load balancing.\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p3\">Solutions :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Use a Load Balancer like NGINX or Kubernetes.\u003C\u002Fli>\u003Cli class=\"li3\">Check Redis Pub\u002FSub usage to reduce redundant processing.\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p3\">Post-Improvement Review. After resolving issues, perform stress testing again and compare results :\u003C\u002Fp>\u003Cul class=\"ul1\">\u003Cli class=\"li3\">Has latency decreased?\u003C\u002Fli>\u003Cli class=\"li3\">Has the number of successful connections increased?\u003C\u002Fli>\u003Cli class=\"li3\">Has resource usage decreased?\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p4\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">\u003Cstrong>Summary\u003C\u002Fstrong>\u003C\u002Fp>\u003Cul class=\"ul2\">\u003Cli class=\"li3\">Analyze logs to troubleshoot issues like failed connections or high latency.\u003C\u002Fli>\u003Cli class=\"li3\">Use tools like ELK Stack or Kibana for analysis.\u003C\u002Fli>\u003Cli class=\"li3\">Enhance the system using load balancers, worker pools, and timeout settings.\u003C\u002Fli>\u003C\u002Ful>\u003Cp class=\"p4\">&nbsp;\u003C\u002Fp>\u003Cp class=\"p3\">\u003Cstrong>Fun Activity\u003C\u002Fstrong>\u003C\u002Fp>\u003Cp class=\"p3\">Try using the ELK Stack to analyze logs from your WebSocket server and create a graph showing average latency over time!\u003C\u002Fp>","30_11zon_bjnctegz01.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002F1fu05b1cxz1ddr2\u002F30_11zon_bjnctegz01.webp","2026-03-04 08:51:41.713Z","",{"keywords":15,"locale":103,"school_blog":113},[16,23,28,33,38,43,48,53,58,63,68,73,78,83,88,93,98],{"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:20:11.547Z","ey3puyme01a9bsw","Go","2026-04-10 16:07:25.893Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-04 08:33:59.315Z","btmgtfwmgpke1aa","Go language","2026-04-10 16:08:04.625Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-03-04 08:20:14.253Z","ah6lvy4x8qe08l5","Golang","2026-04-10 16:07:26.172Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-03-04 08:51:39.840Z","mq2qomzo7pfa5a9","log analysis","2026-04-10 16:14:38.298Z",{"collectionId":17,"collectionName":18,"created":39,"created_by":13,"id":40,"name":41,"updated":42,"updated_by":13},"2026-03-04 08:34:00.521Z","44l3qn47xjhwgf8","Stress Testing","2026-04-10 16:08:05.159Z",{"collectionId":17,"collectionName":18,"created":44,"created_by":13,"id":45,"name":46,"updated":47,"updated_by":13},"2026-03-04 08:34:02.872Z","xntux9h6g6sr5zv","Bottlenecks","2026-04-10 16:08:05.936Z",{"collectionId":17,"collectionName":18,"created":49,"created_by":13,"id":50,"name":51,"updated":52,"updated_by":13},"2026-03-04 08:34:00.920Z","ecac9y661or1xka","WebSocket","2026-04-10 16:08:05.227Z",{"collectionId":17,"collectionName":18,"created":54,"created_by":13,"id":55,"name":56,"updated":57,"updated_by":13},"2026-03-04 08:51:40.755Z","wk58vmuon13nwlu","performance improvement","2026-04-10 16:14:38.723Z",{"collectionId":17,"collectionName":18,"created":59,"created_by":13,"id":60,"name":61,"updated":62,"updated_by":13},"2026-03-04 08:51:41.189Z","6gbye103g40ndn4","data analysis","2026-04-10 16:14:38.798Z",{"collectionId":17,"collectionName":18,"created":64,"created_by":13,"id":65,"name":66,"updated":67,"updated_by":13},"2026-03-04 08:32:51.346Z","tmzmy6jyz1n35rr","Go Programming","2026-04-10 16:08:01.434Z",{"collectionId":17,"collectionName":18,"created":69,"created_by":13,"id":70,"name":71,"updated":72,"updated_by":13},"2026-03-04 08:32:15.843Z","m0x7wo77i8iycf1","Programming Education","2026-04-10 16:07:51.675Z",{"collectionId":17,"collectionName":18,"created":74,"created_by":13,"id":75,"name":76,"updated":77,"updated_by":13},"2026-03-04 08:32:26.073Z","vnvj1oaxje9m1q8","programming for beginners","2026-04-10 16:07:54.133Z",{"collectionId":17,"collectionName":18,"created":79,"created_by":13,"id":80,"name":81,"updated":82,"updated_by":13},"2026-03-04 08:31:49.362Z","2m9vv13etpn6zkx","programming language","2026-04-10 16:07:45.606Z",{"collectionId":17,"collectionName":18,"created":84,"created_by":13,"id":85,"name":86,"updated":87,"updated_by":13},"2026-03-04 08:31:22.575Z","lfjse4xivbgg5wu","Practice programming","2026-04-10 16:07:39.541Z",{"collectionId":17,"collectionName":18,"created":89,"created_by":13,"id":90,"name":91,"updated":92,"updated_by":13},"2026-03-04 08:20:33.316Z","ln1ntwattzmxo0o","programming","2026-04-10 16:07:27.299Z",{"collectionId":17,"collectionName":18,"created":94,"created_by":13,"id":95,"name":96,"updated":97,"updated_by":13},"2026-03-04 08:31:54.955Z","264sfjffyhspetq","programmers","2026-04-10 16:07:47.221Z",{"collectionId":17,"collectionName":18,"created":99,"created_by":13,"id":100,"name":101,"updated":102,"updated_by":13},"2026-03-04 08:26:59.195Z","gab60xd583s3qaw","Superdev School","2026-04-10 16:07:37.087Z",{"code":104,"collectionId":105,"collectionName":106,"created":107,"flag":108,"id":109,"is_default":110,"label":111,"updated":112},"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":114,"collectionId":115,"collectionName":116,"created":13,"expand":117,"id":131,"slug":132,"updated":13,"views":133},"wqxt7ag2gn7xcmk","pbc_2105096300","school_blogs",{"category":118},{"blogIds":119,"collectionId":120,"collectionName":121,"created":122,"created_by":13,"id":114,"image":123,"image_alt":13,"image_path":124,"label":125,"name":126,"priority":127,"publish_at":128,"scheduled_at":13,"status":129,"updated":130,"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":126,"th":126},"Golang The Series",1,"2026-03-16 04:39:38.440Z","published","2026-04-25 02:32:15.470Z","yu0wu97qcd95w66","log-analysis-stress-testing-websocket",210,"1fu05b1cxz1ddr2",[20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100],"2025-01-27 04:43:14.866Z","Learn how to analyze logs and results from stress testing to identify bottlenecks in your WebSocket system, along with solutions to improve system performance.","2026-04-22 07:11:48.745Z",{"th":132,"en":132}]