{"id":21486918,"url":"https://github.com/ntsd/websocket-benchmark","last_synced_at":"2025-10-13T01:33:49.594Z","repository":{"id":206079489,"uuid":"712592816","full_name":"ntsd/websocket-benchmark","owner":"ntsd","description":"Compares the speed of WebSocket frameworks for different languages","archived":false,"fork":false,"pushed_at":"2025-10-06T01:18:40.000Z","size":108,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T03:19:44.414Z","etag":null,"topics":["benchmark","bun","fasthttp","gorilla-websocket","hacktoberfest","k6","tokio-tungstenite","uwebsockets","websocket"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntsd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-31T19:24:07.000Z","updated_at":"2025-10-06T01:18:44.000Z","dependencies_parsed_at":"2023-11-13T18:44:51.926Z","dependency_job_id":"c562e948-a94c-42a5-8d7f-3a585896dd6b","html_url":"https://github.com/ntsd/websocket-benchmark","commit_stats":null,"previous_names":["ntsd/websocket-benchmark"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ntsd/websocket-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fwebsocket-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fwebsocket-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fwebsocket-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fwebsocket-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntsd","download_url":"https://codeload.github.com/ntsd/websocket-benchmark/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fwebsocket-benchmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013897,"owners_count":26085326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","bun","fasthttp","gorilla-websocket","hacktoberfest","k6","tokio-tungstenite","uwebsockets","websocket"],"created_at":"2024-11-23T13:24:47.675Z","updated_at":"2025-10-13T01:33:49.588Z","avatar_url":"https://github.com/ntsd.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebSocket Benchmark\n\nThis repository compares the speed of WebSocket frameworks for different languages.\n\n## Frameworks\n\n1. [Bun WebSockets](https://bun.sh/docs/api/websockets)\n2. [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js)\n3. [gorilla/websocket](https://github.com/gorilla/websocket)\n4. [fasthttp/websocket](https://github.com/fasthttp/websocket)\n5. [tokio-tungstenite](https://github.com/snapview/tokio-tungstenite)\n6. [websocketpp](https://github.com/zaphoyd/websocketpp)\n7. [sip](https://github.com/PooyaEimandar/sib) Thanks to @PooyaEimandar\n\n## Test Resources\n\nTo ensure a fair comparison, the resources will be limited using Docker to determine the most efficient framework per resource.\n\nCPU Limit: 2 cores (Apply M3)\n\nMemory Limit: 1GB\n\nMemory Swap: no swap\n\nMore details: \u003chttps://docs.docker.com/config/containers/resource_constraints/\u003e\n\n\u003e Note: I performed some tests using my local machine without CPU limits.\n\u003e The results were that Go performed better than both Bun and Node.\n\u003e You could try it yourself on a high performance machine.\n\n## Test Methods\n\nPort Number: 9001\n\nAll tests are performed in concurrent connections using 16, 64, 128 virtual users (VUs) with a duration of 5 seconds for each test.\n\n1. Connection Speed Test\n\npath: `HTTP /`\n\nThe client connects to the server, gets a 101 status response, and then closes the connection.\n\n2. Text Message Test\n\npath: `WS /plain`\n\nThe client sends `{randomText}`, and the server responds with `{randomText}`.\n\n3. JSON Message Test\n\npath: `WS /json`\n\nThe client sends `{\"number\": {randomNumber}}` and the server responds as follows:\n\nIf the number is odd, the server sends `{\"number\": {randomNumber + 1}}`.\n\nIf the number is even, the server sends `{\"number\": {randomNumber + 2}}`.\n\n4. Binary Message Test\n\npath: `WS /binary`\n\nThe client sends a `number` in an Int32Array message.\n\nIf the number is odd, the server responds with `number+1`.\n\nIf the number is even, the server responds with `number+2`.\n\n### Sync and Async Tests\n\nAsynchronous test sends messages without waiting for the response message.\n\nSynchronous test sends a message, waits for the response message, and then sends the next message.\n\n### Why Test with a Condition Statement?\n\nIn real use cases, we don't only receive and send messages using frameworks. Other parts of the code, such as the JSON parser or DB connect, etc.\n\n## Results\n\nCheck other results in the `./results` directory.\n\n### Connection Method 16 VUs Result\n\n| Framework          | ws_sessions   | ws_connecting                                                             |\n| ------------------ | ------------- | ------------------------------------------------------------------------- |\n| bun-websocket      | 8499.867364/s | avg=1.84ms min=499.66µs med=1.65ms max=58.16ms p(90)=2.43ms p(95)=2.8ms   |\n| fasthttp-websocket | 8412.220813/s | avg=1.86ms min=311.83µs med=1.69ms max=34.66ms p(90)=2.52ms p(95)=2.94ms  |\n| tokio-tungstenite  | 8001.300394/s | avg=1.96ms min=476.37µs med=1.76ms max=55.22ms p(90)=2.59ms p(95)=3ms     |\n| uwebsocket-js      | 7794.733031/s | avg=2ms min=482.7µs med=1.79ms max=103.02ms p(90)=2.63ms p(95)=3.06ms     |\n| websocketpp        | 6494.632196/s | avg=2.42ms min=625µs med=2.22ms max=65.99ms p(90)=2.96ms p(95)=3.38ms     |\n| gorilla-websocket  | 4041.91578/s  | avg=3.91ms min=362.91µs med=1.96ms max=202.4ms p(90)=9.77ms p(95)=12.61ms |\n| sib                | 13.398208/s   | avg=747.03ms min=265.54µs med=1.62ms max=34.93s p(90)=4.51ms p(95)=5.66ms |\n\n### JSON Sync Method 16 VUs Result\n\n| Framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| tokio-tungstenite  | 37935.617767/s   |\n| bun-websocket      | 36708.43469/s    |\n| gorilla-websocket  | 34822.879647/s   |\n| websocketpp        | 34657.213957/s   |\n| fasthttp-websocket | 32446.244966/s   |\n| uwebsocket-js      | 32044.007075/s   |\n| sib                | 28158.671323/s   |\n\n### JSON Async Method 16 VUs Result\n\n| Framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| tokio-tungstenite  | 327224.988122/s  |\n| bun-websocket      | 293216.98072/s   |\n| websocketpp        | 291755.287335/s  |\n| uwebsocket-js      | 266258.581015/s  |\n| fasthttp-websocket | 209233.336363/s  |\n| gorilla-websocket  | 201350.128115/s  |\n| sib                | 37153.030704/s   |\n\n### Binary Sync Method 16 VUs Result\n\n| Framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| tokio-tungstenite  | 37347.855585/s   |\n| websocketpp        | 36198.696847/s   |\n| uwebsocket-js      | 34129.443009/s   |\n| gorilla-websocket  | 34065.377308/s   |\n| bun-websocket      | 34028.915716/s   |\n| fasthttp-websocket | 30066.910145/s   |\n| sib                | 28952.664725/s   |\n\n### Binary Async Method 16 VUs Result\n\n| Framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| tokio-tungstenite  | 297233.517612/s  |\n| sib                | 292559.60582/s   |\n| websocketpp        | 274422.674722/s  |\n| gorilla-websocket  | 262322.002225/s  |\n| bun-websocket      | 239248.186499/s  |\n| fasthttp-websocket | 234948.363489/s  |\n| uwebsocket-js      | 134965.345539/s  |\n\n### Connection Method 64 VUS Result\n\n| framework          | ws_sessions    | ws_connecting                                                             |\n| ------------------ | -------------- | ------------------------------------------------------------------------- |\n| tokio-tungstenite  | 13137.162324/s | avg=4.77ms min=551.53µs med=4.44ms max=80.03ms p(90)=6.78ms p(95)=7.72ms  |\n| bun-websocket      | 13069.55048/s  | avg=4.79ms min=525.68µs med=4.39ms max=100.63ms p(90)=6.87ms p(95)=7.97ms |\n| uwebsocket-js      | 11882.529466/s | avg=5.27ms min=682.24µs med=4.81ms max=58.78ms p(90)=7.58ms p(95)=8.8ms   |\n| fasthttp-websocket | 11524.364692/s | avg=5.44ms min=475.44µs med=4.94ms max=82.83ms p(90)=8.3ms p(95)=9.7ms    |\n| gorilla-websocket  | 10754.352134/s | avg=5.83ms min=621.41µs med=5.28ms max=75.57ms p(90)=8.87ms p(95)=10.48ms |\n\n### JSON Sync Method 64 VUS Result\n\n| framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| tokio-tungstenite  | 81725.569759/s   |\n| bun-websocket      | 75606.357558/s   |\n| uwebsocket-js      | 73137.835789/s   |\n| fasthttp-websocket | 70818.793428/s   |\n| gorilla-websocket  | 67720.472743/s   |\n\n### JSON Async Method 64 VUS Result\n\n| framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| bun-websocket      | 611168.371646/s  |\n| uwebsocket-js      | 563460.469109/s  |\n| fasthttp-websocket | 508246.997076/s  |\n| gorilla-websocket  | 498667.980764/s  |\n| tokio-tungstenite  | 442561.993299/s  |\n\n### Binary Sync Method 64 VUS Result\n\n| framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| tokio-tungstenite  | 80498.928468/s   |\n| uwebsocket-js      | 75384.902691/s   |\n| bun-websocket      | 69794.434565/s   |\n| fasthttp-websocket | 68214.604466/s   |\n| gorilla-websocket  | 67583.49342/s    |\n\n### Binary Async Method 64 VUS Result\n\n| framework          | ws_msgs_received |\n| ------------------ | ---------------- |\n| tokio-tungstenite  | 494548.05839/s   |\n| bun-websocket      | 467317.123974/s  |\n| uwebsocket-js      | 451046.522207/s  |\n| fasthttp-websocket | 440250.603802/s  |\n| gorilla-websocket  | 434406.944224/s  |\n\n## Contribution\n\n### Starting the Server\n\nYou can use Docker Compose:\n\n```sh\ndocker compose up fasthttp-websocket\n```\n\nReplace `fasthttp-websocket` with another framework.\n\nYou can check the list of servers in the `docker-compose.yaml` file.\n\nfor `bun-websocket`, the test methods are separate because Bun does not support multiple websocket paths, so you need to run each one individually.\n\n### K6 benchmark\n\n[Install K6](https://k6.io/docs/get-started/installation/) on your local and then run\n\n```sh\n# Run comprehensive benchmarks for all frameworks\nmake benchmark-comprehensive\n\n# Or run individual test methods\nmake benchmark-all\n```\n\nThe test methods list (or can be found in `Makefile`):\n\n**Comprehensive Benchmarks:**\n\n- `benchmark-comprehensive` - Test all frameworks with all methods and extract results\n- `benchmark-all` - Run all tests across all frameworks systematically\n- `extract-results` - Parse and display benchmark results\n\n**Direct Script Usage:**\n\n- `./websocket_benchmark.sh` - Run complete benchmark suite (same as `both`)\n- `./websocket_benchmark.sh benchmark` - Only run benchmarks\n- `./websocket_benchmark.sh extract` - Only parse existing results\n- `./websocket_benchmark.sh help` - Show usage information\n\n**Individual Tests:**\n\n- `benchmark-individual` - Run individual test methods for the currently running framework\n- `connection` - Test WebSocket connection establishment speed\n- `plain-async` - Test plain text messaging (async)\n- `plain-sync` - Test plain text messaging (sync)\n- `json-async` - Test JSON messaging (async)\n- `json-sync` - Test JSON messaging (sync)\n- `binary-async` - Test binary messaging (async)\n- `binary-sync` - Test binary messaging (sync)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntsd%2Fwebsocket-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntsd%2Fwebsocket-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntsd%2Fwebsocket-benchmark/lists"}