Skip to content

Commit

Permalink
Remove NumProxyEventGoRoutines field from cluster config.
Browse files Browse the repository at this point in the history
  • Loading branch information
aforge committed Sep 29, 2020
1 parent 1d47736 commit 127138f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
27 changes: 5 additions & 22 deletions server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/tinode/chat/server/auth"
"github.com/tinode/chat/server/concurrency"
"github.com/tinode/chat/server/push"
rh "github.com/tinode/chat/server/ringhash"
"github.com/tinode/chat/server/store/types"
Expand Down Expand Up @@ -52,9 +51,8 @@ type clusterConfig struct {
Nodes []clusterNodeConfig `json:"nodes"`
// Name of this cluster node
ThisName string `json:"self"`
// Size of the cluster event goroutine pool (used by topic master multiplexing sessions
// for forwarding events to the topic proxies).
NumProxyEventGoRoutines int `json:"num_proxy_event_goroutines"`
// Deprecated: this field is no longer used.
NumProxyEventGoRoutines int `json:"-"`
// Failover configuration
Failover *clusterFailoverConfig
}
Expand Down Expand Up @@ -407,13 +405,6 @@ type Cluster struct {

// Failover parameters. Could be nil if failover is not enabled
fo *clusterFailover

// Thread pool to use for running proxy session (write) event processing logic.
// The number of proxy sessions grows as O(number of topics x number of cluster nodes).
// In large Tinode deployments (10s of thousands of topics, tens of nodes),
// running a separate event processing goroutine for each proxy session
// leads to a rather large memory usage and excessive scheduling overhead.
proxyEventQueue *concurrency.GoRoutinePool
}

// TopicMaster is a gRPC endpoint which receives requests sent by proxy topic to master topic.
Expand Down Expand Up @@ -914,21 +905,14 @@ func clusterInit(configString json.RawMessage, self *string) int {
gob.Register(map[string]string{})
gob.Register(MsgAccessMode{})

numProxyGoRoutines := config.NumProxyEventGoRoutines
if numProxyGoRoutines < 0 {
log.Println("Cluster: invalid number of proxy event goroutines:", numProxyGoRoutines)
return 1
}
if numProxyGoRoutines == 0 {
numProxyGoRoutines = len(config.Nodes) * 5
log.Println("Cluster: number of proxy event goroutines not specified. Default is", numProxyGoRoutines)
if config.NumProxyEventGoRoutines != 0 {
log.Println("Cluster config: field num_proxy_event_goroutines is deprecated.")
}

globals.cluster = &Cluster{
thisNodeName: thisName,
fingerprint: time.Now().Unix(),
nodes: make(map[string]*ClusterNode),
proxyEventQueue: concurrency.NewGoRoutinePool(numProxyGoRoutines)}
nodes: make(map[string]*ClusterNode)}

var nodeNames []string
for _, host := range config.Nodes {
Expand Down Expand Up @@ -1013,7 +997,6 @@ func (c *Cluster) shutdown() {
close(n.rpcDone)
}

globals.cluster.proxyEventQueue.Stop()
globals.cluster = nil

c.inbound.Close()
Expand Down
4 changes: 0 additions & 4 deletions server/tinode.conf
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,6 @@
{"name": "three", "addr":"localhost:12003"}
],

// Number of goroutines used for processing topic master to proxy responses.
// If not specified, the server will use len(nodes) x 5 by default.
// "num_proxy_event_goroutines": 20,

// Failover config.
"failover": {
// Failover is enabled.
Expand Down

0 comments on commit 127138f

Please sign in to comment.