Increase max thread count to 50k

Signed-off-by: Dong Chen <dongluo.chen@docker.com>
This commit is contained in:
Dong Chen 2016-03-14 18:35:02 -07:00
parent e24cc12814
commit 408f3cff8e
1 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"runtime/debug"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
@ -13,6 +14,8 @@ import (
// Run the Swarm CLI.
func Run() {
setProgramLimits()
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Usage = "A Docker-native clustering system"
@ -66,3 +69,11 @@ func Run() {
log.Fatal(err)
}
}
func setProgramLimits() {
// Swarm runnable threads could be large when the number of nodes is large
// or under request bursts. Most threads are occupied by network connections.
// Increase max thread count from 10k default to 50k to accommodate it.
const maxThreadCount int = 50 * 1000
debug.SetMaxThreads(maxThreadCount)
}