{"id":13461577,"url":"https://github.com/smallnest/1m-go-tcp-server","last_synced_at":"2025-10-07T19:24:41.069Z","repository":{"id":37663724,"uuid":"170834782","full_name":"smallnest/1m-go-tcp-server","owner":"smallnest","description":"benchmarks for implementation of servers which support 1 million connections ","archived":false,"fork":false,"pushed_at":"2021-04-15T14:32:27.000Z","size":45,"stargazers_count":1915,"open_issues_count":4,"forks_count":355,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-05-15T22:03:21.205Z","etag":null,"topics":["benchmark","epoll","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/smallnest.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}},"created_at":"2019-02-15T09:07:15.000Z","updated_at":"2025-05-13T15:07:56.000Z","dependencies_parsed_at":"2022-07-12T16:42:34.207Z","dependency_job_id":null,"html_url":"https://github.com/smallnest/1m-go-tcp-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2F1m-go-tcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2F1m-go-tcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2F1m-go-tcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2F1m-go-tcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallnest","download_url":"https://codeload.github.com/smallnest/1m-go-tcp-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430326,"owners_count":22069907,"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","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","epoll","go","golang"],"created_at":"2024-07-31T11:00:45.187Z","updated_at":"2025-10-07T19:24:36.023Z","avatar_url":"https://github.com/smallnest.png","language":"Go","funding_links":[],"categories":["Go","Repositories","golang"],"sub_categories":[],"readme":"# Benchmark for implementation of servers that support 1m connections\n\ninspired by [handling 1M websockets connections in Go ](https://github.com/eranyanay/1m-go-websockets)\n\n## Servers\n\n1. **1_simple_tcp_server**： a 1m-connections server implemented based on `goroutines per connection`\n2. **2_epoll_server**: a 1m-connections server implemented based on `epoll`\n3. **3_epoll_server_throughputs**: \tadd throughputs and latency test for 2_epoll_server\n4. **4_epoll_client**: \timplement the client based on `epoll`\n5. **5_multiple_client**: \tuse `multiple epoll` to manage connections in client\n6. **6_multiple_server**:  \tuse `multiple epoll` to manage connections in server\n7. **7_server_prefork**: \tuse `prefork` style of apache to implement server\n8. **8_server_workerpool**: use `Reactor` pattern to implement multiple event loops\n9. **9_few_clients_high_throughputs**: a simple `goroutines per connection` server for test throughtputs and latency\n10. **10_io_intensive_epoll_server**: an io-bound `multiple epoll`  server\n11. **11_io_intensive_goroutine**:  an io-bound `goroutines per connection` server\n12. **12_cpu_intensive_epoll_server**: a cpu-bound `multiple epoll`  server\n13. **13_cpu_intensive_goroutine**:  an cpu-bound `goroutines per connection` server\n\t\n## Test Environment\n\n- two `E5-2630 V4` cpus, total **20** cores, **40** logicial cores.\n- 32G memory \n\ntune the linux:\n\n```sh\nsysctl -w fs.file-max=2000500\nsysctl -w fs.nr_open=2000500\nsysctl -w net.nf_conntrack_max=2000500\nulimit -n 2000500\n\nsysctl -w net.ipv4.tcp_tw_recycle=1\nsysctl -w net.ipv4.tcp_tw_reuse=1\n```\n\nclient sends the next request only when it has received the response. it has not used the `pipeline` style to test.\n## Benchmarks\n\n### 1m connections\n\n| | throughputs (tps) | latency |\n|--|--|--|\n|goroutine-per-conn|202830|4.9s|\n|single epoll(both server and client)| 42495 | 23s|\n|single epoll server| 42402 | 0.8s|\n|multiple epoll server| 197814 | 0.9s|\n|prefork| 444415 | 1.5s|\n|workerpool| 190022 | 0.3s|\n\n\n**中文介绍**:\n\n1. [百万 Go TCP 连接的思考: epoll方式减少资源占用](https://colobu.com/2019/02/23/1m-go-tcp-connection/)\n2. [百万 Go TCP 连接的思考2: 百万连接的服务器的性能](https://colobu.com/2019/02/27/1m-go-tcp-connection-2/)\n3. [百万 Go TCP 连接的思考3: 低连接场景下的服务器的吞吐和延迟](https://colobu.com/2019/02/28/1m-go-tcp-connection-3/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2F1m-go-tcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallnest%2F1m-go-tcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2F1m-go-tcp-server/lists"}