mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
Option for Socket Sharding as requested at #1544
Former-commit-id: 0384baf593012377a94344d647ca41121294285a
This commit is contained in:
21
_examples/http-server/socket-sharding/main.go
Normal file
21
_examples/http-server/socket-sharding/main.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris/v12"
|
||||
)
|
||||
|
||||
func main() {
|
||||
startup := time.Now()
|
||||
|
||||
app := iris.New()
|
||||
app.Get("/", func(ctx iris.Context) {
|
||||
s := startup.Format(ctx.Application().ConfigurationReadOnly().GetTimeFormat())
|
||||
ctx.Writef("This server started at: %s\n", s)
|
||||
})
|
||||
|
||||
// This option allows linear scaling server performance on multi-CPU servers.
|
||||
// See https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/ for details.
|
||||
app.Listen(":8080", iris.WithSocketSharding)
|
||||
}
|
||||
Reference in New Issue
Block a user