Skip to content

Commit 2c2d802

Browse files
authored
Merge pull request #3 from sam-ke/master
readme
2 parents ae81d17 + 598718e commit 2c2d802

File tree

5 files changed

+64
-37
lines changed

5 files changed

+64
-37
lines changed

README.md

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,59 @@ $ git clone git@github.com:tal-tech/gaea.git
1717
```
1818

1919
### Build & Run
20+
The following is a simple example, detailed [Documentation](https://github.com/tal-tech/gaea-doc/blob/master/SUMMARY.md)
2021

2122
```golang
2223
//Will use makefile to compile and generate binary files to the bin directory
23-
$ make
24-
```
24+
$ cd gaea
25+
$ make
26+
$ ./bin/gaea
27+
2020/08/26 14:40:02 CONF INIT,path:../conf/conf.ini
28+
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
29+
- using env: export GIN_MODE=release
30+
- using code: gin.SetMode(gin.ReleaseMode)
2531

26-
## Example
27-
1.Config server port
28-
```golang
29-
//conf/conf.ini
30-
[HTTP]
31-
port = 9898
32-
;...
33-
```
32+
[GIN-debug] GET /demo/test --> gaea/app/controller/democontroller.GaeaDemo (1 handlers)
33+
2020/08/26 14:40:02 [overseer master] run
34+
2020/08/26 14:40:02 [overseer master] starting /mnt/d/codes/go/src/gaea/bin/gaea
35+
2020/08/26 14:40:02 CONF INIT,path:../conf/conf.ini
36+
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
37+
- using env: export GIN_MODE=release
38+
- using code: gin.SetMode(gin.ReleaseMode)
3439

35-
2.Add router
36-
```golang
37-
//app/router/router.go is the file that manage all URI
38-
func RegisterRouter(router *gin.Engine) {
39-
entry := router.Group("/demo", middleware.PerfMiddleware(), middleware.XesLoggerMiddleware())
40-
entry.GET("/test", democontroller.GaeaDemo)
41-
}
42-
```
40+
[GIN-debug] GET /demo/test --> gaea/app/controller/democontroller.GaeaDemo (1 handlers)
41+
2020/08/26 14:40:02 [overseer slave#1] run
42+
2020/08/26 14:40:02 [overseer slave#1] start program
43+
2020/08/26 14:40:09 [overseer master] proxy signal (window changed)
4344

44-
4.Controller (mvc programming style)
45-
```golang
46-
//app/router/
47-
func GaeaDemo(ctx *gin.Context) {
48-
goCtx := xesgin.TransferToContext(ctx)
49-
param := ctx.PostForm("param")
50-
ret, err := demoservice.DoFun(goCtx, param)
51-
if err != nil {
52-
resp := xesgin.Error(err)
53-
ctx.JSON(http.StatusOK, resp)
54-
} else {
55-
resp := xesgin.Success(ret)
56-
ctx.JSON(http.StatusOK, resp)
57-
}
58-
}
5945
```
6046

61-
5.Try it!
62-
```
63-
curl http://127.0.0.1:9898/demo/test
64-
```
47+
## Comparison of routing performance of major mainstream frameworks
48+
49+
![pic](doc/images/jianjie_xingneng.png)
50+
51+
(Picture to Resource Network)
52+
53+
#### Gaea Benchmark
54+
Compared with the native Gin, the point that the Gaea framework affects performance is actually all concentrated on the middleware, because every http request will be run again, so observe the impact on the overall performance when each middle is turned on
55+
##### Environment
56+
57+
| Metrics | Remarks |
58+
| ---- | ---- |
59+
| SyesTem | vm centos7 |
60+
| Mem| 1GB |
61+
|CPU| 1|
62+
|Request number| 100000|
63+
|Concurrent number |100|
64+
|Data|{"code":0,"data":"hell world","msg":"ok","stat":1}|
65+
66+
67+
![pic](doc/images/perf.png)
68+
69+
We can clearly see from the figure:
70+
* Gaea's default configuration will bring a certain amount of energy consumption, about 30%
71+
* Among them, the `Logger` middleware has the largest impact on the performance of each middleware, and other middleware is almost negligible
72+
73+
*Note: The middleware in the test is used for testing and not open source*
74+
75+
In actual project applications, when [Log](https://github.com/tal-tech/loggerX) middleware is the bottleneck, we can close it or adjust the log level to `WARNING`

doc/images/g3.jpg

47.2 KB
Loading

doc/images/jianjie_xingneng.png

16.4 KB
Loading

doc/images/perf.png

12.4 KB
Loading

go.mod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
module gaea
22

33
go 1.12
4+
5+
require (
6+
github.com/Unknwon/goconfig v0.0.0-20191126170842-860a72fb44fd // indirect
7+
github.com/gin-gonic/gin v1.6.3
8+
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
9+
github.com/jpillora/overseer v1.1.6 // indirect
10+
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
11+
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
12+
github.com/sirupsen/logrus v1.6.0 // indirect
13+
github.com/smallnest/rpcx v0.0.0-20200729031544-75f1e2894fdb // indirect
14+
github.com/spf13/cast v1.3.1
15+
github.com/tal-tech/hera v0.0.0-20200807103530-dd689e514981
16+
github.com/tal-tech/loggerX v0.0.0-20200806121626-bc3db51db258
17+
github.com/tal-tech/xtools v0.0.0-20200807105038-f5e7d6202665
18+
go.uber.org/zap v1.15.0 // indirect
19+
)

0 commit comments

Comments
 (0)