The demand for responsive real-time web applications continues to grow, making the selection of backend technology and WebSocket libraries a crucial factor in determining performance. Node.js and Golang are popular platforms for real-time applications. However, the WebSocket library within them offers a trade-off between features and efficiency, the impact of which has not been comprehensively measured. This research aims to fill this gap by conducting a quantitative performance analysis to compare the efficiency and scalability of four WebSocket libraries: ws and socket.io on Node.js, and gorilla/websocket and coder/websocket on Golang. This research uses a benchmarking experimental method with client load simulations that gradually increase from 100 to 1000 concurrent clients. The experiment was conducted through two scenarios, namely the Echo Test and Broadcast Test. In the Echo Test, the performance metrics measured were Connection Time, Round Trip Time (RTT), and Throughput. Meanwhile, in the Broadcast Test, the performance metric measured was Broadcast Latency. The results from the Echo Test show a significant performance disparity. At a peak load of 1000 clients, socket.io achieved a throughput of only 27,152 messages/second, whereas the lightweight libraries (ws, gorilla/websocket, and coder/websocket) all achieved over 44,000 messages/second. In the Broadcast Test with a high load, the latency difference between the four libraries became insignificant. Therefore, for applications prioritizing raw performance in point-to-point communication, certain WebSocket libraries such as ws, gorilla/websocket, and coder/websocket are more suitable for future development.
Copyrights © 2025