mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +00:00
tweak client settings
This commit is contained in:
parent
26ca63f31b
commit
ac4765f813
2 changed files with 21 additions and 6 deletions
|
@ -3,6 +3,7 @@ package cmd
|
|||
import (
|
||||
"context"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
|
||||
"github.com/DataDog/datadog-go/statsd"
|
||||
|
@ -36,17 +37,31 @@ func Execute(ctx context.Context) int {
|
|||
if !profile {
|
||||
return nil
|
||||
}
|
||||
|
||||
f, perr := os.Create("cpu.pprof")
|
||||
if perr != nil {
|
||||
return perr
|
||||
}
|
||||
|
||||
pprof.StartCPUProfile(f)
|
||||
return nil
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
if profile {
|
||||
pprof.StopCPUProfile()
|
||||
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
||||
if !profile {
|
||||
return nil
|
||||
}
|
||||
|
||||
pprof.StopCPUProfile()
|
||||
|
||||
f, perr := os.Create("mem.pprof")
|
||||
if perr != nil {
|
||||
return perr
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
runtime.GC()
|
||||
err := pprof.WriteHeapProfile(f)
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ func NewClient(id, secret string, statsd *statsd.Client, connLimit int) *Client
|
|||
}
|
||||
|
||||
t := http.DefaultTransport.(*http.Transport).Clone()
|
||||
t.MaxIdleConns = connLimit / 4
|
||||
t.MaxConnsPerHost = connLimit
|
||||
t.MaxIdleConnsPerHost = connLimit / 4
|
||||
t.MaxIdleConns = connLimit / 4 / 100
|
||||
t.MaxConnsPerHost = connLimit / 100
|
||||
t.MaxIdleConnsPerHost = connLimit / 4 / 100
|
||||
t.IdleConnTimeout = 60 * time.Second
|
||||
t.ResponseHeaderTimeout = 5 * time.Second
|
||||
|
||||
|
|
Loading…
Reference in a new issue