#### 服务器
- CentOS Linux release 7.6
- Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
- 2g内存 2g带宽
#### 语言及框架版本
- go v1.13.3 gin.v1
- node v12.10.0 adonis v4.1
- php v7.1.29 laravel5.6
测试工具为autocannon
业务代码分为输出json和输出模板
go-gin
```
router.LoadHTMLGlob("views/*")
router.GET("/json", func(c *gin.Context) {
list := [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
c.JSON(http.StatusOK, gin.H{"message": "OK", "statusCode": 100, "data": gin.H{"list": list}})
})
router.GET("/tpl", func(c *gin.Context) {
_, err := template.ParseFiles("views/layout.html", "views/content.html")
if err != nil {
log.Fatal(err)
}
c.HTML(http.StatusOK, "layout.html", nil)
})
```
/json
![gin-json.png](https://static.studygolang.com/191123/076045afe39dd6c574435e532a1057d8.png)
/tpl
![gin-tpl.png](https://static.studygolang.com/191123/81fccabc7b238bdc1b2949f6001d191d.png)
adonis
```
Route.get('/tpl' ,({ view }) => {
return view.render('content')
})
Route.get('/json', () =>{
var list=[1,2,3,4,5,6,7,8,9,10]
return {'message' : 'OK',
'statusCode': 100,
'data' : {'list':list}}
})
```
/json
![adonis-json.png](https://static.studygolang.com/191123/ddbf81816c42fca0607bd015a42a836b.png)
/tpl
![anonis-tpl.png](https://static.studygolang.com/191123/e9b5531d11590efd3557dd421e4451d2.png)
laravel5.6 + nginx1.13
```
Route::get('/tpl', function () {
return view('content');
}
);
Route::get('/json', function () {
$list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
return response() -> json(['message' => 'OK',
'statusCode' => 100,
'data' => ['list' => $list]]
);
}
);
```
/api/json
![nginx-php71-json.png](https://static.studygolang.com/191123/de38bd0828307c6efd6dd3a8f5edf305.png)
/tpl
![nginx-php71-tpl.png](https://static.studygolang.com/191123/2d338485dc3d612b0423582d7cd40018.png)
用 php artisan serve启动
![artisan-php71.png](https://static.studygolang.com/191123/ba13884f22297dba2a4d9ad44bb70b26.png)
### 综合比较
![bench.png](https://static.studygolang.com/191123/17ad8892cd6ee936cc6c03cca53812d5.png)
有疑问加站长微信联系(非本文作者)