Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	components/mongo/component.go
liliang 7 miesięcy temu
rodzic
commit
0d6b0065e4

+ 15 - 2
components/mongo/component.go

@@ -103,11 +103,24 @@ func CreateDatabase(uri, dbName string, tlsEnable int, maxClient uint64, timeout
 			MinVersion:               tls.VersionTLS12,
 			PreferServerCipherSuites: true,
 		}
-		o = options.Client().ApplyURI(uri).SetTLSConfig(tlsConfig).SetMaxPoolSize(maxClient)
+
+		o = options.Client().ApplyURI(uri).SetMaxPoolSize(500). //最大连接
+			SetMinPoolSize(20).                  //最小连接
+			SetMaxConnIdleTime(3 * time.Minute). //连接空闲时间
+			SetMaxConnIdleTime(5 * time.Minute). //连接生命周期
+			SetConnectTimeout(10 * time.Second). //连接超时时间
+			SetSocketTimeout(10 * time.Second).SetTLSConfig(tlsConfig)   //套接字超时时间
 	} else {
-		o = options.Client().ApplyURI(uri).SetMaxPoolSize(maxClient)
+		o = options.Client().ApplyURI(uri).SetMaxPoolSize(500). //最大连接
+			SetMinPoolSize(20).                  //最小连接
+			SetMaxConnIdleTime(3 * time.Minute). //连接空闲时间
+			SetMaxConnIdleTime(5 * time.Minute). //连接生命周期
+			SetConnectTimeout(10 * time.Second). //连接超时时间
+			SetSocketTimeout(10 * time.Second)
 	}
 
+
+	
 	if err := o.Validate(); err != nil {
 		return nil, err
 	}

+ 1 - 1
game/game_cluster/robot_client/main.go

@@ -17,7 +17,7 @@ import (
 func main() {
 
 	// 定义命令行标志
-	userOffset := flag.Int("userOffset", 300001, "用户偏移量")
+	userOffset := flag.Int("userOffset", 400001, "用户偏移量")
 	count := flag.Int("count", 50000, "请求总数")
 	qps := flag.Int("qps", 200, "最大并发数")
 	url := flag.String("url", "http://127.0.0.1:20000", "请求url")