Compare commits
3 Commits
da3deedb0c
...
c1997aaab5
| Author | SHA1 | Date | |
|---|---|---|---|
| c1997aaab5 | |||
| 45f6f19441 | |||
| 2b13292e3b |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
/.vscode
|
/.vscode
|
||||||
/__debug*
|
/__debug*
|
||||||
|
/build
|
||||||
/tmp
|
/tmp
|
||||||
/config.yaml
|
/config.yaml
|
||||||
|
|||||||
6
Makefile
6
Makefile
@ -1,2 +1,8 @@
|
|||||||
|
EXEC=iris-test
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@air
|
@air
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build:
|
||||||
|
@go build -ldflags "-s -w" -o ./build/${EXEC} ./app/main.go
|
||||||
|
|||||||
42
README.md
42
README.md
@ -14,3 +14,45 @@
|
|||||||
## Howto
|
## Howto
|
||||||
|
|
||||||
- [Password Hashing (bcrypt)](https://gowebexamples.com/password-hashing/)
|
- [Password Hashing (bcrypt)](https://gowebexamples.com/password-hashing/)
|
||||||
|
|
||||||
|
|
||||||
|
## Bombardier benchmark
|
||||||
|
|
||||||
|
Pandora - Jet templating engine
|
||||||
|
|
||||||
|
```
|
||||||
|
eden@pandora:[~/apps/sandbox/golang/iris-web-framework]: bombardier -c 100 -d 10s -l http://localhost:8000 ±[A1][main]
|
||||||
|
Bombarding http://localhost:8000 for 10s using 100 connection(s)
|
||||||
|
Done!
|
||||||
|
Statistics Avg Stdev Max
|
||||||
|
Reqs/sec 10542.16 2631.23 17296.86
|
||||||
|
Latency 9.50ms 3.22ms 42.93ms
|
||||||
|
Latency Distribution
|
||||||
|
50% 8.77ms
|
||||||
|
75% 11.86ms
|
||||||
|
90% 15.31ms
|
||||||
|
95% 17.86ms
|
||||||
|
99% 23.90ms
|
||||||
|
HTTP codes:
|
||||||
|
1xx - 0, 2xx - 105258, 3xx - 0, 4xx - 0, 5xx - 0
|
||||||
|
others - 0
|
||||||
|
Throughput: 28.08MB/s
|
||||||
|
```
|
||||||
|
```
|
||||||
|
eden@pandora:[~/apps/sandbox/golang/iris-web-framework]: bombardier -c 100 -d 10s -l http://localhost:8000/users ±[A1][main]
|
||||||
|
Bombarding http://localhost:8000/users for 10s using 100 connection(s)
|
||||||
|
Done!
|
||||||
|
Statistics Avg Stdev Max
|
||||||
|
Reqs/sec 1096.26 427.09 3211.54
|
||||||
|
Latency 91.08ms 80.06ms 471.41ms
|
||||||
|
Latency Distribution
|
||||||
|
50% 78.37ms
|
||||||
|
75% 156.58ms
|
||||||
|
90% 191.60ms
|
||||||
|
95% 223.49ms
|
||||||
|
99% 309.59ms
|
||||||
|
HTTP codes:
|
||||||
|
1xx - 0, 2xx - 11060, 3xx - 0, 4xx - 0, 5xx - 0
|
||||||
|
others - 0
|
||||||
|
Throughput: 19.91MB/s
|
||||||
|
```
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package main
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package main
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package main
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
25
app/main.go
25
app/main.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"iris-test/app/common"
|
||||||
"iris-test/app/views"
|
"iris-test/app/views"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -15,32 +16,32 @@ import (
|
|||||||
var redisDB *redis.Database
|
var redisDB *redis.Database
|
||||||
|
|
||||||
func createSessionEngine() *sessions.Sessions {
|
func createSessionEngine() *sessions.Sessions {
|
||||||
redisAddr := fmt.Sprintf("%s:%d", Config.Redis.Host, Config.Redis.Port)
|
redisAddr := fmt.Sprintf("%s:%d", common.Config.Redis.Host, common.Config.Redis.Port)
|
||||||
|
|
||||||
redisDB = redis.New(redis.Config{
|
redisDB = redis.New(redis.Config{
|
||||||
Network: "tcp",
|
Network: "tcp",
|
||||||
Addr: redisAddr,
|
Addr: redisAddr,
|
||||||
Timeout: time.Duration(30) * time.Second,
|
Timeout: time.Duration(30) * time.Second,
|
||||||
MaxActive: 10,
|
MaxActive: 10,
|
||||||
Username: Config.Redis.Username,
|
Username: common.Config.Redis.Username,
|
||||||
Password: Config.Redis.Password,
|
Password: common.Config.Redis.Password,
|
||||||
Database: Config.Redis.Database,
|
Database: common.Config.Redis.Database,
|
||||||
Prefix: Config.Redis.Prefix,
|
Prefix: common.Config.Redis.Prefix,
|
||||||
Driver: redis.GoRedis(), // defaults to this driver.
|
Driver: redis.GoRedis(), // defaults to this driver.
|
||||||
// To set a custom, existing go-redis client, use the "SetClient" method:
|
// To set a custom, existing go-redis client, use the "SetClient" method:
|
||||||
// Driver: redis.GoRedis().SetClient(customGoRedisClient)
|
// Driver: redis.GoRedis().SetClient(customGoRedisClient)
|
||||||
})
|
})
|
||||||
|
|
||||||
sessions_engine := sessions.New(sessions.Config{
|
sessionsEngine := sessions.New(sessions.Config{
|
||||||
Cookie: "_session_id",
|
Cookie: "_session_id",
|
||||||
Expires: 0, // defaults to 0: unlimited life. Another good value is: 45 * time.Minute,
|
Expires: 0, // defaults to 0: unlimited life. Another good value is: 45 * time.Minute,
|
||||||
AllowReclaim: true,
|
AllowReclaim: true,
|
||||||
CookieSecureTLS: true,
|
CookieSecureTLS: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
sessions_engine.UseDatabase(redisDB)
|
sessionsEngine.UseDatabase(redisDB)
|
||||||
|
|
||||||
return sessions_engine
|
return sessionsEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAccessLog() *accesslog.AccessLog {
|
func createAccessLog() *accesslog.AccessLog {
|
||||||
@ -83,7 +84,7 @@ func createApp() *iris.Application {
|
|||||||
accessLog := createAccessLog()
|
accessLog := createAccessLog()
|
||||||
|
|
||||||
app := iris.New()
|
app := iris.New()
|
||||||
app.Logger().SetLevel(Config.Application.LogLevel)
|
app.Logger().SetLevel(common.Config.Application.LogLevel)
|
||||||
app.Use(sessionsEngine.Handler())
|
app.Use(sessionsEngine.Handler())
|
||||||
app.UseRouter(accessLog.Handler)
|
app.UseRouter(accessLog.Handler)
|
||||||
app.RegisterView(iris.Jet("./app/templates", ".jet").Reload(true))
|
app.RegisterView(iris.Jet("./app/templates", ".jet").Reload(true))
|
||||||
@ -92,9 +93,9 @@ func createApp() *iris.Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
InitCfg()
|
common.InitCfg()
|
||||||
InitLogging()
|
common.InitLogging()
|
||||||
InitDB()
|
common.InitDB()
|
||||||
|
|
||||||
app := createApp()
|
app := createApp()
|
||||||
defer redisDB.Close()
|
defer redisDB.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user