{"id":13367536,"url":"https://github.com/smallnest/Go-web-framework-benchmark","last_synced_at":"2025-03-12T20:30:47.349Z","repository":{"id":6911436,"uuid":"55581236","full_name":"smallnest/go-web-framework-benchmark","owner":"smallnest","description":":zap: Go web framework benchmark","archived":false,"fork":false,"pushed_at":"2025-01-17T01:25:36.000Z","size":98357,"stargazers_count":2097,"open_issues_count":3,"forks_count":226,"subscribers_count":90,"default_branch":"master","last_synced_at":"2025-03-06T07:07:11.562Z","etag":null,"topics":["benchmark","concurrency","http-router-benchmark","mux","webframework"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","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":"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}},"created_at":"2016-04-06T06:27:33.000Z","updated_at":"2025-03-05T08:20:32.000Z","dependencies_parsed_at":"2024-01-05T21:46:11.079Z","dependency_job_id":"bdf4ebf2-10d1-4539-8eba-27af6ba95678","html_url":"https://github.com/smallnest/go-web-framework-benchmark","commit_stats":{"total_commits":224,"total_committers":45,"mean_commits":4.977777777777778,"dds":0.5178571428571428,"last_synced_commit":"b07cebd150aa2458ba2df1726a284ea4fd36fad4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgo-web-framework-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgo-web-framework-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgo-web-framework-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fgo-web-framework-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallnest","download_url":"https://codeload.github.com/smallnest/go-web-framework-benchmark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243290606,"owners_count":20267749,"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","concurrency","http-router-benchmark","mux","webframework"],"created_at":"2024-07-30T00:01:52.889Z","updated_at":"2025-03-12T20:30:47.343Z","avatar_url":"https://github.com/smallnest.png","language":"Go","readme":"# go-web-framework-benchmark\nThis benchmark suite aims to compare the performance of Go web frameworks. It is inspired by [Go HTTP Router Benchmark](https://github.com/julienschmidt/go-http-routing-benchmark) but this benchmark suite is different with that. Go HTTP Router Benchmark suit aims to compare the performance of **routers** but this Benchmark suit aims to compare whole HTTP request processing.\n\n**Last Test Updated:** 2020-05\n\n*test environment*\n\n* CPU:      KVM Virtual CPU version(2 GHz, 4 cores)\n* Memory:   16G\n* Go:       go1.18.5 linux/amd64\n* OS:       Ubuntu 22.04.1 LTS with Kernel 5.15.0-41-generic\n\n\n## Tested web frameworks (in alphabetical order)\n\n**Only test those webframeworks which are stable**\n\n* [atreugo](https://github.com/savsgio/atreugo)\n* [baa](https://github.com/go-baa/baa)\n* [beego](https://github.com/astaxie/beego)\n* [bone](https://github.com/go-zoo/bone)\n* [chi](https://github.com/go-chi/chi)\n* [clevergo](https://github.com/clevergo/clevergo)\n* [default http](https://golang.org/pkg/net/http/)\n* [denco](https://github.com/naoina/denco)\n* [don](https://github.com/abemedia/go-don)\n* [echo](https://github.com/labstack/echo)\n* [fasthttp-routing](https://github.com/qiangxue/fasthttp-routing)\n* [fasthttp/router](https://github.com/fasthttp/router)\n* [fasthttp](https://github.com/valyala/fasthttp)\n* [fiber](https://gofiber.io/)\n* [gear](http://github.com/teambition/gear)\n* [gearbox](https://github.com/gogearbox/gearbox)\n* [gem](https://github.com/go-gem/gem)\n* [gin](https://github.com/gin-gonic/gin)\n* [goframe](https://github.com/gogf/gf)\n* [go-ozzo](https://github.com/go-ozzo/ozzo-routing)\n* [go-restful](https://github.com/emicklei/go-restful)\n* [go-tigertonic](https://github.com/rcrowley/go-tigertonic)\n* [goji](https://github.com/zenazn/goji/web)\n* [goji](http://goji.io)\n* [golf](https://github.com/dinever/golf)\n* [gorilla](https://github.com/gorilla/mux)\n* [gorouter](https://github.com/vardius/gorouter)\n* [goyave](https://github.com/System-Glitch/goyave)\n* [httprouter](https://github.com/julienschmidt/httprouter)\n* [httptreemux](https://github.com/dimfeld/httptreemux)\n* [httpz](https://github.com/aeilang/httpz)\n* [indigo](https://github.com/indigo-web/indigo)\n* [lars](https://github.com/go-playground/lars)\n* [lion](https://github.com/celrenheit/lion)\n* [macaron](https://github.com/Unknwon/macaron)\n* [muxie](https://github.com/kataras/muxie)\n* [negroni](https://github.com/urfave/negroni)\n* [pat](https://github.com/bmizerany/pat)\n* [pulse](https://github.com/gopulse/pulse)\n* [pure](https://github.com/go-playground/pure)\n* [r2router](https://github.com/vanng822/r2router)\n* [tango](https://github.com/lunny/tango)\n* [tinyrouter](https://github.com/go101/tinyrouter)\n* [treemux](https://github.com/vmihailenco/treemux)\n* [violetear](https://github.com/nbari/violetear)\n* [vulcan](https://github.com/mailgun/route)\n* [webgo](https://github.com/bnkamalesh/webgo)\n\n**some libs have not been maintained and the test code has removed them**\n\n## Motivation\nWhen I investigated performance of Go web frameworks, I found [Go HTTP Router Benchmark](https://github.com/julienschmidt/go-http-routing-benchmark), created by Julien Schmidt. He also developed a high performance http router: [httprouter](https://github.com/julienschmidt/httprouter). I had thought I got the performance result until I created a piece of codes to mock the real business logics:\n\n```go\napi.Get(\"/rest/hello\", func(c *XXXXX.Context) {\n\tsleepTime := strconv.Atoi(os.Args[1]) //10ms\n\tif sleepTime \u003e 0 {\n\t\ttime.Sleep(time.Duration(sleepTime) * time.Millisecond)\n\t}\n\n\tc.Text(\"Hello world\")\n})\n```\n\nWhen I use the above codes to test those web frameworks, the token time of route selection is not so important in the whole http request processing, although performance of route selection of web frameworks are very different.\n\nSo I create this project to compare performance of web frameworks including connection, route selection, handler processing. It mocks business logics and can set a special processing time.\n\nThen you can get some interesting results if you use it to test.\n\n## Implementation\nWhen you test a web framework, this test suit will starts a simple http server implemented by this web framework. It is a real http server and only contains GET url: \"/hello\".\n\nWhen this server processes this url, it will sleep n milliseconds in this handler. It mocks the business logics such as:\n* read data from sockets\n* write data to disk\n* access databases\n* access cache servers\n* invoke other microservices\n* ……\n\nIt contains a test.sh that can do those tests automatically.\n\nIt uses [wrk](https://github.com/wg/wrk/) to test.\n\n## Basic Test\nThe first test case is to mock 0 ms, 10 ms, 100 ms, 500 ms processing time in handlers.\n\n![Benchmark (Round 3)](benchmark.png)\nthe concurrency clients are 5000.\n\n![Latency (Round 3)](benchmark_latency.png)\nLatency is the time of real processing time by web servers. The smaller is the better.\n\n![Allocs (Round 3)](benchmark_alloc.png)\nAllocs is the heap allocations by web servers when test is running. The unit is MB. The smaller is the better.\n\n\nIf we enable http pipelining, test result as below:\n\n![benchmark pipelining (Round 2)](benchmark-pipeline.png)\n\n## Concurrency Test\nIn 30 ms processing time, the test result for 100, 1000, 5000 clients is:\n\n![concurrency (Round 3)](concurrency.png)\n\n![Latency (Round 3)](concurrency_latency.png)\n\n![Latency (Round 3)](concurrency_alloc.png)\n\n\nIf we enable http pipelining, test result as below:\n\n![concurrency pipelining(Round 2)](concurrency-pipeline.png)\n\n\n## cpu-bound case Test\n\n![cpu-bound (5000 concurrency)](cpubound_benchmark.png)\n\n## Usage\nYou should install this package first if you want to run this test.\n\n```\ngo get github.com/smallnest/go-web-framework-benchmark\n```\n\nIt takes a while to install a large number of dependencies that need to be downloaded. Once that command completes, you can run:\n\n```\ncd $GOPATH/src/github.com/smallnest/go-web-framework-benchmark\ngo build -o gowebbenchmark .\n./test.sh\n```\n\nIt will  generate test results in processtime.csv and concurrency.csv. You can modify test.sh to execute your customized test cases.\n\n\n* If you also want to generate latency data and allocation data, you can run the script:\n```\n./test-latency.sh\n```\n\n* If you don't want use keepalive, you can run:\n```\n./test-latency-nonkeepalive.sh\n```\n\n* If you want to test http pipelining, you can run:\n```\n./test-pipelining.sh\n```\n\n* If you want to test some of web frameworks, you can modify the test script and only keep your selected web frameworks:\n```\n……\nweb_frameworks=(\"default\" \"atreugo\" \"beego\" \"bone\" \"chi\" \"denco\" \"don\" \"echo\" \"fasthttp\" \"fasthttp-routing\" \"fasthttp/router\" \"fiber\" \"gear\" \"gearbox\" \"gin\" \"goframe\" \"goji\" \"gorestful\" \"gorilla\" \"gorouter\" \"gorouterfasthttp\" \"go-ozzo\" \"goyave\" \"httprouter\" \"httptreemux\" \"indigo\" \"lars\" \"lion\" \"muxie\" \"negroni\" \"pat\" \"pulse\" \"pure\" \"r2router\" \"tango\" \"tiger\" \"tinyrouter\" \"violetear\" \"vulcan\" \"webgo\")\n……\n```\n* If you want to test all cases, you can run:\n\n```\n./test-all.sh\n```\n\nNOTE: comparing 2 webframeworks consumes approx. 11-13 minutes (doesn't depend on the machine). Just `test.sh` with all\nthe webframeworks enabled will take a couple of hours to run.\n\n## Plot\nAll the graphs are generated automatically as the `./test.sh` finishes. However, if the run was interrupted, you can\ngenerate them manually of partial data by executing `plot.sh` in testresults directory.\n\n### Add new web framework\nWelcome to add new Go web frameworks. You can follow the below steps and send me a pull request.\n\n1. add your web framework link in README\n2. add a hello implementation in server.go\n3. add your webframework in libs.sh\n\nPlease add your web framework alphabetically.\n","funding_links":[],"categories":["基准测试","基準測試"],"sub_categories":["其他软件","其他軟件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2FGo-web-framework-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallnest%2FGo-web-framework-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2FGo-web-framework-benchmark/lists"}