{"id":13671170,"url":"https://github.com/axetroy/concurrency-benchmarks","last_synced_at":"2025-04-09T11:15:01.260Z","repository":{"id":145997396,"uuid":"185166990","full_name":"axetroy/concurrency-benchmarks","owner":"axetroy","description":"Golang/Nodejs/Deno/Python/PHP的原生 HTTP 高并发测试","archived":false,"fork":false,"pushed_at":"2019-05-08T02:59:34.000Z","size":130,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T05:16:03.569Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/axetroy.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}},"created_at":"2019-05-06T09:36:06.000Z","updated_at":"2019-05-10T01:06:59.000Z","dependencies_parsed_at":"2024-01-14T16:56:22.485Z","dependency_job_id":null,"html_url":"https://github.com/axetroy/concurrency-benchmarks","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/axetroy%2Fconcurrency-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axetroy%2Fconcurrency-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axetroy%2Fconcurrency-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axetroy%2Fconcurrency-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axetroy","download_url":"https://codeload.github.com/axetroy/concurrency-benchmarks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027412,"owners_count":21035594,"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":[],"created_at":"2024-08-02T09:01:01.653Z","updated_at":"2025-04-09T11:15:01.201Z","avatar_url":"https://github.com/axetroy.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"### TL; DR\n\n\u003e 各语言原生 HTTP 高并发测试性能\n\u003e 尽量排除其他因素的影响，例如各语言文件读写能力\n\n结论: Golang \u003e Deno \u003e Nodejs \u003e Python(异步IO) \u003e Dart(异步IO) \u003e PHP\n\n### 不同语言实现的高并发测试\n\n测试参数:\n\n1. 持续请求 10 秒\n2. 并发量 100\n\n服务的的操作:\n\n1. 返回一个 `test_file.js` 文件的内容\n\n测试脚本\n```bash\n\u003e siege -c 100 -t 10s http://127.0.0.1:3000/\n```\n\n测试语言\n\n- [Nodejs](#nodejs)\n- [Deno](#deno)\n- [Golang](#golang)\n- [Python](#python)\n- [PHP](#php)\n- [Dart](#dart)\n\n### 测试机器\n\n操作系统: macOS Mojave 10.14.4\n\n处理器: 1.8 GHz Intel Core i5\n\n内存: 8 GB 1600 MHz DDR3\n\n测试工具: apache bench\n\n#### NodeJs\n\n1. Without cluster\n\n```bash\n\u003e node -v\nv10.15.3\n\u003e node nodejs/index.js\n\u003e bash run.sh\n\nTransactions:\t\t        9049 hits\nAvailability:\t\t      100.00 %\nElapsed time:\t\t        9.16 secs\nData transferred:\t     2639.57 MB\nResponse time:\t\t        0.10 secs\nTransaction rate:\t      987.88 trans/sec\nThroughput:\t\t      288.16 MB/sec\nConcurrency:\t\t       98.60\nSuccessful transactions:        9049\nFailed transactions:\t           0\nLongest transaction:\t        0.37\nShortest transaction:\t        0.00\n```\n\n2. With cluster\n\n```bash\n\u003e node -v\nv10.15.3\n\u003e node nodejs/cluster.js\n\u003e bash run.sh\n\nTransactions:\t\t        8431 hits\nAvailability:\t\t      100.00 %\nElapsed time:\t\t        9.12 secs\nData transferred:\t     2459.30 MB\nResponse time:\t\t        0.10 secs\nTransaction rate:\t      924.45 trans/sec\nThroughput:\t\t      269.66 MB/sec\nConcurrency:\t\t       95.72\nSuccessful transactions:        8431\nFailed transactions:\t           0\nLongest transaction:\t        0.35\nShortest transaction:\t        0.00\n```\n\n### Deno\n\n```bash\n\u003e deno version\ndeno: 0.4.0\nv8: 7.6.53\ntypescript: 3.4.1\n\u003e deno run --allow-all deno/index.ts\n\u003e bash run.sh\n\nTransactions:\t\t        9213 hits\nAvailability:\t\t      100.00 %\nElapsed time:\t\t        9.74 secs\nData transferred:\t     2687.41 MB\nResponse time:\t\t        0.10 secs\nTransaction rate:\t      945.89 trans/sec\nThroughput:\t\t      275.91 MB/sec\nConcurrency:\t\t       98.99\nSuccessful transactions:        9213\nFailed transactions:\t           0\nLongest transaction:\t        0.30\nShortest transaction:\t        0.06\n```\n\n### Golang\n\n```bash\n\u003e go version\ngo version go1.11.2 darwin/amd64\n\u003e go run go/main.go\n\u003e bash run.sh\n\nTransactions:\t\t       11523 hits\nAvailability:\t\t      100.00 %\nElapsed time:\t\t        9.71 secs\nData transferred:\t     3386.32 MB\nResponse time:\t\t        0.05 secs\nTransaction rate:\t     1186.71 trans/sec\nThroughput:\t\t      348.75 MB/sec\nConcurrency:\t\t       61.55\nSuccessful transactions:       11609\nFailed transactions:\t           0\nLongest transaction:\t        0.38\nShortest transaction:\t        0.00\n```\n\n### Python\n\n```bash\n\u003e python3 --version\nPython 3.7.3\n\u003e python3 python3/index.py\n\u003e bash run.sh\n\nTransactions:\t\t        5532 hits\nAvailability:\t\t       84.37 %\nElapsed time:\t\t        9.54 secs\nData transferred:\t        0.07 MB\nResponse time:\t\t        0.10 secs\nTransaction rate:\t      579.87 trans/sec\nThroughput:\t\t        0.01 MB/sec\nConcurrency:\t\t       56.57\nSuccessful transactions:        5532\nFailed transactions:\t        1025\nLongest transaction:\t        7.58\nShortest transaction:\t        0.00\n```\n\n### PHP\n\n```bash\n\u003e php -S 0.0.0.0:3000 php/index.php\nPHP 7.1.23 Development Server started at Tue May  7 10:55:42 2019\nListening on http://0.0.0.0:10000\nDocument root is /Users/axetroy/gpm/github.com/axetroy/concurrency-benchmarks\nPress Ctrl-C to quit.\n\u003e bash run.sh\n\nTransactions:\t\t          48 hits\nAvailability:\t\t      100.00 %\nElapsed time:\t\t        9.83 secs\nData transferred:\t        0.00 MB\nResponse time:\t\t        5.03 secs\nTransaction rate:\t        4.88 trans/sec\nThroughput:\t\t        0.00 MB/sec\nConcurrency:\t\t       24.55\nSuccessful transactions:          48\nFailed transactions:\t           0\nLongest transaction:\t        9.81\nShortest transaction:\t        0.24\n```\n\n### Dart\n\n```bash\n\u003e dart --version\nDart VM version: 2.1.0 (Tue Nov 13 18:22:02 2018 +0100) on \"macos_x64\"\n\u003e dart dart/main.dart\n\u003e bash run.sh\n\nTransactions:\t\t        1847 hits\nAvailability:\t\t      100.00 %\nElapsed time:\t\t        9.13 secs\nData transferred:\t      538.77 MB\nResponse time:\t\t        0.47 secs\nTransaction rate:\t      202.30 trans/sec\nThroughput:\t\t       59.01 MB/sec\nConcurrency:\t\t       94.18\nSuccessful transactions:        1847\nFailed transactions:\t           0\nLongest transaction:\t        1.04\nShortest transaction:\t        0.06\n```\n\n### 声明\n\n这个测试并不是标准的基准测试，也不是都很熟悉这些语言。\n\n而且是在服务的和客户端在同一台机器，有竞争状态不是很准确。\n\n如有错误，欢迎指出。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxetroy%2Fconcurrency-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxetroy%2Fconcurrency-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxetroy%2Fconcurrency-benchmarks/lists"}