当前位置:网站首页>go之web框架 iris
go之web框架 iris
2022-06-30 17:46:00 【IT工作者】
最近开始学习GO的WEB框架,IRIS号称是Go最快的后端Web框架,目前发展最快的Go Web框架。提供完整的MVC功能并且面向未来。
所以先从它开始。
github地址
https://github.com/kataras/iris
文档
https://docs.iris-go.com/
安装
go get -u github.com/kataras/iris
编辑main.go
package main
import "github.com/kataras/iris"
func main() {
app := iris.Default()
// Method: GET
// Resource: http://localhost:8080/
app.Handle("GET", "/", func(ctx iris.Context) {
ctx.HTML("Hello world!")
})
// same as app.Handle("GET", "/ping", [...])
// Method: GET
// Resource: http://localhost:8080/ping
app.Get("/ping", func(ctx iris.Context) {
ctx.WriteString("pong")
})
// Method: GET
// Resource: http://localhost:8080/hello
app.Get("/hello", func(ctx iris.Context) {
ctx.JSON(iris.Map{"message": "Hello iris web framework."})
})
// http://localhost:8080
// http://localhost:8080/ping
// http://localhost:8080/hello
app.Run(iris.Addr(":8080"))
}运行
go run main.go
新打开个窗口执行
curl http://localhost:8080
结果 Hello world!
或在浏览器 访问http://localhost:8080
测试
现在对它进行简单压力测试
系统配置 1核 1G内存 , 操作系统:CentOS 7.4 64位
ab -n 10000 -c 1000 http://localhost:8080/
#结果
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software:
Server Hostname: localhost
Server Port: 8080
Document Path: /
Document Length: 12 bytes
Concurrency Level: 1000
Time taken for tests: 3.102 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1280000 bytes
HTML transferred: 120000 bytes
Requests per second: 3223.45 [#/sec] (mean)
Time per request: 310.227 [ms] (mean)
Time per request: 0.310 [ms] (mean, across all concurrent requests)
Transfer rate: 402.93 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 168 383.5 2 3013
Processing: 8 138 325.4 23 2005
Waiting: 1 137 325.5 22 2002
Total: 8 306 625.5 26 3067
Percentage of the requests served within a certain time (ms)
50% 26
66% 34
75% 59
80% 90
90% 1480
95% 1748
98% 1925
99% 3014
100% 3067 (longest request)
边栏推荐
- 正则表达式(正则匹配)
- torch stack() meshgrid()
- Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills
- 浏览器窗口切换激活事件 visibilitychange
- The online procurement system of the electronic components industry accurately matches the procurement demand and leverages the digital development of the electronic industry
- Can go struct in go question bank · 15 be compared?
- 【TiDB】TiCDC canal_ Practical application of JSON
- Leader: who can use redis expired monitoring to close orders and get out of here!
- PO模式简介「建议收藏」
- Swin-Transformer(2021-08)
猜你喜欢

Dependencies tool to view exe and DLL dependencies

MySQL事务并发问题和MVCC机制

《所谓情商高,就是会说话》读书笔记

挑选智能音箱时,首选“智能”还是“音质”?这篇文章给你答案

系统集成项目管理工程师认证高频考点:编制项目范围管理计划

4个技巧告诉你,如何使用SMS促进业务销售?

How to use AI technology to optimize the independent station customer service system? Listen to the experts!

Apple Watch无法开机怎么办?苹果手表不能开机解决方法!

iCloud照片无法上传或同步怎么办?
Do you really understand the persistence mechanism of redis?
随机推荐
Digital intelligent supplier management system solution for coal industry: data driven, supplier intelligent platform helps enterprises reduce costs and increase efficiency
How to use AI technology to optimize the independent station customer service system? Listen to the experts!
《客从何处来》
Is it safe to open a mobile stock account? Is it reliable?
Rust 操控大疆可编程无人机 tello
3.10 haas506 2.0开发教程-example-TFT
详解单例模式
视频内容生产与消费创新
Where do the guests come from
屏幕显示技术进化史
SaaS project management system solution for the financial service industry helps enterprises tap a broader growth service space
Word——Word在试图打开文件时遇到错误的一种解决办法
Compare the audio librosa library with the Mel spectrogram in the torchaudio library
期货怎么开户安全些?现在哪些期货公司靠谱些?
depends工具查看exe和dll依赖关系
Small program container technology to promote the operation efficiency of the park
C# Winform程序界面优化实例
Glacier teacher's book
一文详解|Go 分布式链路追踪实现原理
dtd建模