• Stars
    star
    1,915
  • Rank 23,224 (Top 0.5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚡ Go web framework benchmark

go-web-framework-benchmark

This benchmark suite aims to compare the performance of Go web frameworks. It is inspired by Go HTTP Router 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.

Last Test Updated: 2020-05

test environment

  • CPU: KVM Virtual CPU version(2 GHz, 4 cores)
  • Memory: 16G
  • Go: go1.18.5 linux/amd64
  • OS: Ubuntu 22.04.1 LTS with Kernel 5.15.0-41-generic

Tested web frameworks (in alphabetical order)

Only test those webframeworks which are stable

some libs have not been maintained and the test code has removed them

Motivation

When I investigated performance of Go web frameworks, I found Go HTTP Router Benchmark, created by Julien Schmidt. He also developed a high performance http router: httprouter. I had thought I got the performance result until I created a piece of codes to mock the real business logics:

api.Get("/rest/hello", func(c *XXXXX.Context) {
	sleepTime := strconv.Atoi(os.Args[1]) //10ms
	if sleepTime > 0 {
		time.Sleep(time.Duration(sleepTime) * time.Millisecond)
	}

	c.Text("Hello world")
})

When 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.

So 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.

The you can get some interesting results if you use it to test.

Implementation

When 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".

When this server processes this url, it will sleep n milliseconds in this handler. It mocks the business logics such as:

  • read data from sockets
  • write data to disk
  • access databases
  • access cache servers
  • invoke other microservices
  • ……

It contains a test.sh that can do those tests automatically.

It uses wrk to test.

Basic Test

The first test case is to mock 0 ms, 10 ms, 100 ms, 500 ms processing time in handlers.

Benchmark (Round 3) the concurrency clients are 5000.

Latency (Round 3) Latency is the time of real processing time by web servers. The smaller is the better.

Allocs (Round 3) Allocs is the heap allocations by web servers when test is running. The unit is MB. The smaller is the better.

If we enable http pipelining, test result as below:

benchmark pipelining (Round 2)

Concurrency Test

In 30 ms processing time, the test result for 100, 1000, 5000 clients is:

concurrency (Round 3)

Latency (Round 3)

Latency (Round 3)

If we enable http pipelining, test result as below:

concurrency pipelining(Round 2)

cpu-bound case Test

cpu-bound (5000 concurrency)

Usage

You should install this package first if you want to run this test.

go get github.com/smallnest/go-web-framework-benchmark

It takes a while to install a large number of dependencies that need to be downloaded. Once that command completes, you can run:

cd $GOPATH/src/github.com/smallnest/go-web-framework-benchmark
go build -o gowebbenchmark .
./test.sh

It will generate test results in processtime.csv and concurrency.csv. You can modify test.sh to execute your customized test cases.

  • If you also want to generate latency data and allocation data, you can run the script:
./test-latency.sh
  • If you don't want use keepalive, you can run:
./test-latency-nonkeepalive.sh
  • If you want to test http pipelining, you can run:
./test-pipelining.sh
  • If you want to test some of web frameworks, you can modify the test script and only keep your selected web frameworks:
……
web_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")
……
  • If you want to test all cases, you can run:
./test-all.sh

NOTE: comparing 2 webframeworks consumes approx. 11-13 minutes (doesn't depend on the machine). Just test.sh with all the webframeworks enabled will take a couple of hours to run.

Plot

All the graphs are generated automatically as the ./test.sh finishes. However, if the run was interrupted, you can generate them manually of partial data by executing plot.sh in testresults directory.

Add new web framework

Welcome to add new Go web frameworks. You can follow the below steps and send me a pull request.

  1. add your web framework link in README
  2. add a hello implementation in server.go
  3. add your webframework in libs.sh

Please add your web framework alphabetically.

More Repositories

1

rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
Go
7,712
star
2

1m-go-tcp-server

benchmarks for implementation of servers which support 1 million connections
Go
1,840
star
3

dive-to-gosync-workshop

深入Go并发编程研讨课
Go
1,604
star
4

C1000K-Servers

⚡ High performance websocket servers implemented by Spray-can, Netty, undertow, jetty, Vert.x, Grizzly, node.js and Go. It supports 1,200,000 active websocket connections
Scala
1,506
star
5

gen

Converts a database into gorm structs and RESTful api
Go
1,411
star
6

concurrency-programming-via-rust

Rust
1,261
star
7

chanx

unbounded chan
Go
412
star
8

gosercomp

⚡ Golang Serializer Benchmark Comparison
Go
403
star
9

ringbuffer

a thread-safe circular buffer (ring buffer) in Go, implemented io.ReaderWriter interface
Go
357
star
10

gofsm

a featured FSM that can export state images
Go
297
star
11

go-best-practices

resources for go best practices
283
star
12

douban-recommender

基于Spark ML实现的豆瓣电影推荐系统
Scala
224
star
13

rpcx-ui

rpcx manager web ui
Go
215
star
14

Jax-RS-Performance-Comparison

⚡ Performance Comparison of Jax-RS implementations and embedded containers
Java
187
star
15

weighted

high-performance common weighted algorithm library
Go
185
star
16

ZKRecipesByExample

all examples for ZooKeeper recipes by Curator
Java
183
star
17

goframe

send/receive framed data via TCP or QUIC
Go
167
star
18

go-concurrent-quiz

Go concurrency quizzes
Go
166
star
19

kafka-example-in-scala

a kafka producer and consumer example in scala and java
Java
152
star
20

rpcx-programming-guide-cn

gitbook Go RPC开发指南 [中文文档]
CSS
142
star
21

glean

hotfix for go applications via plugin, supports Linux and MacOS
Go
130
star
22

queue

lock-free queue and other implementations
Go
123
star
23

rpcx-rs

rpcx microservice framework in Rust
Rust
119
star
24

goreq

A Simplified Golang Http Client
Go
104
star
25

go_test_workshop

Go Test Workshop
HTML
100
star
26

gofer

Go
94
star
27

channels

go channel patterns
Go
89
star
28

resp3

First redis RESP3 protocol library in Go
Go
84
star
29

rpcx-java

rpcx implementation in Java for server side and client side
Java
79
star
30

smallchat

A minimal programming example for a chat server in Go and Rust
Rust
77
star
31

epoller

epoll implementation for connections in Linux, MacOS and Windows
C
75
star
32

grpc-examples

examples for gRPC
Go
63
star
33

distributed

distributed synchronization primitives
Go
60
star
34

FlyRunner

一个记录你地图路线的跑步软件,无需google map支持
Java
44
star
35

rpcxdump

a tcpdump-like tool to capture rpcx tcp packets
Go
43
star
36

zhuge

救命用的profile
Go
41
star
37

exp

Experimental packages not in std and golang.org/exp
Go
41
star
38

hash-bench

go hash benchmark
Go
38
star
39

mping

a multi-targets ping tool, which supports 10,000 packets/second, accurate latency
Go
38
star
40

spring-kafka-demo

Java
37
star
41

Tractor

A Tractor game. (升级,一个在中国非常流行的扑克牌游戏。又叫拖拉机,双扣)。 Developed by C#
C#
37
star
42

leetcode-solutions

leetcode 算法题解精选
37
star
43

network_benchmark

3百万QPS benchmark测试
Go
35
star
44

mahout-douban-recommender

基于mahout实现的豆瓣电影推荐系统
Java
33
star
45

mping-rs

a multi-targets ping tool and library, which supports 10,000 packets/second, accurate latency
Rust
31
star
46

RPC-TEST

test performance of gRPC and Thrift. All services are implemented as HelloWorld by Java, Scala and Golang
Shell
30
star
47

breakdown

记录国内外互联网公司和电信企业P0级别的重大故障
27
star
48

quick

an encrypted UDP connection between two peers using QUIC
Go
26
star
49

talk-about-go-generics

谈谈Go泛型 - GopherChina 2023 大会分享
Go
24
star
50

gitalk

gitalk for colobu
19
star
51

fastjson-jaxrs-json-provider

a JAX-RS entity provider for https://github.com/alibaba/fastjson
Java
18
star
52

redis-bench

a different redis bench tool that is used for test latency at given max throughputs
Go
16
star
53

rpcxlite

a lite version of rpcx
Go
16
star
54

iprange

check whether a IP is in IP ranges with CIDR format such as 216.249.16.0/20 and 2a01:5a80::/32
Go
16
star
55

smallnest.github.io

HTML
16
star
56

leetcode

有空就刷题
Go
14
star
57

syncx

more advanced sync primitives in Go
Go
14
star
58

kafka_monitor

A kafka monitor to send alarm emails
Go
14
star
59

rediscopy

copy redis requests to other servers
Go
14
star
60

weighted-rs

A Rust library for weighted balancing algorithm
Rust
12
star
61

gomemcached

memcached protocol implementation for memcached server
Go
12
star
62

rpcx-agent

Agent to invoke rpcx services in C++, Java, Python, C#, Ruby, etc. for rpcx 2.x
Go
10
star
63

gofu

functional go with generic types
10
star
64

libra-wallet

a libra wallet example in go
HTML
9
star
65

qianmo

additional network functions
Go
9
star
66

rust-examples

study rust by examples
Rust
9
star
67

rpcx-programming-guide-en

rpcx programming guide (english version)
9
star
68

Ember-Lance

Dashboard Bootstrap implemented with sb-admin2, Ember, D3.js and other third-party libraries
JavaScript
9
star
69

concurrency-programming-via-go-code

code of concurrency programming via go
Go
9
star
70

DisruptorBootstrap

Example for Disruptor and Spring Reactor
Java
8
star
71

nettrace

explore internal/nettrace in go std lib
Go
8
star
72

go-app-metrics

add system monitor (cpu/load/memory/disk/bandwidth) to go-metrics
Go
7
star
73

blockchain

a general blockchain implementation
Go
7
star
74

go-cheatsheets

7
star
75

go-generics-examples

go generics examples
Assembly
7
star
76

pool

a go pool that you don't worry about GC
Go
5
star
77

libp2p

a secure go p2p libary, easy to use. cloned from go-spacemesh
Go
5
star
78

libkv-etcdv3-store

libkv etcd store by client v3 API: https://github.com/docker/libkv
Go
5
star
79

preallocate

File preallocation library, cloned from https://git.sr.ht/~tslocum/preallocate
Go
5
star
80

benchpi

rust examples for calculating PI
Rust
4
star
81

json-parser-benchmark

json parser benchmark
Go
4
star
82

Java-Memcached-Clients-Benchmark

⚡ Benchmark for Java Memcached clients such as SpyMemcached, XMemcached and folsom
Scala
4
star
83

p2p

p2p examples
Go
4
star
84

word

一个命令行中查找英语单词的意思和发音
Go
4
star
85

tracert

a special traceroute lib for multiple paths by UDP
Go
4
star
86

kafka-go-examples

examples for kafka go clients
Go
3
star
87

golang-tls

golang tls for http/http2 examples
Go
3
star
88

awesome-web-templates

record free web templates
3
star
89

concurrency-programming-via-go

Go并发编程勘误页和问题反馈
2
star
90

Scala-Collections-Cookbook

codes for the book "Scala Collections Cookbook"
Scala
2
star
91

libra-wallet-rust

libra wallet in rust
CSS
2
star
92

batch

batch process or timeout
Go
2
star
93

bitcoin

bitcoin study
Go
2
star
94

shorturl

a scalable high performance ShortURL server
Scala
2
star
95

go-database-study

study golang database lib
Go
2
star
96

ai_assistant

熊厂内分享,github copilot vs baidu comate
Go
1
star
97

traceto

traceroute with Geographic information
Go
1
star
98

SpringMongoExample

Java
1
star
99

jsonrpc-demo

implemented in Go, call from C via CGO
C
1
star
100

f

Go functional lib with Generic
1
star