K8S - storage - minPoolSize/maxPoolSize per server
MODIFY
src/assets/storage/schemas/configuration/configuration-save.json
src/assets/storage/schemas/configuration/configuration-save.json
"poolSize": {
"type": "integer"
},
+ "minPoolSize": {
+ "type": "integer"
+ },
+ "maxPoolSize": {
+ "type": "integer"
+ },
"debug": {
"type": "boolean"
},
},
"required": [
"implementation",
- "uri",
- "poolSize"
+ "uri"
]
},
"OCPIService": {

MODIFY
src/storage/mongodb/MongoDBStorage.ts
src/storage/mongodb/MongoDBStorage.ts
@@ -267,17 +267,31 @@ export default class MongoDBStorage {
}
// Connect to EVSE
Logging.logConsoleDebug(`Connecting to '${mongoUrl}'`);
- const mongoDBClient = await MongoClient.connect(
+ // Connection pool size
+ let minPoolSize: number, maxPoolSize: number;
+ if (this.dbConfig.minPoolSize && this.dbConfig.maxPoolSize) {
+ // New configuration (K8S)
+ minPoolSize = this.dbConfig.minPoolSize;
+ maxPoolSize = this.dbConfig.maxPoolSize;
+ } else if (this.dbConfig.poolSize) {
+ // Legacy configuration (AWS FARGATE)
+ minPoolSize = Math.floor(this.dbConfig.poolSize / 2);
+ maxPoolSize = this.dbConfig.poolSize;
+ } else {
+ // Default values
+ minPoolSize = 10;
+ maxPoolSize = 100;
+ }
+ // Mongo Client to EVSE DB
+ this.mongoDBClient = await MongoClient.connect(
mongoUrl,
{
- minPoolSize: Math.floor(this.dbConfig.poolSize / 2),
- maxPoolSize: this.dbConfig.poolSize,
+ minPoolSize,
+ maxPoolSize,
loggerLevel: this.dbConfig.debug ? 'debug' : null,
readPreference: this.dbConfig.readPreference ? this.dbConfig.readPreference as ReadPreferenceMode : ReadPreferenceMode.secondaryPreferred
}
);
- // Get the EVSE DB
- this.mongoDBClient = mongoDBClient;
this.database = this.mongoDBClient.db();
// Keep a global reference
global.database = this;

MODIFY
src/types/configuration/StorageConfiguration.ts
src/types/configuration/StorageConfiguration.ts
@@ -6,9 +6,12 @@ export default interface StorageConfiguration {
user: string;
password: string;
database: string;
- poolSize: number;
+ poolSize?: number;
+ minPoolSize?: number;
+ maxPoolSize?: number;
replicaSet: string;
monitorDBChange: boolean;
debug: boolean;
readPreference: string;
}
+

K8S - storage - minPoolSize/maxPoolSize per server