{"id":31790763,"url":"https://github.com/codebam/tokio-chat-server","last_synced_at":"2025-10-10T16:29:45.585Z","repository":{"id":301533864,"uuid":"1009529747","full_name":"codebam/tokio-chat-server","owner":"codebam","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-29T04:48:31.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-26T08:49:02.712Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codebam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-06-27T09:27:39.000Z","updated_at":"2025-06-29T04:48:34.000Z","dependencies_parsed_at":"2025-06-30T17:45:17.499Z","dependency_job_id":null,"html_url":"https://github.com/codebam/tokio-chat-server","commit_stats":null,"previous_names":["codebam/tokio-chat-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codebam/tokio-chat-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebam%2Ftokio-chat-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebam%2Ftokio-chat-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebam%2Ftokio-chat-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebam%2Ftokio-chat-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebam","download_url":"https://codeload.github.com/codebam/tokio-chat-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebam%2Ftokio-chat-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004707,"owners_count":26083750,"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-10T02:00:06.843Z","response_time":62,"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":[],"created_at":"2025-10-10T16:29:41.533Z","updated_at":"2025-10-10T16:29:45.573Z","avatar_url":"https://github.com/codebam.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tokio-chat-server\n\nA high-performance WebSocket chat server built with Tokio, supporting both plain HTTP and secure TLS/WSS connections.\n\n## Features\n\n- **High Performance**: 19k-68k+ messages/second throughput\n- **Fan-out Efficiency**: 80-100% message delivery success rate\n- **Low Latency**: Sub-millisecond batching with smart flush strategies  \n- **Massive Scalability**: Successfully tested up to 100 concurrent connections with high fan-out\n- **TLS/WSS Support**: Secure WebSocket connections with native-tls\n- **Redis Integration**: Horizontal scaling with Redis pub/sub for distributed deployments\n- **Dual Protocol**: Supports both `ws://` and `wss://` connections\n- **Client Metrics**: Real-time tracking of message counts and activity\n\n## Performance Benchmarks\n\n**Latest Test Results on 16-core system:**\n\n### HTTP WebSocket Performance (ws://)\n| Test Scenario | Throughput | Delivery Rate | Details |\n|---------------|------------|---------------|---------|\n| Multicore High Throughput | **42,370 msg/sec** | 80.1% | 50 clients, 50k messages, 946ms |\n| 1-to-100 Fan-out | **43,718 msg/sec** | 100x fan-out | 500 msgs → 50k deliveries, 1.14s |\n| Burst Fan-out | **54,982 msg/sec** | 75x fan-out | 1k msgs → 75k deliveries, 1.36s |  \n| Complex Multi-sender | **4,419 msg/sec** | 44.5x fan-out | 10 senders → 50 receivers, 20.1s |\n\n### TLS WebSocket Performance (wss://)\n| Test Scenario | Throughput | Delivery Rate | Details |\n|---------------|------------|---------------|---------|\n| Simple Throughput (TLS) | **40,074 msg/sec** | 80.0% | 10k messages, 200ms |\n| WebSocket High Throughput (TLS) | **68,288 msg/sec** | 99x fan-out | 10k msgs → 990k deliveries, 14.5s |\n\n### Redis-Backed Performance (wss:// + Redis Pub/Sub)\n| Test Scenario | Throughput | Delivery Rate | Details |\n|---------------|------------|---------------|---------|\n| Redis High Throughput (TLS) | **19,042 msg/sec** | 49x fan-out | 5k msgs → 245k deliveries, 12.9s |\n\n**Performance Summary:**\n- **Peak HTTP Throughput**: 54,982 messages/second\n- **Peak TLS Throughput**: 68,288 messages/second  \n- **Redis-Backed Throughput**: 19,042 messages/second\n- **TLS Massive Fan-out**: 99x message amplification with 100 clients\n- **Redis Fan-out**: 49x message amplification with 50 clients\n- **Fan-out Multiplier**: Up to 100x message amplification\n- **Burst Send Rate**: 93,643 messages/second\n- **Connection Scaling**: 100 concurrent TLS connections tested successfully\n\n## Quick Start\n\n### Basic HTTP Server\n```rust\nuse chat_server::run_chat_server;\nuse tokio::net::TcpListener;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let listener = TcpListener::bind(\"127.0.0.1:8080\").await?;\n    println!(\"Chat server running on ws://127.0.0.1:8080\");\n    run_chat_server(listener).await;\n    Ok(())\n}\n```\n\n### TLS/WSS Server\n```rust\nuse chat_server::{run_chat_server_tls, create_test_tls_acceptor};\nuse tokio::net::TcpListener;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let listener = TcpListener::bind(\"127.0.0.1:8443\").await?;\n    let tls_acceptor = create_test_tls_acceptor()?;\n    println!(\"Secure chat server running on wss://127.0.0.1:8443\");\n    run_chat_server_tls(listener, tls_acceptor).await;\n    Ok(())\n}\n```\n\n### Redis-Backed Server\n```rust\nuse chat_server::{run_chat_server_tls_redis, create_test_tls_acceptor};\nuse tokio::net::TcpListener;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let listener = TcpListener::bind(\"127.0.0.1:8443\").await?;\n    let tls_acceptor = create_test_tls_acceptor()?;\n    println!(\"Redis-backed chat server running on wss://127.0.0.1:8443\");\n    run_chat_server_tls_redis(listener, tls_acceptor, \"redis://127.0.0.1:6379\").await;\n    Ok(())\n}\n```\n\n## Testing\n\nRun all tests including TLS functionality:\n```bash\ncargo test\n```\n\n**Test Results: 16/16 tests passing**\n- 8 core functionality tests (including 2 TLS tests)\n- 3 fan-out performance tests  \n- 2 multicore performance tests\n- 1 simple throughput test\n- 2 WebSocket performance tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebam%2Ftokio-chat-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebam%2Ftokio-chat-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebam%2Ftokio-chat-server/lists"}