mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 05:07: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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
|
||||||
"github.com/DataDog/datadog-go/statsd"
|
"github.com/DataDog/datadog-go/statsd"
|
||||||
|
@ -36,17 +37,31 @@ func Execute(ctx context.Context) int {
|
||||||
if !profile {
|
if !profile {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
f, perr := os.Create("cpu.pprof")
|
f, perr := os.Create("cpu.pprof")
|
||||||
if perr != nil {
|
if perr != nil {
|
||||||
return perr
|
return perr
|
||||||
}
|
}
|
||||||
|
|
||||||
pprof.StartCPUProfile(f)
|
pprof.StartCPUProfile(f)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if profile {
|
if !profile {
|
||||||
pprof.StopCPUProfile()
|
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 := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
t.MaxIdleConns = connLimit / 4
|
t.MaxIdleConns = connLimit / 4 / 100
|
||||||
t.MaxConnsPerHost = connLimit
|
t.MaxConnsPerHost = connLimit / 100
|
||||||
t.MaxIdleConnsPerHost = connLimit / 4
|
t.MaxIdleConnsPerHost = connLimit / 4 / 100
|
||||||
t.IdleConnTimeout = 60 * time.Second
|
t.IdleConnTimeout = 60 * time.Second
|
||||||
t.ResponseHeaderTimeout = 5 * time.Second
|
t.ResponseHeaderTimeout = 5 * time.Second
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue