- Le plus récent
- Le plus de votes
- La plupart des commentaires
Hey Dilshan,
If you look at https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Limits.html, you going to see that:
The maximum number of simultaneous database connections varies by the DB engine type and the memory allocation for the DB instance class. The maximum number of connections is generally set in the parameter group associated with the DB instance. The exception is Microsoft SQL Server, where it is set in the server properties for the DB instance in SQL Server Management Studio (SSMS).
Having said that, In AWS CDK, you can't directly access the maximum number of database connections specific to an instance type at runtime because the CDK constructs are resolved during synthesis time (when you run cdk deploy
), which is before the resource is actually created in AWS. This max connections value is also not exposed directly via the CloudFormation resources that CDK encapsulates.
However, you could create a mapping structure in your CDK code that hardcodes the instance type and the max connections. You can then look up the threshold based on the used instance type during CDK synthesis.
const maxConnectionsByInstanceType = {
't3.medium': 1000,
// other instance types...
};
const instanceType = 't3.medium'; // this would come from your actual instance declaration
const maxConnections = maxConnectionsByInstanceType[instanceType];
const thresholdValue = maxConnections * 0.75;
const dbConnectionsAlarm = ConnectionsMetric.createAlarm(this, 'TestAlarm', {
alarmName: 'DB-DbConnections-Alarm',
threshold: thresholdValue,
evaluationPeriods: 1
});
Any approach you use will need to account for both and should be cross-checked against the official AWS documentation for RDS limits. Please note that none of these strategies will automatically adjust the threshold if AWS changes the connection limits for an RDS instance type. This aspect would still need to be manually managed.
Contenus pertinents
- demandé il y a un an
- demandé il y a un an
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a 4 mois
- AWS OFFICIELA mis à jour il y a un an